Example #1
0
        private void ParseCharacter(UnitObject unitObject)
        {
            UnitHelpFunctions unitHelp = new UnitHelpFunctions(fileManager);

            unitHelp.LoadCharacterValues(baseCharacter.Character);

            characterWrapper = new CharacterWrapper(baseCharacter.Character, fileManager);
        }
Example #2
0
        public ItemInfo(UnitObject item)
        {
            _item = item;

            int width  = UnitHelpFunctions.GetSimpleValue(item, ItemValueNames.inventory_width.ToString());
            int height = UnitHelpFunctions.GetSimpleValue(item, ItemValueNames.inventory_height.ToString());

            _itemSize.Width  = width;
            _itemSize.Height = height;
        }
Example #3
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);
        }
Example #4
0
        private void b_addAffix_Click(object sender, EventArgs e)
        {
            if (_characterUnit == null || _selectedItem == null)
            {
                return;
            }

            UnitObjectStats.Stat value = UnitHelpFunctions.GetComplexValue(_selectedItem.Item.UnitObject, ItemValueNames.applied_affix.ToString());
            if (value != null)
            {
                MessageBox.Show(value.ToString());
            }
        }
Example #5
0
        public List <UnitObject> GetItemsOfQuality(ItemQuality quality)
        {
            List <UnitObject> tmp = new List <UnitObject>();

            foreach (UnitObject item in UnitObject.Items)
            {
                if (UnitHelpFunctions.GetSimpleValue(UnitObject, (int)ItemValueNames.item_quality) == (int)quality)
                {
                    tmp.Add(item);
                }
            }
            return(tmp);
        }
Example #6
0
        private void b_save_Click(object sender, EventArgs e)
        {
            if (_characterUnit != null)
            {
                if (MessageBox.Show("Are you sure you want to save these changes?", "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    UnitHelpFunctions.SaveCharacterFile(_characterUnit, _characterPath);

                    MessageBox.Show("Saving successful!");
                }

                SetCharacterStatus(CharacterStatus, CharacterStatus.Saved, p_status, l_status);
            }
        }
Example #7
0
        private void AddOrRemoveItem(TradeInventoryTypes type, UnitObject item, bool removeItem)
        {
            // get corresponding inventory
            bool[,] inventory = _charInventory[(int)type];

            int x = item.InventoryPositionX;
            int y = item.InventoryPositionY;

            int width  = UnitHelpFunctions.GetSimpleValue(item, ItemValueNames.inventory_width.ToString());
            int height = UnitHelpFunctions.GetSimpleValue(item, ItemValueNames.inventory_height.ToString());

            if (width <= 0)
            {
                width = 1;
            }
            if (height <= 0)
            {
                height = 1;
            }

            AllocateInventorySpace(inventory, x, y, width, height, removeItem);
        }
Example #8
0
        private void b_loadCharacter_Click(object sender, EventArgs e)
        {
            _characterPath = _characterFolder + @"\" + cb_selectCharacter.SelectedItem + ".hg1";

            //_characterUnit = UnitHelpFunctions.OpenCharacterFile(_tableFiles, _characterPath);

            if (_characterUnit != null)
            {
                _itemHelpFunctions.LoadCharacterValues(_characterUnit);

                gb_characterName.Text = cb_selectCharacter.SelectedItem.ToString();
                int level = UnitHelpFunctions.GetSimpleValue(_characterUnit, ItemValueNames.level.ToString()) - 8;
                gb_characterName.Text += " (Level " + level.ToString() + ")";

                SetCharacterStatus(CharacterStatus, CharacterStatus.Loaded, p_status, l_status);

                InitInventory(_characterUnit, _characterItemPanel);
            }
            else
            {
                MessageBox.Show("Error while parsing the character file!", "b_loadCharacter_Click");
            }
        }
Example #9
0
        private void b_save_Click(object sender, EventArgs e)
        {
            if (_backupCharacters)
            {
                CreateBackup(_characterPath1);
                CreateBackup(_characterPath2);
            }
            if (_characterUnit1 != null && _characterUnit2 != null)
            {
                if (MessageBox.Show("Are you sure you want to save these changes?", "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
//XmlUtilities<Unit>.Serialize(_characterUnit2.HeroUnit, @"F:\after.xml");
                    UnitHelpFunctions.SaveCharacterFile(_characterUnit1.BaseCharacter.Character, _characterPath1);
                    UnitHelpFunctions.SaveCharacterFile(_characterUnit2.BaseCharacter.Character, _characterPath2);

                    MessageBox.Show("Saving successful!");
                }

                EnableComboBoxes(true, true);
                SetCharacterStatus(_characterStatus1, CharacterStatus.Saved, p_status1, l_status1);
                SetCharacterStatus(_characterStatus2, CharacterStatus.Saved, p_status2, l_status2);
            }
        }
Example #10
0
        private void ParseCharacter(UnitObject unitObject)
        {
            UnitHelpFunctions unitHelp = new UnitHelpFunctions(fileManager);
            unitHelp.LoadCharacterValues(baseCharacter.Character);

            characterWrapper = new CharacterWrapper(baseCharacter.Character, fileManager);
        }
Example #11
0
        public CharacterItems(UnitObject unitObject, FileManager fileManager)
            : base(unitObject, fileManager)
        {
            _itemTable = fileManager.GetDataTable("ITEMS");
            DataRow[] itemRow = _itemTable.Select("code = " + unitObject.UnitCode);

            //DataTable colorTable = _dataSet.GetExcelTableFromStringId("ITEMQUALITY");
            //DataRow[] colorRow = colorTable.Select("code = " + _hero.unitCode);

            if (itemRow.Length > 0)
            {
                _isItem = true;

                uint bitMask = (uint)itemRow[0]["bitmask02"];
                _isQuestItem = (bitMask >> 13 & 1) == 1;

                string   maxStackSize = (string)itemRow[0]["stackSize"];
                string[] splitResult  = maxStackSize.Split(new char[] { ',' });
                if (splitResult.Length == 3)
                {
                    _maxStackSize = int.Parse(splitResult[1]);
                }
                if (_maxStackSize <= 0)
                {
                    _maxStackSize = 1;
                }

                _stackSize = UnitHelpFunctions.GetSimpleValue(unitObject, ItemValueNames.item_quantity.ToString());
                if (_stackSize <= 0)
                {
                    _stackSize = 1;
                }

                _itemImagePath = CreateImagePath();

                _numberOfAugmentations = UnitHelpFunctions.GetSimpleValue(unitObject, ItemValueNames.item_augmented_count.ToString());
                _numberOfUpgrades      = UnitHelpFunctions.GetSimpleValue(unitObject, ItemValueNames.item_upgraded_count.ToString());

                DataTable gameGlobals = fileManager.GetDataTable("GAME_GLOBALS");
                //DataRow[] globalsRow = gameGlobals.Select("name = " + "max_item_upgrades");
                DataRow[] globalsRow = gameGlobals.Select("Index = " + 16);
                _maxNumberOfUpgrades = (int)globalsRow[0]["intValue"];

                //globalsRow = gameGlobals.Select("name = " + "max_item_augmentations");
                globalsRow          = gameGlobals.Select("Index = " + 17);
                _maxNumberOfAffixes = (int)globalsRow[0]["intValue"];
                UnitObjectStats.Stat affixes = UnitHelpFunctions.GetComplexValue(unitObject, ItemValueNames.applied_affix.ToString());
                if (affixes != null)
                {
                    _numberOfAffixes = affixes.Values.Count;
                }

                int numberOfInherentAffixes = _numberOfAffixes - _numberOfAugmentations;
                _numberOfAugmentationsLeft = _maxNumberOfAffixes - numberOfInherentAffixes;

                if (_numberOfAugmentationsLeft < 0)
                {
                    _numberOfAugmentationsLeft = 0;
                }

                _maxNumberOfAugmentations = _numberOfAugmentations + _numberOfAugmentationsLeft;
                if (_maxNumberOfAugmentations > _maxNumberOfAffixes)
                {
                    _maxNumberOfAugmentations = _maxNumberOfAffixes;
                }
            }

            _items = new List <CharacterItems>();

            foreach (UnitObject item in unitObject.Items)
            {
                CharacterItems wrapper = new CharacterItems(item, fileManager);
                _items.Add(wrapper);
            }
        }