Ejemplo n.º 1
0
        public static List <SkillListItemView.Item> GetItems(
            SkillStorage skillStorage,
            PlayerStateStorage playerStateStorage,
            SkillHelperStorage skillHelperStorage,
            Translator translator)
        {
            itemsBuffer.Clear();
            currentSkillsBuffer.Clear();
            BaseSkill[] baseSkills      = skillStorage.GetAllBase();
            PlayerState playerState     = playerStateStorage.Get();
            List <int>  currentSkillIds = playerState.SkillIds;

            for (int i = 0; i < currentSkillIds.Count; ++i)
            {
                Skill currentSkill = skillStorage.Get(currentSkillIds[i]);
                currentSkillsBuffer.Add(currentSkill.BaseId, currentSkill);
            }

            for (int i = 0; i < baseSkills.Length; ++i)
            {
                itemsBuffer.Add(GetItem(
                                    baseSkills[i],
                                    currentSkillsBuffer,
                                    playerState,
                                    skillStorage,
                                    skillHelperStorage,
                                    translator
                                    ));
            }

            return(itemsBuffer);
        }
Ejemplo n.º 2
0
        public void Learn(int skillId)
        {
            PlayerState playerState     = playerStateStorage.Get();
            List <int>  currentSkillIds = playerState.SkillIds;

            for (int i = 0; i < currentSkillIds.Count; ++i)
            {
                var currentSkillId = currentSkillIds[i];

                if (skillStorage.Get(skillId).BaseId !=
                    skillStorage.Get(currentSkillId).BaseId)
                {
                    continue;
                }

                playerState.RemoveSkill(currentSkillId);
                break;
            }

            playerState.AddSkill(skillId);
            --playerState.AvailableSkillPointsCount;
            playerStateStorage.Save(playerState);
        }