示例#1
0
        //!--寻找符合的挂机点
        private void GetProperWayPoints()
        {
            AutoPlayModel apmodel = AutoPlayModel.getInstance();

            //DistanceInFB = apmodel.AutoplayXml.GetNode("mdis_fb").getFloat("val");
            Dictionary <int, List <Vector3> > wpdic = apmodel.mapWayPoint;

            List <Vector3> wps = null;

            wpdic.TryGetValue(GRMap.instance.m_nCurMapID, out wps);
            if (wps == null || wps.Count == 0)
            {
                return;
            }

            /*Distance = float.MaxValue;
             * if (apmodel.Scope == 0)
             *  Distance = apmodel.AutoplayXml.GetNode("odis").getFloat("val");
             * else if (apmodel.Scope == 1)*/// Modified

            for (int i = 0; i < wps.Count; i++)
            {
                float dis = Vector3.Distance(Origin, wps[i]);
                if (dis <= Distance)
                {
                    //!--挂机点在圈内为期望的挂机点
                    AutoPoints.Add(new Vector3(wps[i].x, wps[i].y, wps[i].z));
                }
            }
        }
示例#2
0
        private void Init()
        {
            AutoPlayModel apModel = AutoPlayModel.getInstance();
            SXML          xml     = apModel.AutoplayXml;

            string str = xml.GetNode("recover_hp").getString("order");

            string[] s_str = str.Split(',');
            for (int i = 0; i < s_str.Length; i++)
            {
                hpOrder.Add(int.Parse(s_str[i]));
            }

            str   = xml.GetNode("recover_mp").getString("order");
            s_str = str.Split(',');
            for (int i = 0; i < s_str.Length; i++)
            {
                mpOrder.Add(int.Parse(s_str[i]));
            }

            /*str = xml.GetNode("recover_mhp").getString("order");
             * s_str = str.Split(',');
             * for (int i = 0; i < s_str.Length; i++)
             * {
             *  mhpOrder.Add(int.Parse(s_str[i]));
             * }*///Modified

            hasInit = true;
        }
示例#3
0
        public override void init()
        {
            apModel = AutoPlayModel.getInstance();
            inText();
            this.getEventTrigerByPath("ig_bg_bg").onClick = OnClose;
            BaseButton okBtn = new BaseButton(getTransformByPath("ok"));

            okBtn.onClick = OnOK;

            eqpToggles = new Toggle[6];
            for (int i = 0; i < 6; i++)
            {
                eqpToggles[i] = getComponentByPath <Toggle>("eqp" + i);
            }

            matToggles = new Toggle[5];
            for (int i = 0; i < 5; i++)
            {
                matToggles[i] = getComponentByPath <Toggle>("mat" + i);
            }

            equip_Toggles  = getComponentByPath <Toggle>("eqp_cailiao");
            pet_Toggles    = getComponentByPath <Toggle>("pet_cailiao");
            wing_Toggles   = getComponentByPath <Toggle>("wing_cailiao");
            summon_Toggles = getComponentByPath <Toggle>("summon_cailiao");
            drugs_Toggles  = getComponentByPath <Toggle>("drugs");
            golds_Toggles  = getComponentByPath <Toggle>("golds");
            other_Toggles  = getComponentByPath <Toggle>("other");
        }
示例#4
0
        public void PickUpItem()
        {
            if (NetClient.instance == null)
            {
                dispose();
                return;
            }

            long curMs = NetClient.instance.CurServerTimeStampMS;

            if (curMs < cantGetTimer)
            {
                return;
            }

            if (NetClient.instance != null)
            {
                if (curMs - itemdta.initedTimer < 100)
                {
                    return;
                }
            }

            if (isFake)
            {
                FightText.play(FightText.MONEY_TEXT, SelfRole._inst.getHeadPos(), itemdta.count);
                dispose();
            }
            else
            {
                //int timer = NetClient.instance.CurServerTimeStamp;
                //if (timer - lastGetTimer < 3)
                //    return;
                //lastGetTimer = timer;
                //BaseRoomItem.instance.removeDropItm(itemdta.dpid);

                if (SelfRole.fsm.Autofighting &&
                    !AutoPlayModel.getInstance().WillPick((uint)itemdta.tpid))
                {
                    return;
                }
                if (a3_BagModel.getInstance().curi <= a3_BagModel.getInstance().getItems().Count&& (
                        a3_BagModel.getInstance().getItemNumByTpid((uint)itemdta.tpid) == 0 ||
                        a3_BagModel.getInstance().getItemNumByTpid((uint)itemdta.tpid) >= a3_BagModel.getInstance().getItemDataById((uint)itemdta.tpid).maxnum) &&
                    itemdta.tpid != 0)
                {
                    flytxt.instance.fly(ContMgr.getCont("BagProxy_noplace"));
                    return;
                }
                if (itemdta.ownerId == PlayerModel.getInstance().cid || itemdta.ownerId == 0)
                {
                    if (!A3_RollModel.getInstance().rollMapping.ContainsKey(itemdta.dpid))
                    {
                        BaseRoomItem.instance.removeDropItm(itemdta.dpid, false);
                    }
                }

                MapProxy.getInstance().sendPickUpItem(itemdta.dpid);
            }
        }
示例#5
0
        public StateInit()
        {
            AutoPlayModel apmodel = AutoPlayModel.getInstance();

            DistanceNormal = apmodel.AutoplayXml.GetNode("mdis").getFloat("val");
            SXML xml = AutoPlayModel.getInstance().AutoplayXml;

            PickDistanceNormal = xml.GetNode("pickdis").getFloat("val");
            maxAllowedDistance = xml.GetNode("interrupt")?.getInt("val") ?? 3;
        }
        void doHurt(BaseRole toRole, BaseRole frm, int damage, bool isdie, int hprest, int iscrit, bool miss, bool stagger, uint skill_id = 0)
        {
            toRole.onServerHurt(damage, hprest, isdie, frm, iscrit, miss, stagger);

            if (toRole.m_isMain && !miss)
            {
                PlayerModel.getInstance().modHp(hprest);
            }

            if (frm != null)
            {
                //if (frm.m_isMain)
                //{//主角不改变朝向,有些技能伤害是延迟的

                //}
                //else
                //{
                //    frm.TurnToRole(toRole, false);
                //}
                //if (frm is M000P2 || frm is M000P3 || frm is M000P5
                //    frm is ohterP2Warrior || frm is ohterP3Mage || frm is ohterP5Assassin)
                //{
                //    frm.PlaySkill((int)skill_id);
                //    frm.m_LockRole = toRole;
                //}
                //else frm.PlaySkill(0);
                //frm.PlaySkill((int)skill_id);
            }


            if (frm is ProfessionRole &&
                toRole.m_isMain &&
                SelfRole.fsm.Autofighting &&
                AutoPlayModel.getInstance().AutoPK > 0)
            {
                if (StatePK.Instance.Enemy != frm &&
                    SelfRole.fsm.currentState != StatePK.Instance)
                {
                    StatePK.Instance.Enemy = (ProfessionRole)frm;
                    SelfRole.fsm.ChangeState(StatePK.Instance);
                }
            }
        }
示例#7
0
        public void AutoEquipProcess(a3_BagItemData itmdata)
        {
            AutoPlayModel apmodel = AutoPlayModel.getInstance();

            //!--非自动挂机不做处理
            if (!SelfRole.fsm.Autofighting)
            {
                return;
            }

            //!--不处理装备,或vip等级3以下
            if (apmodel.EqpType == 0 || A3_VipModel.getInstance().Level < 3)
            {
                return;
            }

            int eqpproc = apmodel.EqpProc;
            int quality = itmdata.confdata.quality;
            int bitqual = (1 << (quality - 1));

            if ((eqpproc & bitqual) == 0)
            {
                return;
            }

            if (apmodel.EqpType == 1)
            {//!--自动出售
                BagProxy.getInstance().sendSellItems(itmdata.id, itmdata.num);


                flytxt.instance.fly(ContMgr.getCont("StatePick0") + Globle.getColorStrByQuality(itmdata.confdata.item_name, itmdata.confdata.quality));
            }
            else if (apmodel.EqpType == 2)
            {//!--自动分解
                List <uint> eqps = new List <uint>();
                eqps.Add(itmdata.id);
                EquipProxy.getInstance().sendsell(eqps);

                flytxt.instance.fly(ContMgr.getCont("StatePick1") + Globle.getColorStrByQuality(itmdata.confdata.item_name, itmdata.confdata.quality));
            }
        }
        public override void init()
        {
            apModel = AutoPlayModel.getInstance();
            inText();
            this.getEventTrigerByPath("ig_bg_bg").onClick = OnClose;

            eqpToggles = new Toggle[6];
            for (int i = 0; i < 6; i++)
            {
                eqpToggles[i] = getComponentByPath <Toggle>("eqp" + i);
            }

            sellToggle = getComponentByPath <Toggle>("sell");
            sellToggle.onValueChanged.AddListener(OnSellChange);

            recyleToggle = getComponentByPath <Toggle>("recyle");
            recyleToggle.onValueChanged.AddListener(OnRecyleChange);

            BaseButton okBtn = new BaseButton(getTransformByPath("ok"));

            okBtn.onClick = OnOK;
        }
示例#9
0
        public override void Enter()
        {
            Origin = SelfRole._inst.m_curModel.position;

            AutoPoints = new List <Vector3>();
            GetProperWayPoints();

            if (AutoPlayModel.getInstance().RespawnLimit > 0)
            {//开启了自动复活限制
                RespawnTimes = AutoPlayModel.getInstance().RespawnUpBound;
            }
            else
            {
                RespawnTimes = int.MaxValue;
            }

            SXML xml = AutoPlayModel.getInstance().AutoplayXml;

            PKDistance = xml.GetNode("pkdis").getFloat("val");

            //PickInterval = xml.GetNode("pickinterval").getFloat("val");

            PreferedSkill = -1;
        }
        public void onLoadSkill(Variant data)
        {
            debug.Log("a3技能升级:" + data.dump());
            int res = data["res"];

            if (data["res"] == 1)
            {
                Skill_a3Model.getInstance().skillinfos(data["skid"], data["sklvl"]);
                if (skill_a3._instance != null)
                {
                    skill_a3._instance.uprefreshskillinfo(data["skid"], data["sklvl"]);
                    skill_a3._instance.showCanStudy();
                    skill_a3._instance.showLevelupImage();
                    //skill_a3._instance.refresh(data["skid"],data["sklvl"]);
                }
                dispatchEvent(GameEvent.Create(SKILLINFO, this, data));
                //新学技能自动添加到挂机配置
                int acsk = -1;
                int i    = 0;
                foreach (var v in AutoPlayModel.getInstance().Skills)
                {
                    if (v == 0)
                    {
                        bool exist = false;
                        foreach (var s in AutoPlayModel.getInstance().Skills)
                        {
                            if (s == data["skid"])
                            {
                                exist = true;
                            }
                        }
                        if (!exist)
                        {
                            acsk = i;
                            break;
                        }
                    }
                    i++;
                }
                if (acsk >= 0 && Skill_a3Model.getInstance().skilldic.ContainsKey(data["skid"]) &&
                    Skill_a3Model.getInstance().skilldic[data["skid"]].skillType2 != 1)
                {
                    AutoPlayModel.getInstance().Skills[acsk] = data["skid"];
                    AutoPlayModel.getInstance().WriteLocalData();
                }

                if (!Skill_a3Model.getInstance().skillid_have.Contains((int)data["skid"]))
                {
                    Skill_a3Model.getInstance().skillid_have.Add(data["skid"]);
                }

                //新学技能自动添加到技能栏
                if (data.ContainsKey("sklvl") && data["sklvl"] == 1)
                {
                    if (a3_skillopen.instance != null)
                    {
                        a3_skillopen.instance.open_id = data["skid"];
                        a3_skillopen.instance.refreshInfo();
                    }
                    if (Skill_a3Model.getInstance().skillid_have.Count != 2)
                    {//当为第一个技能时不开启自动拖拽,留给新手指引
                        int xxida = -1;
                        int xxidb = -1;
                        for (int a = 0; a < Skill_a3Model.getInstance().idsgroupone.Length; a++)
                        {
                            if (Skill_a3Model.getInstance().idsgroupone[a] <= 0)
                            {
                                xxida = a;
                                break;
                            }
                        }
                        if (xxida < 0)
                        {
                            for (int a = 0; a < Skill_a3Model.getInstance().idsgrouptwo.Length; a++)
                            {
                                if (Skill_a3Model.getInstance().idsgrouptwo[a] <= 0)
                                {
                                    xxidb = a;
                                    break;
                                }
                            }
                        }
                        if (Skill_a3Model.getInstance().skilldic.ContainsKey(data["skid"]))
                        {
                            if (xxida >= 0)
                            {
                                Skill_a3Model.getInstance().idsgroupone[xxida] = data["skid"];
                                if (a1_gamejoy.inst_skillbar != null && a1_gamejoy.inst_skillbar.skillsetIdx == 1)
                                {
                                    a1_gamejoy.inst_skillbar.refreSkill(xxida + 1, data["skid"]);
                                }
                            }
                            else if (xxidb >= 0)
                            {
                                Skill_a3Model.getInstance().idsgrouptwo[xxidb] = data["skid"];
                                if (a1_gamejoy.inst_skillbar != null && a1_gamejoy.inst_skillbar.skillsetIdx == 2)
                                {
                                    a1_gamejoy.inst_skillbar.refreSkill(xxidb + 1, data["skid"]);
                                }
                            }
                            if (skill_a3._instance != null)
                            {
                                skill_a3._instance.openrefreshskillinfo();
                                int x = xxida >= 0 ? 1 : 2;
                                //skill_a3._instance.moveAni(data["skid"], x, xxida);
                            }
                        }
                    }
                }
            }
            else if (data["res"] == 2)
            {
                debug.Log("a3技能组合:" + data.dump());
                Skill_a3Model.getInstance().skillGroups(data["skill_groups"]._arr);
            }
            else if (data["res"] == 4)
            {
                debug.Log("升级:" + data.dump());
                dispatchEvent(GameEvent.Create(SKILLUPINFO, this, data));
            }
            //else if (data["res"]==5)
            //{
            //    debug.Log("确认升级:"+data.dump());
            //    dispatchEvent(GameEvent.Create(SKILLUP, this, data));
            //}
            else if (data["res"] < 0)
            {
                Globle.err_output(data["res"]);
                return;
            }
        }
示例#11
0
        private void pickup_drop()
        {
            #region if
            if (nearest == null || !nearest.gameObject)
            {
                DropItem drpitm;
                float    min = float.MaxValue;
                Dictionary <uint, DropItem> .Enumerator etor = BaseRoomItem.instance.dDropItem_own.GetEnumerator();
                //if (!etor.MoveNext())
                // goto_dropitem = false;
                //所有物品都时间到了
                if (BaseRoomItem.instance.dDropItem.Count <= 0)
                {
                    goto_dropitem = false;
                    return;
                }
                while (etor.MoveNext())
                {
                    drpitm = etor.Current.Value;
                    if (drpitm != null && drpitm.gameObject)
                    {
                        //自己是否可拾取
                        bool hasOwner = drpitm.itemdta.ownerId != 0,
                             notMine  = drpitm.itemdta.ownerId != PlayerModel.getInstance().cid ||
                                        (TeamProxy.getInstance().MyTeamData != null && drpitm.itemdta.ownerId == TeamProxy.getInstance().MyTeamData.teamId);
                        if (hasOwner && notMine)
                        {
                            continue;
                        }
                        //!--距离超过拾取范围
                        if (Vector3.Distance(drpitm.transform.position /*.ConvertToGamePosition()*/, transform.position) > StateInit.Instance.PickDistance)
                        {
                            continue;
                        }
                        //!--如果背包满且不是金币,不捡
                        if (a3_BagModel.getInstance().curi <= a3_BagModel.getInstance().getItems().Count&& (
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) == 0 ||
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) >= a3_BagModel.getInstance().getItemDataById((uint)drpitm.itemdta.tpid).maxnum) &&
                            drpitm.itemdta.tpid != 0)
                        {
                            continue;
                        }

                        if (A3_RollModel.getInstance().rollMapping.ContainsKey(drpitm.itemdta.dpid) && !A3_RollModel.getInstance().rollMapping[drpitm.itemdta.dpid].isCanPick)
                        {
                            continue;
                        }

                        else if (drpitm.canPick && AutoPlayModel.getInstance().WillPick((uint)drpitm.itemdta.tpid))
                        {
                            pickTarget = drpitm;
                            if (nearest == null)
                            {
                                nearest = pickTarget;
                            }
                            else
                            {
                                float dis = Vector3.Distance(pickTarget.transform.position /*.ConvertToGamePosition()*/, transform.position);
                                if (dis < min)
                                {
                                    min     = dis;
                                    nearest = pickTarget;
                                }
                            }
                        }
                        else
                        {
                            pickTarget = null;
                        }
                    }
                }
                calc_ori = transform.position;
                if (nearest != null)
                {
                    //SelfRole._inst.SetDestPos(nearest.transform.position);
                    if (goto_dropitem ^ true)
                    {
                        pickTarget = null;
                    }
                    goto_dropitem = true;
                    drop_pos      = nearest.transform.position;
                    calc_tar      = nearest.transform.position;

                    // if (A3_RollModel.getInstance().rollMapping.ContainsKey(nearest.itemdta.dpid))  // 该物品是roll点物品
                    //{
                    //    bool isCanPick = A3_RollModel.getInstance().rollMapping[nearest.itemdta.dpid].isCanPick;
                    //    if (!isCanPick)
                    //    {
                    //        nearest = null;
                    //        goto_dropitem = false;
                    //        calc_tar = Vector3.zero;
                    //        drop_pos = Vector3.zero;
                    //    }else
                    //    {
                    //        return;
                    //    }
                    //}
                    //else {
                    return;
                    //}
                }
                else
                {
                    goto_dropitem = false;
                    calc_tar      = Vector3.zero;
                    drop_pos      = Vector3.zero;
                }
            }
            #endregion
            #region else
            else
            {
                // print("小鸟和物品之间的距离是多少:" + Vector3.Distance(transform.position, nearest.transform.position/*.ConvertToGamePosition()*/));
                if (Vector3.Distance(transform.position, nearest.transform.position) < 0.5f)
                {
                    if (nearest.gameObject != null)
                    {
                        nearest.PickUpItem();
                        // SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                        goto_dropitem = false;
                        drop_pos      = Vector3.zero;
                        nearest       = null;
                    }
                    else
                    {
                        goto_dropitem = false;
                        drop_pos      = Vector3.zero;
                        nearest       = null;
                    }
                }
                // bool isOutOfTouch = Vector3.Distance(nearest.transform.position.ConvertToGamePosition(), transform.position) > StateInit.Instance.PickDistance;

                if (nearest != null)
                {
                    //print("物品和pet之间的距离:" + Vector3.Distance(nearest.transform.position, transform.position) + ".限定距离:" + StateInit.Instance.PickDistance);
                    if (Vector3.Distance(nearest.transform.position /*.ConvertToGamePosition()*/, transform.position) <= StateInit.Instance.PickDistance)
                    {
                        //SelfRole._inst.TurnToPos(nearest.transform.position);
                        //SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
                        if (goto_dropitem ^ true)
                        {
                            pickTarget = null;
                        }
                        goto_dropitem = true;
                        drop_pos      = nearest.transform.position;
                    }
                    else
                    {
                        nearest = null;
                        // SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                        goto_dropitem = false;
                        drop_pos      = Vector3.zero;
                    }
                }
                calc_cur = Path.transform.position;
                if (nearest == null || nearest.gameObject == null)
                {
                    goto_dropitem = false;
                    drop_pos      = Vector3.zero;
                    //SelfRole._inst.m_moveAgent.Stop();
                    //SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                    //if (SelfRole.fsm.Autofighting)
                    //    SelfRole.fsm.ChangeState(StateAttack.Instance);
                    //else
                    //    SelfRole.fsm.ChangeState(StateIdle.Instance);
                    //return;
                }
            }
            #endregion
        }
示例#12
0
 private void onMpLowerSliderChange(float v)
 {
     AutoPlayModel.getInstance().NMpLower = (int)v;
 }
示例#13
0
        private void setChangeMapData(uint scene_setting_mapid, Variant svrConf, Variant localConf_TO_DEL)
        {
            changeMapTimeSt = NetClient.instance.CurServerTimeStamp;
            curSvrConf      = svrConf;
            InterfaceMgr.doCommandByLua("MapModel:getInstance().getmapinfo", "model/MapModel", curSvrConf);
            debug.Log("C#1::::" + svrConf.dump());
            MediaClient.instance.StopSounds(); //清理所有的音效缓存
            GAMEAPI.ClearAllOneAsset();
            Resources.UnloadUnusedAssets();
            System.GC.Collect(0, System.GCCollectionMode.Forced);

            if (sdk_sendroleLogin)
            {
                sdk_sendroleLogin = false;
                //     LGPlatInfo.inst.logSDKAP("roleLogin");
            }

            MouseClickMgr.init();


            int local_mapid = svrConf["id"]._int;

            //m_nCurMapSceneSettingID = scene_setting_mapid;
            m_nCurMapID = local_mapid;

            bool isFb = false;
            int  idx  = -1;

            for (int i = 0; i < AutoPlayModel.getInstance().autoplayCfg4FB.Count; i++)
            {
                if (AutoPlayModel.getInstance().autoplayCfg4FB[i].map.Contains(m_nCurMapID))
                {
                    isFb = true;
                    idx  = i;
                    break;
                }
            }
            if (isFb)
            {
                if (idx != -1)
                {
                    StateInit.Instance.Distance     = AutoPlayModel.getInstance().autoplayCfg4FB[idx].Distance;
                    StateInit.Instance.PickDistance = AutoPlayModel.getInstance().autoplayCfg4FB[idx].DistancePick;
                }
            }
            else
            {
                StateInit.Instance.Distance     = StateInit.Instance.DistanceNormal;
                StateInit.Instance.PickDistance = StateInit.Instance.PickDistanceNormal;
            }
            //m_CurLocalConf = localConf;
            InterfaceMgr.getInstance().closeAllWin();

            if (MapProxy.getInstance().openWin != null && MapProxy.getInstance().openWin != "")
            {
                if (MapProxy.getInstance().Win_uiData != null && MapProxy.getInstance().Win_uiData != "")
                {
                    ArrayList arr = new ArrayList();
                    arr.Add(MapProxy.getInstance().Win_uiData);
                    InterfaceMgr.getInstance().ui_async_open(MapProxy.getInstance().openWin, arr);
                }
                else
                {
                    InterfaceMgr.getInstance().ui_async_open(MapProxy.getInstance().openWin);
                }
                MapProxy.getInstance().openWin    = null;
                MapProxy.getInstance().Win_uiData = null;
            }
            //combo_txt.clear();


            //TaskModel.getInstance().isSubTask = false;
            LEVEL_PLOT_ID = 0;
            REV_RES_LIST_OK();
            REV_PLOT_PLAY_OVER();
        }
示例#14
0
        private void TryNormalHp()
        {
            cdtime++;
            if (PlayerModel.getInstance().hp >=
                AutoPlayModel.getInstance().NHpLower *PlayerModel.getInstance().max_hp / 100)
            {
                return;
            }
            if (PlayerModel.getInstance().inSpost)
            {
                return;
            }
            int id = GetNormalHpID();

            if (id == -1)
            {//!--没有药,触发购买
                // 改为不再挂机状态也可自动购买
                //if (!SelfRole.fsm.Autofighting)
                //   return;

                if (AutoPlayModel.getInstance().BuyDrug == 0)
                {
                    return;
                }

                SXML        xml       = AutoPlayModel.getInstance().AutoplayXml;
                List <SXML> supply_hp = xml.GetNodeList("supply_hp", "playlimit==" + PlayerModel.getInstance().up_lvl);
                uint        hp_id     = 0;
                uint        max_num   = 0;
                foreach (SXML x in supply_hp)
                {
                    int playerlevel = x.getInt("playerlevel");
                    hp_id   = x.getUint("hp_id");
                    max_num = x.getUint("max_num");
                    if (PlayerModel.getInstance().lvl < playerlevel)
                    {
                        break;
                    }
                }
                if (hp_id != 0)
                {
                    //a3_ItemData itmdata = a3_BagModel.getInstance().getItemDataById(hp_id);
                    shopDatas itmdata = Shop_a3Model.getInstance().GetShopDataById((int)hp_id);
                    if (itmdata == null || itmdata.value <= 0)
                    {
                        return;
                    }
                    if (PlayerModel.getInstance().money < itmdata.value)
                    {
                        if (remindNotEnoughMoney)
                        {
                            Globle.err_output(-4000);
                            remindNotEnoughMoney = false;
                        }
                        return;
                    }
                    else
                    {
                        remindNotEnoughMoney = true;
                    }
                    if (!a3_BagModel.getInstance().getHaveRoom())
                    {
                        return;
                    }

                    uint num;
                    if (max_num * itmdata.value <= PlayerModel.getInstance().money)
                    {
                        num = max_num;
                    }
                    else
                    {
                        num = (uint)(PlayerModel.getInstance().money / itmdata.value);
                    }
                    if (buyhptimer > 2f)
                    {
                        Shop_a3Proxy.getInstance().BuyStoreItems(hp_id, num);
                        buyhptimer = 0f;
                    }
                }
            }
            else
            {//!--有药==在cd时候不吃药
                SXML        itemsXMl = XMLMgr.instance.GetSXML("item");
                SXML        s_xml    = itemsXMl.GetNode("item", "id==" + (uint)id);
                a3_ItemData item     = new a3_ItemData();
                item.tpid    = (uint)id;
                item.cd_time = s_xml.getFloat("cd");
                if (cdtime == 0)
                {
                    a3_BagModel.getInstance().useItemByTpid((uint)id, 1);
                }
                if (cdtime > item.cd_time)
                {
                    a3_BagModel.getInstance().useItemByTpid((uint)id, 1);
                    cdtime = 0;
                    return;
                }
            }
        }
        public override void init()
        {
            apModel = AutoPlayModel.getInstance();
            inText();
            nhpText   = getComponentByPath <Text>("nhptxt");
            nhpSlider = getComponentByPath <Slider>("nhpSlider");
            nmpText   = getComponentByPath <Text>("nmptxt");
            nmpSlider = getComponentByPath <Slider>("nmpSlider");
            //mhpText = getComponentByPath<Text>("mhptxt");
            //mhpSlider = getComponentByPath<Slider>("mhpSlider");
            buyToggle = getComponentByPath <Toggle>("buy");

            nhpSlider.onValueChanged.AddListener(OnNhpSliderChange);
            nmpSlider.onValueChanged.AddListener(OnNmpSliderChange);
            //mhpSlider.onValueChanged.AddListener(OnMhpSliderChange);
            buyToggle.onValueChanged.AddListener(OnBuyToggleChange);

            avoidToggle       = getComponentByPath <Toggle>("avoid");
            pkToggle          = getComponentByPath <Toggle>("pk");
            respawnToggle     = getComponentByPath <Toggle>("respawn");
            goldRespawnToggle = getComponentByPath <Toggle>("goldrespawn");
            upboundToggle     = getComponentByPath <Toggle>("upbound");
            timesInputField   = getComponentByPath <InputField>("times");

            avoidToggle.onValueChanged.AddListener(OnAvoidToggleChange);
            pkToggle.onValueChanged.AddListener(OnPkToggleChange);
            respawnToggle.onValueChanged.AddListener(OnRespawnToggleChange);
            goldRespawnToggle.onValueChanged.AddListener(OnGoldRespawnToggleChange);
            upboundToggle.onValueChanged.AddListener(OnUpboundToggleChange);
            timesInputField.onValueChanged.AddListener(OnTimesInputField);

            skillChoosed = new GameObject[4];
            for (int i = 0; i < 4; i++)
            {
                skillChoosed[i] = getGameObjectByPath("skill/" + i);
                skillChoosed[i].transform.FindChild("mask").localPosition = Vector3.zero;
                var evli = EventTriggerListener.Get(skillChoosed[i].gameObject);
                evli.onDown = (GameObject g) => {
                    dragdown = int.Parse(g.name);
                    dragup   = int.Parse(g.name);
                };
                evli.onDrag = (GameObject g, Vector2 d) => {
                    var t = g.transform.FindChild("mask");
                    t.transform.position += new Vector3(d.x, d.y, 0);
                };
                evli.onEnter = (GameObject g) => {
                    dragdown = int.Parse(g.name);
                };
                var cbg       = getTransformByPath("skill/cbg");
                var cornerskk = new Vector3[4];
                if (cbg != null)
                {
                    cbg.GetComponent <RectTransform>().GetWorldCorners(cornerskk);
                }
                evli.onDragEnd = (GameObject g, Vector2 d) => {
                    Vector3 mousePos = Input.mousePosition;
                    if (mousePos.x < cornerskk[0].x ||
                        mousePos.x > cornerskk[2].x ||
                        mousePos.y <cornerskk[0].y ||
                                    mousePos.y> cornerskk[2].y)
                    {
                        dragdown = -1;
                    }

                    if (dragup != dragdown)
                    {
                        if (dragdown == -1)
                        {
                            //丢弃
                            if (openListSkil != null)
                            {
                                openListSkil.transform.FindChild("mask").gameObject.SetActive(false);
                                apModel.Skills[int.Parse(g.name)] = 0;
                                openListSkil = null;
                                skList.parent.gameObject.SetActive(false);
                            }
                        }
                        else
                        {
                            //交换
                        }
                    }
                    var t = g.transform.FindChild("mask");
                    t.transform.localPosition = Vector3.zero;
                };
                evli.onClick = OnSkillChoosedClick;
                // BaseButton btn = new BaseButton(skillChoosed[i].GetComponent<Button>().transform);
                // btn.onClick = OnSkillChoosedClick;
            }
            ;

            /*oriToggle = getComponentByPath<Toggle>("ap_o");
             * mediumToggle = getComponentByPath<Toggle>("ap_m");
             * wholeToggle = getComponentByPath<Toggle>("ap_l");
             * oriToggle.onValueChanged.AddListener(OnOriToggleChange);
             * mediumToggle.onValueChanged.AddListener(OnMediumToggleChange);
             * wholeToggle.onValueChanged.AddListener(OnWholeToggleChange);*/// Modified

            BaseButton closeBtn = new BaseButton(getTransformByPath("closeBtn"));

            closeBtn.onClick = OnClose;

            BaseButton eqpBtn = new BaseButton(getTransformByPath("eqp"));

            eqpBtn.onClick = OnEqp;

            BaseButton pickBtn = new BaseButton(getTransformByPath("pick"));

            pickBtn.onClick = OnPick;

            // BaseButton startBtn = new BaseButton(getTransformByPath("start"));
            //startBtn.onClick = OnStart;

            //BaseButton stopBtn = new BaseButton(getTransformByPath("stop"));
            // stopBtn.onClick = OnStop;
        }
示例#16
0
        public override void Execute(float delta_time)
        {
            //if (dropTimer > dropDruation)
            //{//限定拾取不超时
            //    SelfRole.fsm.ChangeState(StateIdle.Instance);
            //    return;
            //}
            //dropTimer += delta_time;
            SelfRole._inst.m_moveAgent.avoidancePriority = 1;
            if (passed)
            {
                nearest        =
                    pickTarget = null;
            }
            if (nearest == null || !nearest.gameObject)
            {//选取一个掉落目标,移动过去
                DropItem drpitm;
                float    min = float.MaxValue;
                Dictionary <uint, DropItem> .Enumerator etor = BaseRoomItem.instance.dDropItem_own.GetEnumerator();
                while (etor.MoveNext())
                {
                    drpitm = etor.Current.Value;
                    if (drpitm != null && drpitm.gameObject)
                    {
                        bool hasOwner = drpitm.itemdta.ownerId != 0,
                             notMine  = drpitm.itemdta.ownerId != PlayerModel.getInstance().cid ||
                                        (TeamProxy.getInstance().MyTeamData != null && drpitm.itemdta.ownerId == TeamProxy.getInstance().MyTeamData.teamId);
                        if (hasOwner && notMine)
                        {
                            continue;
                        }
                        //!--距离超过拾取范围
                        if (Vector3.Distance(drpitm.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition()) > StateInit.Instance.PickDistance)
                        {
                            continue;
                        }
                        //!--如果背包满且不是金币,不捡
                        if (a3_BagModel.getInstance().curi <= a3_BagModel.getInstance().getItems().Count&& (
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) == 0 ||
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) >= a3_BagModel.getInstance().getItemDataById((uint)drpitm.itemdta.tpid).maxnum) &&
                            drpitm.itemdta.tpid != 0)
                        {
                            continue;
                        }

                        if (A3_RollModel.getInstance().rollMapping.ContainsKey(drpitm.itemdta.dpid) && !A3_RollModel.getInstance().rollMapping[drpitm.itemdta.dpid].isCanPick)
                        {
                            continue;
                        }

                        else if (drpitm.canPick && AutoPlayModel.getInstance().WillPick((uint)drpitm.itemdta.tpid))
                        {
                            pickTarget = drpitm;
                            if (nearest == null)
                            {
                                nearest = pickTarget;
                            }
                            else
                            {
                                float dis = Vector3.Distance(pickTarget.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition());
                                if (dis < min)
                                {
                                    min     = dis;
                                    nearest = pickTarget;
                                }
                            }
                        }
                        else
                        {
                            pickTarget = null;
                        }
                    }
                }

                calc_ori = SelfRole._inst.m_curModel.transform.position;
                if (nearest != null)
                {
                    //if (A3_RollModel.getInstance().rollMapping.ContainsKey(nearest.itemdta.dpid))  // 该物品是roll点物品
                    //{
                    //    bool isCanPick = A3_RollModel.getInstance().rollMapping[nearest.itemdta.dpid].isCanPick;

                    //    if (!isCanPick)
                    //    {
                    //        nearest = null;
                    //        calc_tar = Vector3.zero;
                    //    }
                    //    else
                    //    {
                    //        SelfRole._inst.SetDestPos(nearest.transform.position);
                    //        calc_tar = nearest.transform.position;
                    //        return;
                    //    }
                    //}
                    //else {

                    SelfRole._inst.SetDestPos(nearest.transform.position);
                    calc_tar = nearest.transform.position;

                    return;
                    //}
                }
                else
                {
                    calc_tar = Vector3.zero;
                }
            }
            else
            {
                //if (nearest != null)
                //{
                if (nearest.gameObject != null && Vector3.Distance(SelfRole._inst.m_curModel.position.ConvertToGamePosition(), nearest.transform.position.ConvertToGamePosition()) < 0.5f)
                {
                    nearest.PickUpItem();
                    SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                    SelfRole.ChangeRideAniState(false);
                    nearest = null;
                }

                if (nearest != null)
                {
                    bool isOutOfTouch = Vector3.Distance(nearest.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition()) > StateInit.Instance.PickDistance;
                    if (!passed && !isOutOfTouch)
                    {
                        SelfRole._inst.TurnToPos(nearest.transform.position);
                        SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
                        SelfRole.ChangeRideAniState(true);
                    }
                    else
                    {
                        nearest = null;
                        SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                        SelfRole.ChangeRideAniState(false);
                    }
                }
                //}
            }


            calc_cur = SelfRole._inst.m_curModel.transform.position;
            passed   = CheckPass(calc_ori, calc_cur, calc_tar);
            if (nearest == null || nearest.gameObject == null)
            {
                SelfRole._inst.m_moveAgent.Stop();
                SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                SelfRole.ChangeRideAniState(false);
                if (SelfRole.fsm.Autofighting)
                {
                    SelfRole.fsm.ChangeState(StateAttack.Instance);
                }
                else
                {
                    SelfRole.fsm.ChangeState(StateIdle.Instance);
                }
                return;
            }
        }
示例#17
0
        //!--获取可以使用的技能ID
        public int GetSkillCanUse()
        {
            if (PreferedSkill != -1)
            {
                long curtime = muNetCleint.instance.CurServerTimeStampMS;
                if (curtime - releaseTime >= 2000)
                {
                    PreferedSkill = -1;
                }
                else
                {
                    skill_a3Data skdata = Skill_a3Model.getInstance().skilldic[PreferedSkill];
                    if (skdata.mp <= PlayerModel.getInstance().mp&&
                        skdata.cdTime <= 0)
                    {
                        return(PreferedSkill);
                    }
                }
            }
            //List<int> skils=new List<int>();
            //foreach (skill_a3Data skillInfo in Skill_a3Model.getInstance().skilllst) {
            //    if (skillInfo.now_lv > 0 && skillInfo.skillType2 == 0)
            //        skils.Add(skillInfo.skill_id);
            //}
            List <int> skils    = new List <int>();
            List <int> allSkils = AutoPlayModel.getInstance().Skills.ToList();

            for (int i = 0; i < allSkils.Count; i++)
            {
                if (Skill_a3Model.getInstance().skilldic.ContainsKey(allSkils[i]))
                {
                    if (Skill_a3Model.getInstance().skilldic[allSkils[i]].skillType2 <= 1)
                    {
                        skils.Add(allSkils[i]);
                    }
                }
            }
            int skid = -1;

            //优先使用buff技能,buff技能不配置在挂机技能组。(现在去掉了)

            //         foreach (skill_a3Data sk in Skill_a3Model.getInstance().skilldic.Values) {
            //	if (sk.carr == PlayerModel.getInstance().profession &&
            //		sk.skill_id != a1_gamejoy.NORNAL_SKILL_ID &&
            //		sk.now_lv != 0 &&
            //                 sk.skillType2 == 1 &&
            //                 sk.mp <= PlayerModel.getInstance().mp &&
            //		 sk.cdTime <= 0
            //                  ) {
            //			return sk.skill_id;
            //	}

            //}

            //选择的技能按cd从长到短排序
            for (int i = 0; i < skils.Count; i++)
            {
                for (int j = i; j < skils.Count; j++)
                {
                    //if (Skill_a3Model.getInstance().skilldic.ContainsKey(skils[i]) && Skill_a3Model.getInstance().skilldic.ContainsKey(skils[j]))
                    //{
                    if (Skill_a3Model.getInstance().skilldic[skils[i]].cd > Skill_a3Model.getInstance().skilldic[skils[j]].cd)
                    {
                        int temp = skils[i];
                        skils[i] = skils[j];
                        skils[j] = temp;
                    }
                    //}
                }
            }

            for (int i = skils.Count - 1; i >= 0; i--)
            {
                if (skils[i] == 0)
                {
                    continue;
                }

                skid = skils[i];
                skill_a3Data skdata = Skill_a3Model.getInstance().skilldic[skid];
                if (skdata.mp > PlayerModel.getInstance().mp ||
                    skdata.cdTime > 0)
                {
                    continue;
                }

                return(skid);
            }

            return(a1_gamejoy.NORNAL_SKILL_ID);
        }