少年修仙传客户端代码仓库
System/Skill/TreasureSkillModel.cs
@@ -11,6 +11,7 @@
        Dictionary<int, TreasureSkill> treasureSkills = new Dictionary<int, TreasureSkill>();
        Dictionary<int, List<int>> jobTreasureSkills = new Dictionary<int, List<int>>();
        Dictionary<int, int> m_ExpertSkills = new Dictionary<int, int>();
        Dictionary<int, int> m_ExpertActiveLevels = new Dictionary<int, int>();
        public List<int> skillLevelUpItems = new List<int>();
@@ -46,6 +47,7 @@
        public event Action<int> skillLevelUpRefresh;
        public event Action<int, int> potentialLevelRefresh;
        public event Action expertSkillRefresh;
        public event Action<int> expertActiveRefresh;
        public override void Init()
        {
            ParseConfig();
@@ -62,6 +64,7 @@
                skill.Reset();
            }
            m_ExpertSkills.Clear();
            m_ExpertActiveLevels.Clear();
            serverInited = false;
        }
@@ -81,7 +84,16 @@
        private void PlayerDataRefreshEvent(PlayerDataType dataType)
        {
            if (dataType == PlayerDataType.LV)
            if (!serverInited)
            {
                return;
            }
            if (dataType == PlayerDataType.LV
                || dataType == PlayerDataType.CDBPlayerRefresh_Mater
                || dataType == PlayerDataType.CDBPlayerRefresh_Wood
                || dataType == PlayerDataType.CDBPlayerRefresh_Water
                || dataType == PlayerDataType.CDBPlayerRefresh_Fire
                || dataType == PlayerDataType.CDBPlayerRefresh_Earth)
            {
                UpdateRedpoint();
            }
@@ -110,17 +122,15 @@
        void ParseConfig()
        {
            var configs = TreasureSkillConfig.GetValues();
            var index = 0;
            foreach (var config in configs)
            {
                TreasureSkill treasureSkill;
                if (!treasureSkills.TryGetValue(config.limitSkillId, out treasureSkill))
                {
                    treasureSkill = new TreasureSkill(config.limitSkillId, index);
                    treasureSkill = new TreasureSkill(config.limitSkillId);
                    treasureSkills.Add(config.limitSkillId, treasureSkill);
                    index++;
                }
                treasureSkill.potentials.Add(new TreasurePotential(config.id, 0, config.limitLevel, treasureSkill.redpoint.id));
                treasureSkill.potentials.Add(new TreasurePotential(config.id, 0, config.limitLevel, treasureSkill.expertRedpoint.id));
                var skillConfig = SkillConfig.Get(config.limitSkillId);
                List<int> skills;
@@ -172,9 +182,9 @@
            return treasureSkills.TryGetValue(skillId, out treasureSkill);
        }
        public bool TryGetExpertSkill(int skillId,out int _skill)
        public bool TryGetExpertSkill(int skillId, out int _skill)
        {
            return m_ExpertSkills.TryGetValue(skillId, out _skill);
            return m_ExpertSkills.TryGetValue(skillId, out _skill) && _skill != 0;
        }
        public bool TryGetPotential(int skillId, out TreasurePotential potential)
@@ -191,6 +201,11 @@
                return potential != null;
            }
            return false;
        }
        public bool TryGetExpertActiveLevel(int skillId, out int level)
        {
            return m_ExpertActiveLevels.TryGetValue(skillId, out level);
        }
        public void OnReceivePackage(int oldSkillID, int newSkillID)
@@ -260,6 +275,18 @@
            {
                var data = package.InfoList[i];
                m_ExpertSkills[(int)data.MainSkillID] = (int)data.ElementSkillID;
                for (int j = 0; j < data.SkillCnt; j++)
                {
                    m_ExpertActiveLevels[(int)data.ActiveSkill[j].SkillID] = data.ActiveSkill[j].ActiveLV;
                    if (serverInited)
                    {
                        if (expertActiveRefresh != null)
                        {
                            expertActiveRefresh((int)data.ActiveSkill[j].SkillID);
                        }
                    }
                }
            }
            if (expertSkillRefresh != null)
            {
@@ -309,39 +336,6 @@
            return true;
        }
        public bool TryLevelUpPotential(int skillId, out int error)
        {
            error = 0;
            TreasurePotential potential;
            if (TryGetPotential(skillId, out potential))
            {
                if (potential.level >= potential.maxLevel)
                {
                    error = 11;
                    return false;
                }
                var config = potential.GetSkillConfig(potential.level);
                if (config.LearnSkillReq != 0 && config.LearnSkillLV > 0)
                {
                    TreasurePotential requirePotential;
                    if (!TryGetPotential(config.LearnSkillReq, out requirePotential)
                        || requirePotential.level < config.LearnSkillLV)
                    {
                        error = 12;
                        return false;
                    }
                }
                var upConfig = potential.GetSkillConfig(potential.level + 1);
                var count = packModel.GetItemCountByID(PackType.Item, upConfig.ExAttr4);
                if (count < upConfig.ExAttr5)
                {
                    error = 13;
                    return false;
                }
            }
            return true;
        }
        public void DisplayLevelUpError(int error)
        {
            switch (error)
@@ -382,20 +376,41 @@
            return false;
        }
        public bool ExistAnyUnlockPotential(int skillId)
        public bool ExistAnyActiveExpert(int skillId)
        {
            TreasureSkill treasureSkill;
            if (TryGetSkill(skillId, out treasureSkill))
            {
                for (int i = 0; i < treasureSkill.potentials.Count; i++)
                {
                    if (PlayerDatas.Instance.baseData.LV >= treasureSkill.potentials[i].limitLevel)
                    var level = 0;
                    if (TryGetExpertActiveLevel(treasureSkill.potentials[i].id, out level)
                        && level > 0)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        public bool SatisfyActiveExpert(int skillId)
        {
            TreasurePotential expert;
            if (!TryGetPotential(skillId, out expert))
            {
                return false;
            }
            if (PlayerDatas.Instance.baseData.LV < expert.limitLevel)
            {
                return false;
            }
            var level = 0;
            TryGetExpertActiveLevel(skillId, out level);
            var skillConfig = SkillConfig.Get(skillId + level);
            var requireProperty = skillConfig.RequireProperty();
            var requireValue = skillConfig.RequirePropertyValue();
            return UIHelper.GetPropertyValue((PropertyType)requireProperty) >= requireValue;
        }
        public void SetAlreadyRemind()
@@ -422,15 +437,26 @@
                }
                var expertSkill = 0;
                if (funcOpen && skill.level > 0
                    && !TryGetExpertSkill(skill.skillId, out expertSkill)
                    && ExistAnyUnlockPotential(skill.skillId))
                if (funcOpen && !TryGetExpertSkill(skill.skillId, out expertSkill)
                    && ExistAnyActiveExpert(skill.skillId))
                {
                    skill.expertRedpoint.state = RedPointState.Simple;
                    skill.expertSelectRedpoint.state = RedPointState.Simple;
                }
                else
                {
                    skill.expertRedpoint.state = RedPointState.None;
                    skill.expertSelectRedpoint.state = RedPointState.None;
                }
                foreach (var expert in skill.potentials)
                {
                    if (funcOpen && skill.level > 0 && SatisfyActiveExpert(expert.id))
                    {
                        expert.activeRedpoint.state = RedPointState.Simple;
                    }
                    else
                    {
                        expert.activeRedpoint.state = RedPointState.None;
                    }
                }
            }
        }
@@ -445,9 +471,10 @@
        public Redpoint redpoint { get; private set; }
        public Redpoint levelUpRedpoint { get; private set; }
        public Redpoint expertRedpoint { get; private set; }
        public Redpoint expertSelectRedpoint { get; private set; }
        public List<TreasurePotential> potentials { get; private set; }
        public TreasureSkill(int skillId, int redpointIndex)
        public TreasureSkill(int skillId)
        {
            this.skillId = skillId;
            potentials = new List<TreasurePotential>();
@@ -456,10 +483,12 @@
            maxLevel = config.SkillMaxLV;
            redpoint = new Redpoint(10304,
                TreasureSkillModel.REDPOINTID_BASE + redpointIndex);
                TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);
            levelUpRedpoint = new Redpoint(redpoint.id,
                TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);
            expertRedpoint = new Redpoint(redpoint.id,
                TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);
            expertSelectRedpoint = new Redpoint(expertRedpoint.id,
                TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);
        }
@@ -510,9 +539,10 @@
        public readonly int id;
        public readonly int maxLevel;
        public readonly int limitLevel;
        public readonly Redpoint activeRedpoint;
        public int level { get; private set; }
        public TreasurePotential(int id, int level,int limitLevel, int redpointBase)
        public TreasurePotential(int id, int level, int limitLevel, int redpointBase)
        {
            this.id = id;
            this.level = level;
@@ -520,6 +550,9 @@
            var config = SkillConfig.Get(id);
            maxLevel = config.SkillMaxLV;
            activeRedpoint = new Redpoint(redpointBase,
                TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);
        }
        public SkillConfig GetSkillConfig(int level)