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; }
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); }
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); }
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"); } }
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); } }