Ejemplo n.º 1
0
    private void InitDefaultGeneralsInfo()
    {
        int[] skillids = new int[] { 1001, 1002, 1003, 1004, 1201, 1202, 1203 };

        int sid = 0;

        foreach (var genData in GameData.GeneralData.dataMap)
        {
            int         gIdx = genData.Key;
            GeneralInfo info = new GeneralInfo();

            info.id = gIdx;


            //info.level = UnityEngine.Random.Range(1, GeneralInfo.LEVEL_LIMIT + 1);
            info.healthCur = info.propData.hp;
            generals.Add(info);

            foreach (int skid in skillids)
            {
                SkillStateData data = new SkillStateData();
                data.skillID = skid;
                //data.state = (SkillState)(UnityEngine.Random.Range(0, (int)SkillState.Count));
                info.skills.Add(data);
            }

            if (info.gamedata.adviser && mine.advisers.Count < GeneralInfo.ASVISER_COUNT_LIMIT)
            {
                mine.advisers.Add(info.id);
            }

            uint[] equiplist = new uint[1115 - 1109 + 1] {
                1109, 1110, 1111, 1112, 1113, 1114, 1115
            };
            List <uint> elist = new List <uint>();
            elist.AddRange(equiplist);
            for (int i = 0; i < GeneralInfo.EQUIP_COUNT_LIMIT; ++i)
            {
                t_ObjectProto equip = new t_ObjectProto();
                equip.lv = 1;
                //int idex = UnityEngine.Random.Range(0, elist.Count);
                //equip.dwObjectID = equiplist[idex];
                //elist.Remove(equip.dwObjectID);
                //info.equips[i] = equip;
            }

            sid += GeneralInfo.SOLDIER_LIMIT;
        }
    }
Ejemplo n.º 2
0
    //计算出下一个技能,可能为-1
    private int CalculateSkillId()
    {
        var            skillStates = PlayerDataManager.Instance.PlayerDataModel.SkillData.SkillStates;
        var            skills      = PlayerDataManager.Instance.PlayerDataModel.SkillData.EquipSkillsPriority;
        var            norskillId  = PlayerDataManager.Instance.GetNormalSkill(true);
        var            skillId     = -1;
        SkillStateData skillState  = null;
        SkillRecord    tbSkill     = null;
        var            cd          = 0;


        var skillsCount0 = skills.Count;

        for (var i = skillsCount0 - 1; i >= 0; i--)
        {
            skillId = skills[i];
            if (skillId == -1)
            {
                continue;
            }

            if (skillId == norskillId)
            {
                continue;
            }
            if (ErrorCodes.OK == GameControl.Instance.CheckSkill(skillId, true))
            {
                return(skillId);
            }
        }


        skillId = norskillId;
        if (ErrorCodes.OK == GameControl.Instance.CheckSkill(skillId, true))
        {
            return(skillId);
        }

        return(-1);
    }
Ejemplo n.º 3
0
    private void InitDefaultGeneralsInfo()
    {
        int[] skillids = new int[] { 1001, 1002, 1003, 1004, 1201, 1202, 1203 };

        int sid = 0;

        foreach (var genData in GameData.GeneralData.dataMap)
        {
            int gIdx = genData.Key;
            GeneralInfo info = new GeneralInfo();

            info.id = gIdx;

            //info.level = UnityEngine.Random.Range(1, GeneralInfo.LEVEL_LIMIT + 1);
            info.healthCur = info.propData.hp;
            generals.Add(info);

            foreach (int skid in skillids)
            {
                SkillStateData data = new SkillStateData();
                data.skillID = skid;
                //data.state = (SkillState)(UnityEngine.Random.Range(0, (int)SkillState.Count));
                info.skills.Add(data);
            }

            if (info.gamedata.adviser && mine.advisers.Count < GeneralInfo.ASVISER_COUNT_LIMIT)
            {
                mine.advisers.Add(info.id);
            }

            uint[] equiplist = new uint[1115 - 1109 + 1] { 1109, 1110, 1111, 1112, 1113, 1114, 1115 };
            List<uint> elist = new List<uint>();
            elist.AddRange(equiplist);
            for (int i = 0; i < GeneralInfo.EQUIP_COUNT_LIMIT; ++i)
            {
                t_ObjectProto equip = new t_ObjectProto();
                equip.lv = 1;
                //int idex = UnityEngine.Random.Range(0, elist.Count);
                //equip.dwObjectID = equiplist[idex];
                //elist.Remove(equip.dwObjectID);
                //info.equips[i] = equip;
            }

            sid += GeneralInfo.SOLDIER_LIMIT;
        }
    }
Ejemplo n.º 4
0
    public ErrorCodes CheckSkill(int skillId, bool isAuto = false)
    {
        var player = ObjManager.Instance.MyPlayer;

        if (null == player)
        {
            Logger.Error("CheckSkill ObjManager.Instance.MyPlayer is null");
            return(ErrorCodes.Unknow);
        }


        if (player.IsInSafeArea())
        {
            return(ErrorCodes.Error_SafeArea);
        }

        if (player.Dead)
        {
            return(ErrorCodes.Error_CharacterDie);
        }

//      if (player.GetCurrentStateName() == OBJ.CHARACTER_STATE.DIZZY)
//      {
//          return ErrorCodes.Error_Dizzy;
//      }

        if (isAuto)
        {
            var buffId = -1;
            if (AutoSkillBuff.TryGetValue(skillId, out buffId))
            {
                var buffManager = ObjManager.Instance.MyPlayer.GetBuffManager();
                if (buffManager != null && buffManager.HasBuff(buffId))
                {
                    return(ErrorCodes.Unknow);
                }
            }
        }

        var PlayerDataModel = PlayerDataManager.Instance.PlayerDataModel;
        //CD
        var skillStates = PlayerDataManager.Instance.PlayerDataModel.SkillData.SkillStates;

        if (skillStates == null)
        {
            Logger.Error("CheckSkill SkillStates is null");
            return(ErrorCodes.Unknow);
        }
        SkillStateData skillState = null;
        var            tbSkill    = Table.GetSkill(skillId);

        if (null == tbSkill)
        {
            return(ErrorCodes.Unknow);
        }

        if (PlayerDataManager.Instance.PlayerDataModel.SkillData.EquipSkills == null)
        {
            Logger.Error("CheckSkill EquipSkills is null");
            return(ErrorCodes.Unknow);
        }

        var isSkipCd = false;
        SkillItemDataModel skillItem = null;
        var skillLevel = 0;

        if (!PlayerDataManager.Instance.mAllSkills.TryGetValue(skillId, out skillItem))
        {
            return(ErrorCodes.Unknow);
        }

        //MP
        var needMp = StringConvert.Level_Value_Ref(tbSkill.NeedMp, skillLevel);

        if (needMp != -1 && PlayerDataModel.Attributes.MpNow < needMp)
        {
            return(ErrorCodes.Error_MpNoEnough);
        }
        //HP
        var needHP = StringConvert.Level_Value_Ref(tbSkill.NeedHp, skillLevel);

        if (needHP != -1 && PlayerDataModel.Attributes.HpNow < needHP)
        {
            return(ErrorCodes.Error_HpNoEnough);
        }

        if (skillStates.TryGetValue(skillId, out skillState))
        {
            if (skillState.State == SkillState.Send)
            {
                return(ErrorCodes.Error_SkillNoCD);
            }
        }
        if (PlayerDataManager.Instance.PlayerDataModel.SkillData.CommonCoolDown > 0 && tbSkill.Type != 3) //xp技能忽视cd
        {
            return(ErrorCodes.Error_SkillNoCD);
        }

        if ((skillItem.CoolDownTime > 0 && skillItem.ChargeLayerTotal <= 1) || skillItem.ChargeLayer == 0)
        {
            return(ErrorCodes.Error_SkillNoCD);
        }

        if (0 != tbSkill.IsEquipCanUse)
        {
            var euipList = PlayerDataManager.Instance.PlayerDataModel.EquipList;
            if (null == euipList)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
            if (euipList.Count <= (int)eEquipType.WeaponMain)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
            var item = euipList[(int)eEquipType.WeaponMain];
            if (null == item)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
            if (-1 == item.ItemId)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
        }

        //anger
        var needAnger = StringConvert.Level_Value_Ref(tbSkill.NeedAnger, skillLevel);


        //妫€鏌uff闄愬埗鏁堟灉
        if (CheckControlType(skillItem, player.GetBuffManager()))
        {
            return(ErrorCodes.Error_SkillNotUse);
        }
        return(ErrorCodes.OK);
    }
Ejemplo n.º 5
0
    public IEnumerator SendUseSkillRequestCoroutine(ulong objId, int skillId, ulong targetId)
    {
        //Logger.Error("SendUseSkillRequestCoroutine ------Send--- {1}--- {0}", Game.Instance.ServerTime, skillId);
        if (skillId == PlayerDataManager.Instance.GetSkillNoWeapon())
        {
            skillId = PlayerDataManager.Instance.GetNormalSkill(false);
        }

        var            requset     = new CharacterUseSkillMsg();
        var            obj         = ObjManager.Instance.FindCharacterById(objId);
        var            skillStates = PlayerDataManager.Instance.PlayerDataModel.SkillData.SkillStates;
        SkillStateData skillState;

        if (skillStates.TryGetValue(skillId, out skillState))
        {
            skillState.State = SkillState.Send;
        }
        else
        {
            skillState         = new SkillStateData();
            skillState.SkillId = skillId;
            skillState.State   = SkillState.Send;
            skillStates.Add(skillId, skillState);
        }

        var x    = obj.Position.x;
        var z    = obj.Position.z;
        var dirX = obj.TargetDirection.x;
        var dirZ = obj.TargetDirection.z;

        requset.CharacterId = objId;
        requset.SkillId     = skillId;
        requset.TargetObjId.Add(targetId);
        requset.Pos = new PositionData
        {
            Pos = new Vector2Int32
            {
                x = GameUtils.MultiplyPrecision(x),
                y = GameUtils.MultiplyPrecision(z)
            },
            Dir = new Vector2Int32
            {
                x = GameUtils.MultiplyPrecision(dirX),
                y = GameUtils.MultiplyPrecision(dirZ)
            }
        };
        Logger.Info(".......SendUseSkillRequest.....objId : {0}..skillId : {1}", objId, skillId);
        var msg = Instance.SendUseSkillRequest(requset);

        yield return(msg.SendAndWaitUntilDone());

        skillState.State = SkillState.Rece;
        //Logger.Error("SendUseSkillRequestCoroutine ------Rece---{1}--- {0}", Game.Instance.ServerTime,skillId);
        if (msg.State == MessageState.Reply)
        {
            if (msg.ErrorCode == (int)ErrorCodes.OK)
            {
                EventDispatcher.Instance.DispatchEvent(new UiEventChangeOutLineTime());
                if (msg.Response.Items.Count < 1)
                {
                    yield break;
                }
                skillId = msg.Response.Items[0];
                if (obj.GetObjType() == OBJ.TYPE.MYPLAYER)
                {
                    EventDispatcher.Instance.DispatchEvent(new UIEvent_UseSkill(skillId));
                    //SkillReleaseNetBack e = new SkillReleaseNetBack(skillId, true);
                    //EventDispatcher.Instance.DispatchEvent(e);
                }
                yield break;
            }
            if (msg.ErrorCode == (int)ErrorCodes.Error_CharacterDie ||
                msg.ErrorCode == (int)ErrorCodes.Error_SkillNotUse)
            {
//异步逻辑可能发送接受不一致
                Logger.Info("[DoUseSkill]  SkillId : {0}  msg.ErrorCode={1}", skillId, msg.ErrorCode.ToString());
            }
        }
        //技能释放返回错误
        if (obj.GetObjType() == OBJ.TYPE.MYPLAYER)
        {
            var ee = new SkillReleaseNetBack(skillId, false);
            EventDispatcher.Instance.DispatchEvent(ee);
        }
    }