public void RemoveItem(UnitObject item) { UnitObject.Items.Remove(item); CharacterItems tmpItem = _items.Find(tmp => tmp.UnitObject == item); _items.Remove(tmpItem); }
public CharacterInventory(UnitObject unitObject, FileManager fileManager) : base(unitObject, fileManager) { _inventoryList = new List <CharacterInventoryType>(); foreach (UnitObject unit in unitObject.Items) { CharacterItems item = new CharacterItems(unit, fileManager); // get the matching inventory entry CharacterInventoryType inv = _inventoryList.Find(tmp => tmp.InventoryType == (int)item.InventoryType); if (inv == null) { inv = new CharacterInventoryType((int)item.InventoryType); _inventoryList.Add(inv); } inv.Items.Add(item); } }
public void RemoveItem(CharacterItems item) { UnitObject.Items.Remove(item.UnitObject); _items.Remove(item); }
public void AddItem(CharacterItems item) { _items.Add(item); UnitObject.Items.Add(item.UnitObject); }
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); } }
public CharacterInventory(UnitObject unitObject, FileManager fileManager) : base(unitObject, fileManager) { _inventoryList = new List<CharacterInventoryType>(); foreach (UnitObject unit in unitObject.Items) { CharacterItems item = new CharacterItems(unit, fileManager); // get the matching inventory entry CharacterInventoryType inv = _inventoryList.Find(tmp => tmp.InventoryType == (int)item.InventoryType); if (inv == null) { inv = new CharacterInventoryType((int)item.InventoryType); _inventoryList.Add(inv); } inv.Items.Add(item); } }
//, string baseItem) public InventoryItem(CharacterItems item) : base() { _item = item; this.BackgroundImageLayout = ImageLayout.Stretch; Position = _item.InventoryPosition; }
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); } }
public void AddItem2(CharacterItems item) { // get inventory type that the item uses TradeInventoryTypes type = TradeInventoryTypes.Inventory; if (item.InventoryType == InventoryTypes.Cube) { type = TradeInventoryTypes.Cube; } else if (item.InventoryType == InventoryTypes.Stash) { type = TradeInventoryTypes.Stash; } else if (item.InventoryType == InventoryTypes.Inventory) { type = TradeInventoryTypes.Inventory; } else { return; } AddOrRemoveItem2(type, item, false); }
//public UnitObject Item //{ // get { return _item; } // set { _item = value; } //} public ItemInfo(CharacterItems item) { itemWrapper = item; }
private void AddOrRemoveItem2(TradeInventoryTypes type, CharacterItems item, bool removeItem) { // get corresponding inventory bool[,] inventory = _charInventory[(int)type]; int x = item.InventoryPosition.X; int y = item.InventoryPosition.Y; int width = item.InventorySize.Width; int height = item.InventorySize.Height; if (width <= 0) { width = 1; } if (height <= 0) { height = 1; } AllocateInventorySpace(inventory, x, y, width, height, removeItem); }
private TreeNode CreateItemNode(CharacterItems item) { TreeNode node = new TreeNode(item.Name); node.Nodes.Add("Quest item: " + item.IsQuestItem); node.Nodes.Add("Consumable: " + item.IsConsumable); node.Nodes.Add("Affixes: " + item.NumberOfAffixes + "/" + item.MaxNumberOfAffixes); node.Nodes.Add("Augmentations: " + item.NumberOfAugmentations + "/" + item.MaxNumberOfAugmentations); node.Nodes.Add("Upgrades: " + item.NumberOfUpgrades + "/" + item.MaxNumberOfUpgrades); node.Nodes.Add("Quality: " + item.Quality); node.Nodes.Add("Quality Color: " + item.QualityColor.R + "," + item.QualityColor.G + "," + item.QualityColor.B); node.Nodes.Add("Stack size: " + item.StackSize + "/" + item.MaxStackSize); node.Nodes.Add("Has mods: " + item.WrappedItems.Count); TreeNode inventory = new TreeNode("Inventory"); inventory.Nodes.Add("Type: " + item.InventoryType); inventory.Nodes.Add("Position: " + item.InventoryPosition.X + "," + item.InventoryPosition.Y); inventory.Nodes.Add("Size: " + item.InventorySize.Width + "," + item.InventorySize.Height); node.Nodes.Add(inventory); return node; }