private void OnEnable()
        {
            baseSkillsList = new BaseSkill[items.Length];

            for (int i = 0; i < items.Length; ++i)
            {
                Item      item      = items[i];
                BaseSkill baseSkill = item.BaseSkill;
                baseSkillsMap.Add(baseSkill.Id, item);
                baseSkillsList[i] = baseSkill;
                Skill[] derivedSkills = item.Skills;
                Array.Sort(derivedSkills, SkillComparer);

                for (int j = 0; j < derivedSkills.Length; ++j)
                {
                    Skill skill = derivedSkills[j];
                    DebugUtils.Assert(skill.BaseId == baseSkill.Id);
                    skillsMap.Add(skill.Id, skill);
                }
            }

            Array.Sort(baseSkillsList, BaseSkillComparer);
        }
Exemple #2
0
        private static SkillListItemView.Item GetItem(
            BaseSkill baseSkill,
            IDictionary <int, Skill> currentSkills,
            PlayerState playerState,
            SkillStorage skillStorage,
            SkillHelperStorage skillHelperStorage,
            Translator translator)
        {
            ISkillHelper skillHelper =
                skillHelperStorage.Get(baseSkill.Type);
            Skill currentSkill            = null;
            var   currentSkillLevel       = -1;
            var   currentSkillDescription = "";
            Skill nextSkill = null;

            if (currentSkillsBuffer.TryGetValue(
                    baseSkill.Id, out currentSkill))
            {
                currentSkillLevel       = currentSkill.Level;
                currentSkillDescription = translator.Translate(
                    "Skill.CurrentLevelDescription",
                    skillHelper.GetSkillDescription(
                        currentSkill,
                        translator.Translate(baseSkill.Description)
                        )
                    );
                nextSkill =
                    skillStorage.GetNextLevel(currentSkill.Id);
            }
            else
            {
                nextSkill = skillStorage.GetFirstLevel(baseSkill.Id);
            }

            int    nextSkillId          = -1;
            string nextSkillDescription = "";

            if (nextSkill != null)
            {
                nextSkillId          = nextSkill.Id;
                nextSkillDescription = translator.Translate(
                    "Skill.NextLevelDescription",
                    skillHelper.GetSkillDescription(
                        nextSkill,
                        translator.Translate(baseSkill.Description)
                        )
                    );
            }

            int maxSkillLevel =
                skillStorage.GetMaxLevel(baseSkill.Id).Level + 1;
            string currentSkillLevelText = translator.Translate(
                "Skill.CurrentLevel",
                currentSkillLevel + 1,
                maxSkillLevel);
            bool isSkillDisabled =
                playerState.AvailableSkillPointsCount <= 0;

            return(new SkillListItemView.Item {
                Img = baseSkill.Img,
                Name = translator.Translate(baseSkill.Name),
                CurrentLevel = currentSkillLevelText,
                CurrentLevelDescription = currentSkillDescription,
                NextLevelId = nextSkillId,
                NextLevelDescription = nextSkillDescription,
                IsDisabled = isSkillDisabled,
                Learn = translator.Translate("Skill.Learn")
            });
        }
 private int BaseSkillComparer(BaseSkill lhs, BaseSkill rhs)
 {
     return(lhs.Order.CompareTo(rhs.Order));
 }