Exemplo n.º 1
0
        private SkillTab CreateSkillsFromRow(List <UnitObjectStats.Stat.StatValue> availableSkills, DataTable skillTable, DataRow[] skillRows)
        {
            List <UnitObjectStats.Stat.StatValue> values = new List <UnitObjectStats.Stat.StatValue>();
            SkillTab skillInSkillTab = new SkillTab();

            //iterate through all available skills
            foreach (DataRow row in skillRows)
            {
                //get the skill id
                int skillId = (int)row["code"];
                //if the skill is already present, use that one
                UnitObjectStats.Stat.StatValue tmpSkill = availableSkills.Find(tmp => tmp.Param1 == skillId);
                if (tmpSkill != null)
                {
                    values.Add(tmpSkill);
                }
                //if not, add a new one
                else
                {
                    UnitObjectStats.Stat.StatValue skillEntry = new UnitObjectStats.Stat.StatValue();
                    skillEntry.Param1 = skillId;

                    values.Add(skillEntry);
                }
            }
            //_hero.Stats.statCount

            //and finally... initialize all skills :)
            foreach (UnitObjectStats.Stat.StatValue skillBlock in values)
            {
                Skill skill = InitializeSkill(skillTable, skillBlock);
                skillInSkillTab.Skills.Add(skill);
            }
            return(skillInSkillTab);
        }
Exemplo n.º 2
0
        public CharacterSkills(UnitObject unitObject, FileManager fileManager, IEnumerable <int> skillTabs) : base(unitObject, fileManager)
        {
            _skillTabs = new List <SkillTab>();

            //to make things easier, let's add all available character skills to the list
            List <UnitObjectStats.Stat.StatValue> availableSkills = new List <UnitObjectStats.Stat.StatValue>();

            ////get the skills the character already knows
            UnitObjectStats.Stat skills = UnitHelpFunctions.GetComplexValue(unitObject, ItemValueNames.skill_level);
            ////add them to the complete skill list
            availableSkills.AddRange(skills.Values);

            DataTable skillTable = fileManager.GetDataTable("SKILLS");

            //let's add all the skills the character doesn't know yet
            foreach (int skillTab in skillTabs)
            {
                DataRow[] skillRows = skillTable.Select("skillTab = " + skillTab);

                SkillTab skillsInSkillTab = CreateSkillsFromRow(availableSkills, skillTable, skillRows);

                if (skillsInSkillTab.Skills.Count > 0)
                {
                    _skillTabs.Add(skillsInSkillTab);
                }
            }


            // select the general skill tab
            DataRow[] generalSkillRows = skillTable.Select("skillTab = " + 0);
            _generalSkills = CreateSkillsFromRow(availableSkills, skillTable, generalSkillRows);

            //add all skills back to the savegame
            availableSkills.Clear();

            foreach (Skill skill in _generalSkills.Skills)
            {
                availableSkills.Add(skill.SkillBlock);
            }

            foreach (SkillTab skillTab in _skillTabs)
            {
                foreach (Skill skill in skillTab.Skills)
                {
                    availableSkills.Add(skill.SkillBlock);
                }
            }

            //skills.repeatCount = availableSkills.Count;

            //skills.Values = availableSkills;
            skills.Values.Clear();
            skills.Values.AddRange(availableSkills);
        }
Exemplo n.º 3
0
        private Panel CreateSkillTab(SkillTab skillTab, AtlasImageLoader loader)
        {
            Panel panel = new Panel();
            Point distanceToNeighbor = new Point(140, 140);
            //panel.AutoScroll = true;
            //panel.BackColor = Color.Red;

            foreach (Skill skill in skillTab.Skills)
            {
                SingleSkillControl control = new SingleSkillControl(skill, loader, distanceToNeighbor);
                panel.Controls.Add(control);
            }

            panel.Size = new Size(distanceToNeighbor.X * 8 + 102, distanceToNeighbor.Y * 6 + 96);

            return panel;
        }
Exemplo n.º 4
0
        private SkillTab CreateSkillsFromRow(List<UnitObjectStats.Stat.StatValue> availableSkills, DataTable skillTable, DataRow[] skillRows)
        {
            List<UnitObjectStats.Stat.StatValue> values = new List<UnitObjectStats.Stat.StatValue>();
            SkillTab skillInSkillTab = new SkillTab();

            //iterate through all available skills
            foreach (DataRow row in skillRows)
            {
                //get the skill id
                int skillId = (int)row["code"];
                //if the skill is already present, use that one
                UnitObjectStats.Stat.StatValue tmpSkill = availableSkills.Find(tmp => tmp.Param1 == skillId);
                if (tmpSkill != null)
                {
                    values.Add(tmpSkill);
                }
                //if not, add a new one
                else
                {
                    UnitObjectStats.Stat.StatValue skillEntry = new UnitObjectStats.Stat.StatValue();
                    skillEntry.Param1 = skillId;

                    values.Add(skillEntry);
                }
            }
            //_hero.Stats.statCount

            //and finally... initialize all skills :)
            foreach (UnitObjectStats.Stat.StatValue skillBlock in values)
            {
                Skill skill = InitializeSkill(skillTable, skillBlock);
                skillInSkillTab.Skills.Add(skill);
            }
            return skillInSkillTab;
        }
Exemplo n.º 5
0
        public CharacterSkills(UnitObject unitObject, FileManager fileManager, IEnumerable<int> skillTabs)
            : base(unitObject, fileManager)
        {
            _skillTabs = new List<SkillTab>();

            //to make things easier, let's add all available character skills to the list
            List<UnitObjectStats.Stat.StatValue> availableSkills = new List<UnitObjectStats.Stat.StatValue>();
            ////get the skills the character already knows
            UnitObjectStats.Stat skills = UnitHelpFunctions.GetComplexValue(unitObject, ItemValueNames.skill_level);
            ////add them to the complete skill list
            availableSkills.AddRange(skills.Values);

            DataTable skillTable = fileManager.GetDataTable("SKILLS");

            //let's add all the skills the character doesn't know yet
            foreach (int skillTab in skillTabs)
            {
                DataRow[] skillRows = skillTable.Select("skillTab = " + skillTab);

                SkillTab skillsInSkillTab = CreateSkillsFromRow(availableSkills, skillTable, skillRows);

                if (skillsInSkillTab.Skills.Count > 0)
                {
                    _skillTabs.Add(skillsInSkillTab);
                }
            }

            // select the general skill tab
            DataRow[] generalSkillRows = skillTable.Select("skillTab = " + 0);
            _generalSkills = CreateSkillsFromRow(availableSkills, skillTable, generalSkillRows);

            //add all skills back to the savegame
            availableSkills.Clear();

            foreach (Skill skill in _generalSkills.Skills)
            {
                availableSkills.Add(skill.SkillBlock);
            }

            foreach (SkillTab skillTab in _skillTabs)
            {
                foreach (Skill skill in skillTab.Skills)
                {
                    availableSkills.Add(skill.SkillBlock);
                }
            }

            //skills.repeatCount = availableSkills.Count;

            //skills.Values = availableSkills;
            skills.Values.Clear();
            skills.Values.AddRange(availableSkills);
        }