//Sell items from kanp public void SellItem() { float price = clickItem.it.sellPrice * clickItem.count; int value = int.Parse(coinLabel.text); coinLabel.text = (value + price).ToString(); //clear grid and info clickItem.count = 0; clickItem.Clear(); desLabel.text = ""; clickItem = null; }
//Remove item from knap public void RemoveItem(InventoryGrid ig, int num) { ig.count -= num; if (ig.count <= 0) { ig.Clear(); } else if (ig.count == 1) { ig.countLabel.text = ""; } else { ig.countLabel.text = ig.count.ToString(); } }
public void LoadFromDB() { //load everything and make a switch on slot_id Item item = null; int goldAmount = _owner.Toon.GameAccount.DBGameAccount.Gold; // Clear already present items // LoadFromDB is called every time World is changed, even entering a dungeon _stashGrid.Clear(); _inventoryGrid.Clear(); // first of all load stash size var slots = this._owner.Toon.GameAccount.DBGameAccount.StashSize; if (slots > 0) { _owner.Attributes[GameAttribute.Shared_Stash_Slots] = slots; _owner.Attributes.BroadcastChangedIfRevealed(); // To be applied before loading items, to have all the space needed _stashGrid.ResizeGrid(_owner.Attributes[GameAttribute.Shared_Stash_Slots] / 7, 7); } // next load all stash items var stashInventoryItems = _dbInventories.Where( dbi => dbi.DBGameAccount.Id == _owner.Toon.GameAccount.PersistentID && dbi.DBToon == null && dbi.DBItemInstance != null).ToList(); foreach (var inv in stashInventoryItems) { var slot = inv.EquipmentSlot; if (slot == (int)EquipmentSlotId.Stash) { // load stash item = ItemGenerator.LoadFromDBInstance(_owner, inv.DBItemInstance); item.DBInventory = inv; item.DBItemInstance = inv.DBItemInstance; this._stashGrid.AddItem(item, inv.LocationY, inv.LocationX); } } // next read all items var allInventoryItems = _dbInventories.Where( dbi => dbi.DBToon != null && dbi.DBToon.Id == _owner.Toon.PersistentID && dbi.DBItemInstance != null).ToList(); foreach (var inv in allInventoryItems) { var slot = inv.EquipmentSlot; if (slot >= (int)EquipmentSlotId.Inventory && slot <= (int)EquipmentSlotId.Neck) { item = ItemGenerator.LoadFromDBInstance(_owner, inv.DBItemInstance); item.DBInventory = inv; item.DBItemInstance = inv.DBItemInstance; if (slot == (int)EquipmentSlotId.Inventory) { this._inventoryGrid.AddItem(item, inv.LocationY, inv.LocationX); } else { _equipment.EquipItem(item, (int)slot); } } } this._inventoryGold = ItemGenerator.CreateGold(this._owner, goldAmount); this._inventoryGold.Attributes[GameAttribute.ItemStackQuantityLo] = goldAmount; // This is the attribute that makes the gold visible in game this._inventoryGold.Owner = _owner; this._inventoryGold.SetInventoryLocation((int)EquipmentSlotId.Gold, 0, 0); this.Loaded = true; }