Example #1
0
        private Skill InitializeSkill(DataTable table, UnitObjectStats.Stat.StatValue skillBlock)
        {
            DataRow[] availableSkillRows = table.Select("code = " + skillBlock.Param1);

            string name        = availableSkillRows[0]["displayName_string"].ToString();
            string description = availableSkillRows[0]["descriptionString_string"].ToString();
            string iconName    = (string)availableSkillRows[0]["smallIcon"];
            int    maxLevel    = (int)availableSkillRows[0]["maxLevel"];
            int    row         = (int)availableSkillRows[0]["skillPageRow"];
            int    column      = (int)availableSkillRows[0]["skillPageColumn"];

            List <int> requiredSkills         = new List <int>();
            List <int> levelsOfRequiredSkills = new List <int>();

            for (int counter = 1; counter < 5; counter++)
            {
                int requiredSkill = (int)availableSkillRows[0]["requiredSkills" + counter];
                if (requiredSkill >= 0)
                {
                    requiredSkills.Add(requiredSkill);
                }
                int requiredLevel = (int)availableSkillRows[0]["levelsOfrequiredSkills" + counter];
                if (requiredLevel >= 0)
                {
                    levelsOfRequiredSkills.Add(requiredLevel);
                }
            }
            return(new Skill(name, description, iconName, maxLevel, new Point(column, row), requiredSkills.ToArray(), levelsOfRequiredSkills.ToArray(), skillBlock));
        }
Example #2
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);
        }
Example #3
0
 public Skill(string name, string description, string iconName, int maxLevel, Point position, int[] requiredSkills, int[] levelsOfRequiredSkills, UnitObjectStats.Stat.StatValue skillBlock)
 {
     _name                   = name;
     _description            = description;
     _iconName               = iconName;
     _maxLevel               = maxLevel;
     _position               = position;
     _requiredSkills         = requiredSkills;
     _levelsOfRequiredSkills = levelsOfRequiredSkills;
     _skillBlock             = skillBlock;
 }
Example #4
0
        public static int GetSimpleValue(UnitObject unit, int valueId)
        {
            foreach (UnitObjectStats.Stat unitStats in unit.Stats.Stats.Values)
            {
                if (unitStats.Code != valueId)
                {
                    continue;
                }

                UnitObjectStats.Stat.StatValue entry = unitStats.Values[0];

                // if all atributes are 0 the value is most likely a simple value
                if (entry.Param1 == 0 && entry.Param2 == 0 && entry.Param3 == 0)
                {
                    return(entry.Value);
                }

                ExceptionLogger.LogException(new Exception("IsComplexAttributeException"), false, unitStats.Code + " is of type ComplexValue");
            }

            //for (int counter = 0; counter < unit.Stats.Stats.Count; counter++)
            //{
            //    UnitObjectStats.Stat unitStats = unit.Stats[counter];

            //    if (unitStats.Code == valueId)
            //    {
            //        UnitObjectStats.Stat.StatValue entry = unitStats.Values[0];

            //        // if all atributes are 0 the value is most likely a simple value
            //        if (entry.Param1 == 0 && entry.Param2 == 0 && entry.Param3 == 0)
            //        {
            //            return entry.Value;
            //        }

            //        ExceptionLogger.LogException(new Exception("IsComplexAttributeException"), "GetSimpleValue", unitStats.Code + " is of type ComplexValue", false);
            //    }
            //}
            //MessageBox.Show("Field \"" + valueName + "\" not present in unit " + unit.Name + "!");

            return(0);
        }
Example #5
0
        /// <summary>
        /// Adds a new simple value (entry that holds only one value) to the stats table
        /// </summary>
        /// <param name="unit">The unit to add this stat to</param>
        /// <param name="valueName">The name/id of the value to add</param>
        /// <param name="value">The actual value to add</param>
        /// <param name="bitCount">The bitCount of this value (possibly defines the maximum value of the "value" entry)</param>
        public static void AddSimpleValue(UnitObject unit, ItemValueNames valueName, int value, int bitCount)
        {
            List <UnitObjectStats.Stat> newStats = new List <UnitObjectStats.Stat>();

            //copies the existing values to a new array
            newStats.AddRange(unit.Stats.Stats.Values);

            //check if the value already exists
            if (newStats.Find(tmp => tmp.Code == (int)valueName) != null)
            {
                return;
            }

            //generates a new stat
            UnitObjectStats.Stat newStat = new UnitObjectStats.Stat();
            //generates the entry that holds the stat value
            UnitObjectStats.Stat.StatValue newValue = new UnitObjectStats.Stat.StatValue();
            //newStat.Values = new List<UnitObjectStats.Stat.StatValue>();
            //adds the entry to the new stat
            newStat.Values.Add(newValue);
            //sets the bitCOunt value (maximum stat value defined by the number of bits?)
            //newStat.BitCount = bitCount;
            //sets the length of the stat array (may be unnecessary)
            //newStat.Length = 1;
            //sets the Id of the new stat
            //newStat.Code = (short)valueName;
            //newStat.SkipResource = 1;
            //newStat.repeatCount = 1;

            //adds the new value to the array
            newStats.Add(newStat);

            //assigns the new array to the unit
            unit.Stats.Stats.TryAdd(newStat.Code, newStat);// = newStats.ToArray();
            //unit.Stats.statCount = newStats.Count;
        }
Example #6
0
 //public WayPointControl(UnitObjectStats.Stat.Values values) : this()
 public WayPointControl(UnitObjectStats.Stat.StatValue values) : this()
 {
     wayPointValues = values;
 }