Example #1
0
        public void UpdateSkillTalentByProtocol(List <TalentProto> talents, List <int> selected)
        {
            normalPassiveSkilIdDic.Clear();
            PlayerSkillTalentData data;

            for (int i = 0, count = talents.Count; i < count; i++)
            {
                TalentProto proto = talents[i];
                data = PlayerSkillTalentData.GetSkillTalentDataByID(proto.no);
                if (proto.lv >= 1 && data.groupType == Logic.Enums.PlayerSkillTalentType.PassiveNormal)
                {
                    normalPassiveSkilIdDic[data.effect] = proto.lv;
                }
                if (selected.Contains(proto.no))
                {
                    if (data.groupType == PlayerSkillTalentType.PassiveThreeChoiceOne)
                    {
                        this.passiveSkillId    = data.effect;
                        this.passiveSkillLevel = proto.lv;
                    }
                    else if (data.groupType == PlayerSkillTalentType.SummonThreeChoiceOne)
                    {
                        this.summonEffectId   = data.effect;
                        this.summonSkillLevel = proto.lv;
                    }
                }
            }
        }
        public void UpdateSkillTalentByLuaTable()
        {
            LuaTable playerModel     = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "player_model")[0];
            LuaTable talentInfoTable = (LuaTable)playerModel["playerSkillTalentInfoTable"];

            foreach (DictionaryEntry kvp in talentInfoTable.ToDictTable())
            {
                LuaTable talent        = (LuaTable)kvp.Value;
                int      playerModelId = kvp.Key.ToString().ToInt32();

                List <TalentProto> talents    = new List <TalentProto>();
                List <int>         selectList = new List <int>();

                foreach (DictionaryEntry kvp2 in talent.ToDictTable())
                {
                    LuaTable talentInfo = (LuaTable)kvp2.Value;
                    int      no         = talentInfo["id"].ToString().ToInt32();
                    int      lv         = talentInfo["level"].ToString().ToInt32();
                    int      exp        = talentInfo["exp"].ToString().ToInt32();
                    bool     isCarry    = talentInfo["isCarry"].ToString().ToBoolean();
                    if (isCarry)
                    {
                        selectList.Add(no);
                    }
                    TalentProto proto = new TalentProto();
                    proto.no  = no;
                    proto.lv  = lv;
                    proto.exp = exp;
                    talents.Add(proto);
                    UpdateSkillTalent(playerModelId, talents, selectList);
                }
            }
        }
        public void UpdateSkillTalent(int playerModelId, List <TalentProto> talents, List <int> selectList)
        {
            if (!SkillTalentDictionary.ContainsKey(playerModelId))
            {
                return;
            }
            Dictionary <int, PlayerSkillTalentInfo> infoDic = SkillTalentDictionary[playerModelId];

            //天赋
            if (talents != null)
            {
                for (int i = 0, count = talents.Count; i < count; i++)
                {
                    TalentProto proto = talents[i];
                    if (infoDic.ContainsKey(proto.no))
                    {
                        infoDic[proto.no].Set(proto.lv, proto.exp);
                    }
                }
            }
            //携带的天赋
            if (selectList != null)
            {
                if (selectList.Count > 0)
                {
                    foreach (var data in infoDic)
                    {
                        data.Value.IsCarry = false;
                    }
                }

                for (int i = 0, count2 = selectList.Count; i < count2; i++)
                {
                    int id = selectList[i];

                    if (infoDic.ContainsKey(id))
                    {
                        infoDic[id].IsCarry = true;
                    }
                }
            }
            //update Player
            PlayerInfo player = PlayerProxy.instance.GetPlayerInfoByModelId(playerModelId);

            if (player != null)
            {
                Dictionary <int, int> activeNormalTalentDic = new Dictionary <int, int>();
                int passiveId    = 0;
                int passiveLevel = 0;
                int summonId     = 0;
                int summonLevel  = 0;
                PlayerSkillTalentInfo info;
                foreach (var data in infoDic)
                {
                    info = data.Value;
                    if (info.level >= 1 && info.talentData.groupType == PlayerSkillTalentType.PassiveNormal)
                    {
                        activeNormalTalentDic[info.talentData.effect] = info.level;
                    }
                    if (info.talentData.groupType == PlayerSkillTalentType.PassiveThreeChoiceOne && info.IsCarry)
                    {
                        passiveId    = info.talentData.effect;
                        passiveLevel = info.level;
                    }
                    else if (info.talentData.groupType == PlayerSkillTalentType.SummonThreeChoiceOne && info.IsCarry)
                    {
                        summonId    = info.talentData.effect;
                        summonLevel = info.level;
                    }
                }
                player.UpdateSelectSkillTalent(passiveId, passiveLevel, summonId, summonLevel);
                player.UpdateNormalActiveSkillTalent(activeNormalTalentDic);
            }
        }