private void RefreshSkillList()
        {
            skList  = getTransformByPath("skillist/skillist");
            corners = new Vector3[4];
            skList.GetComponent <RectTransform>().GetWorldCorners(corners);

            int i = 0;

            foreach (skill_a3Data sk in Skill_a3Model.getInstance().skilldic.Values)
            {
                //!--非本职业,普通技能,buff技能,未学的技能不可见
                if (sk.carr != PlayerModel.getInstance().profession ||
                    sk.skill_id == a1_gamejoy.NORNAL_SKILL_ID ||
                    sk.now_lv == 0 ||
                    sk.skillType2 == 1)
                {
                    continue;
                }

                int       skid    = sk.skill_id;
                Transform sktrans = skList.GetChild(i);
                sktrans.name = skid.ToString();
                sktrans.FindChild("bg/mask").gameObject.SetActive(true);
                sktrans.FindChild("bg").gameObject.SetActive(true);
                sktrans.FindChild("bg/mask/icon").GetComponent <Image>().sprite = GAMEAPI.ABUI_LoadSprite("icon_skill_" + skid.ToString());
                BaseButton btn = new BaseButton(sktrans.FindChild("bg"));
                btn.onClick = OnSkillListClick;
                i++;
            }

            for (int j = i; j < skList.childCount; j++)
            {
                Transform sktrans = skList.GetChild(j);
                sktrans.name = "0";
                sktrans.FindChild("bg/mask").gameObject.SetActive(false);
                sktrans.FindChild("bg").gameObject.SetActive(false);
                BaseButton btn = new BaseButton(sktrans.FindChild("bg"));
                btn.onClick = OnSkillListClick;
            }

            for (i = 0; i < 4; i++)
            {
                if (apModel.Skills[i] == 0)
                {
                    skillChoosed[i].transform.FindChild("mask").gameObject.SetActive(false);
                }
                else
                {
                    skillChoosed[i].transform.FindChild("mask").gameObject.SetActive(true);
                    skillChoosed[i].transform.FindChild("mask/icon").GetComponent <Image>().sprite = GAMEAPI.ABUI_LoadSprite("icon_skill_" + apModel.Skills[i].ToString());
                }
            }
        }
Exemple #2
0
        public override void Execute(float delta_time)
        {
            timer += delta_time;
            if (timer < 0.1f)
            {
                return;
            }
            timer -= 1.0f;

            if (TargetLost || Vector3.Distance(startPos, SelfRole._inst.m_curModel.position) > StateInit.Instance.PKDistance ||
                Enemy.isDead)
            {//!--超出追击距离,返回最近的挂机点
                Vector3 backpt = StateInit.Instance.GetNearestWayPoint();
                StateAutoMoveToPos.Instance.pos          = backpt;
                StateAutoMoveToPos.Instance.stopdistance = 2.0f;
                SelfRole.fsm.ChangeState(StateAutoMoveToPos.Instance);
                return;
            }

            //!--获取可以使用的技能,并检查攻击距离
            int          skid   = StateInit.Instance.GetSkillCanUse();
            skill_a3Data skdata = null;

            Skill_a3Model.getInstance().skilldic.TryGetValue(skid, out skdata);
            float range = skdata.range / GameConstant.PIXEL_TRANS_UNITYPOS;

            TargetLost = Enemy.m_curModel == null;
            float enemyDis = Vector3.Distance(Enemy.m_curModel.position, SelfRole._inst.m_curModel.position);

            if (enemyDis > range)
            {
                SelfRole._inst.m_moveAgent.destination      = Enemy.m_curModel.position;
                SelfRole._inst.m_moveAgent.stoppingDistance = range - 0.125f;
                SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
            }
            else
            {
                SelfRole._inst.m_moveAgent.Stop();
                SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                SelfRole._inst.TurnToRole(Enemy, true);
                bool ret = a1_gamejoy.inst_skillbar.playSkillById(skid);
                if (ret == true && StateInit.Instance.PreferedSkill == skid)
                {
                    StateInit.Instance.PreferedSkill = -1;
                }
            }
        }
        public void onLoadRune(Variant data)
        {
            int res = data["res"];

            switch (res)
            {
            case 1:
                debug.Log("符文的信息:" + data.dump());
                dispatchEvent(GameEvent.Create(RUNEINFOS, this, data));

                break;;

            case 2:    //加个字段,判断是开启符文
                debug.Log("符文开始研究结果:" + data.dump());
                Skill_a3Model.getInstance().Reshreinfos(data["id"], -1, data["upgrade_count_down"]);
                dispatchEvent(GameEvent.Create(RUNERESEARCH, this, data));
                if (data["upgrade_count_down"] == 0)
                {
                    if (a3_runeopen.instance != null)
                    {
                        a3_runeopen.instance.open_id = data["id"];
                        a3_runeopen.instance.refreshInfo();
                    }
                }
                break;

            case 3:
                debug.Log("符文加速结果:" + data.dump());
                Skill_a3Model.getInstance().Reshreinfos(data["id"], data["lvl"], 0);
                dispatchEvent(GameEvent.Create(RUNEADDSPEED, this, data));
                break;

            case 4:
                debug.Log("升级完成给客户端数据:" + data.dump());
                Skill_a3Model.getInstance().Reshreinfos(data["id"], data["lvl"], 0);
                dispatchEvent(GameEvent.Create(RUNERESEARCHOVER, this, data));
                break;

            default:
                Globle.err_output(data["res"]);
                break;
            }
            ;
        }
        public override void onShowed()
        {
            GameObject iconPrefab = GAMEAPI.ABLayer_LoadNow_GameObject("uilayer_a3_autoplay_skill_icon");

            int skcnt = 0;

            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)
                {
                    continue;
                }

                GameObject icon = Instantiate(iconPrefab) as GameObject;
                if (icon == null)
                {
                    continue;
                }

                int skid = sk.skill_id;

                icon.transform.parent = grid.transform;
                icon.name             = skid.ToString();
                icon.transform.FindChild("bg/mask/icon").GetComponent <Image>().sprite = GAMEAPI.ABUI_LoadSprite("icon_skill_" + skid.ToString());

                icon.transform.FindChild("bg").GetComponent <Button>().onClick.AddListener(() =>
                {
                    onClose(null);
                    OnSkillChoose(skid, SkillSeat);
                });

                skcnt++;
            }

            if (skcnt == 0)
            {
                flytxt.instance.fly(ContMgr.getCont("a3_autoplay_skill"));
            }
        }
        // --<自动战斗> 玩家是否正在返回途中
        //private bool isReturning;
        public StateMachine()
        {
            IsPause = false;

            currentState  = null;
            previousState = null;
            globalState   = null;
            proxyState    = null;

            skill_a3Data skdata = null;
            int          skid   = -1;

            switch (PlayerModel.getInstance().profession)
            {
            default:
            case 2: skid = 2001; break;

            case 3: skid = 3001; break;

            case 5: skid = 5001; break;
            }
            Skill_a3Model.getInstance().skilldic.TryGetValue(skid, out skdata);
            StateAttack.MinRange = skdata.range / GameConstant.PIXEL_TRANS_UNITYPOS;
        }
        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;
            }
        }
Exemple #7
0
        public override void Execute(float delta_time)
        {
            //exe_action_tm += delta_time;
            //Debug.LogError(string.Format("当前时间:{0},技能开始时间:{1},时间间隔:{2},技能的执行时间:{3}", muNetCleint.instance.CurServerTimeStamp, exe_action_tm, muNetCleint.instance.CurServerTimeStamp - exe_action_tm, xml_action_tm));
            if (muNetCleint.instance.CurServerTimeStamp - exe_action_tm < xml_action_tm || SelfRole._inst.isPlayingSkill)
            {
                return;
            }

            if (mon > 0) //每击杀[一次](不是一只)怪物,额外触发一次拾取物品
            {
                mon--;
                if (!PlayerModel.getInstance().havePet || (PlayerModel.getInstance().havePet&& PlayerModel.getInstance().last_time == 0))
                {
                    SelfRole.fsm.ChangeState(StatePick.Instance);
                }
                return;
            }

            if (SelfRole._inst.m_LockRole != null)
            {
                if (SelfRole._inst.m_LockRole is CollectRole)
                {
                    SelfRole._inst.m_LockRole = null;
                }
                else if (PlayerModel.getInstance().pk_state == PK_TYPE.PK_PEACE)
                {
                    if (SelfRole._inst.m_LockRole is ProfessionRole)
                    {
                        SelfRole._inst.m_LockRole = null;
                    }
                }
                else if (PlayerModel.getInstance().pk_state == PK_TYPE.PK_TEAM && TeamProxy.getInstance().MyTeamData != null)
                {
                    if (TeamProxy.getInstance().MyTeamData.itemTeamDataList.Exists((m) => m.cid == SelfRole._inst.m_LockRole.m_unCID))
                    {
                        SelfRole._inst.m_LockRole = null;
                    }
                }
            }

            //if (SelfRole._inst.m_LockRole is ProfessionRole &&
            //    SelfRole._inst.m_ePK_Type == PK_TYPE.PK_PEACE) // 玩家在和平状态下挂机,手动锁定一个玩家时
            //    SelfRole._inst.m_LockRole = null;
            if (SelfRole._inst.m_LockRole == null)
            {
                if (PlayerModel.getInstance().pk_state != PK_TYPE.PK_PEACE)
                {
                    BaseRole plr = OtherPlayerMgr._inst.FindNearestEnemyOne(SelfRole._inst.m_curModel.transform.position, selector: EnemySelector, pkState: PlayerModel.getInstance().pk_state);
                    if (plr != null)
                    {
                        SelfRole._inst.m_LockRole = plr;
                    }
                }
                if (SelfRole._inst.m_LockRole == null)
                {
                    //if (SelfRole._inst.m_LockRole != null /* || SelfRole._inst.m_LockRole is MonsterRole*/)
                    SelfRole._inst.m_LockRole = MonsterMgr._inst.FindNearestMonster(SelfRole._inst.m_curModel.transform.position);
                    MonsterRole mon = SelfRole._inst.m_LockRole as MonsterRole;
                    try
                    {
                        if (PlayerModel.getInstance().task_monsterIdOnAttack.Count != 0 &&
                            !PlayerModel.getInstance().task_monsterIdOnAttack.ContainsValue(mon.monsterid))
                        {
                            SelfRole._inst.m_LockRole = null;
                            SelfRole.fsm.ChangeState(StateIdle.Instance);
                            return;
                        }
                    }
                    catch (Exception)   // 玩家在"角色接受任务后开始自动战斗"时,猛点空白区域,会引发此异常
                                        // 原因是SelfRole._inst.m_LockRole被强制置为null,导致mon未引用到实例对象
                    {
                        SelfRole._inst.m_LockRole = null;
                        SelfRole.fsm.ChangeState(StateIdle.Instance);
                        return;
                    }
                }
            }
            BaseRole target = SelfRole._inst.m_LockRole;

            try
            {
                Vector3 targetPosition = SelfRole._inst.m_LockRole.m_curModel.position;
            }
            catch (Exception)
            {
                SelfRole._inst.m_LockRole = null;
                SelfRole.fsm.RestartState(this);
                return;
            }
            if (target == null || target.isDead)
            {
                StateTimeover += delta_time;
                if (StateTimeover > 1.5f)
                {
                    StateTimeover = 0f;
                    SelfRole.fsm.MoveToOri();
                    return;
                }
                SelfRole._inst.m_LockRole = null;
                //if (BaseRoomItem.instance.dDropItem.Count != 0)
                //    SelfRole.fsm.ChangeState(StatePick.Instance);
                //else
                //    SelfRole.fsm.RestartState(this);
                if (BaseRoomItem.instance.dDropItem_own.Count != 0)
                {
                    if (!PlayerModel.getInstance().havePet || (PlayerModel.getInstance().havePet&& PlayerModel.getInstance().last_time == 0))
                    {
                        SelfRole.fsm.ChangeState(StatePick.Instance);
                    }
                }
                else
                {
                    SelfRole.fsm.RestartState(this);
                }
                return;
            }

            StateTimeover = 0;
            int          skid   = StateInit.Instance.GetSkillCanUse();
            skill_a3Data skdata = null;

            Skill_a3Model.getInstance().skilldic.TryGetValue(skid, out skdata);
            float range = skdata.range / GameConstant.PIXEL_TRANS_UNITYPOS;

            if (skdata.skillType != 0 && Vector3.Distance(target.m_curModel.position, SelfRole._inst.m_curModel.position) > MinRange)
            {
                if (range < Vector3.Distance(SelfRole._inst.m_curModel.position, target.m_curModel.position))
                {
                    StateAutoMoveToPos.Instance.stopdistance = 2.0f;
                    StateAutoMoveToPos.Instance.pos          = SelfRole._inst.m_LockRole.m_curModel.position;
                    SelfRole.fsm.ChangeState(StateAutoMoveToPos.Instance);
                    return;
                }
            }
            SelfRole._inst.TurnToPos(SelfRole._inst.m_LockRole.m_curModel.position);
            exe_action_tm = muNetCleint.instance.CurServerTimeStamp;
            switch (skid)
            {
            case 2001:
            case 3001:
            case 4001:
            case 5001:
                xml_action_tm = 0;
                break;

            default:
                xml_action_tm = skdata.action_tm * 0.1f;
                break;
            }
            bool ret = a1_gamejoy.inst_skillbar.playSkillById(skid);

            if (ret)
            {
                if (StateInit.Instance.PreferedSkill == skid)
                {
                    StateInit.Instance.PreferedSkill = -1;
                }
            }
            else
            {
                xml_action_tm = 0f;
            }
        }
        //!--获取可以使用的技能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);
        }
Exemple #9
0
        public bool CheckUpItem()
        {
            if (PlayerModel.getInstance().inFb)
            {
                return(false);
            }
            // 检查加点
            if (PlayerModel.getInstance().up_lvl > 0)
            {
                Btn_RefreshOrCreate(PlayerModel.getInstance()?.pt_att > 0, Title_BtnStronger.Player_Attribute);
            }
            // 检查装备强化
            EquipStrengthOption availableOptions = a3_EquipModel.getInstance().CheckEquipStrengthAvailable()[true];

            if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.EQP_ENCHANT))
            {
                Btn_RefreshOrCreate((availableOptions & EquipStrengthOption.Add) != 0x00, Title_BtnStronger.Equipment_Add);
            }
            if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.EQP_MOUNTING))
            {
                Btn_RefreshOrCreate((availableOptions & EquipStrengthOption.Gem) != 0x00, Title_BtnStronger.Equipment_Gem);
            }
            if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.EQP_ENHANCEMENT))
            {
                Btn_RefreshOrCreate((availableOptions & EquipStrengthOption.Intensify) != 0x00, Title_BtnStronger.Equipment_Intensify);
            }
            //Btn_RefreshOrCreate((availableOptions & EquipStrengthOption.Stage) != 0x00, Title_BtnStronger.Equipment_Stageup);
            // 检查飞翼
            if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.PET_SWING))
            {
                Btn_RefreshOrCreate(A3_WingModel.getInstance()?.CheckLevelupAvailable() ?? false, Title_BtnStronger.Wings);
            }
            // 检查宠物
            //if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.PET))
            //    Btn_RefreshOrCreate(A3_PetModel.getInstance()?.CheckLevelupAvaiable() ?? false, Title_BtnStronger.Pet);
            // 检查护盾
            //Btn_RefreshOrCreate(HudunModel.getInstance().CheckLevelupAvailable(), Title_BtnStronger.Shield);
            // 检查技能
            if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.SKILL))
            {
                Btn_RefreshOrCreate(Skill_a3Model.getInstance()?.CheckSkillLevelupAvailable() ?? false, Title_BtnStronger.Skill_LevelUp);
            }
            // 检查符文

            // 检查军衔
            if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.ACHIEVEMENT))
            {
                Btn_RefreshOrCreate(a3_RankModel.getInstance()?.CheckTitleLevelupAvailable() ?? false, Title_BtnStronger.Title);
            }
            RefreshView();
            if (ShownItemNum > 0)
            {
                upBtn?.gameObject.SetActive(true);
                if (!gameObject.activeSelf)
                {
                    gameObject.SetActive(true);
                }
                return(true);
            }
            else
            {
                upBtn?.gameObject.SetActive(false);
                if (gameObject.activeSelf)
                {
                    gameObject.SetActive(false);
                }
                return(false);
            }
        }