public void Sell(Item pItem) { if (!ShopKeeper.playerIsInShop) { return; } if (_shopInventory == null) { _shopInventory = GameObject.Find("ShopInventory").GetComponent <ShopInventory>(); } if (_inventory.RemoveItem(pItem)) { if (!_shopInventory.AddItem(pItem)) { _inventory.AddItem(pItem); GameController.errorMessage.AddMessage("Shop is full!"); } else { _playerCoins.AddCoins(pItem.Value); pItem.IsInShop = true; GameController.errorMessage.AddMessage(pItem.Name + " has been sold!", Color.green); } } }
void CommitSale(Item item, int quantity) { float price = PriceChecker.AppraiseItem(item, "Sale") * quantity; if (shop.CheckSpaceAndGold(item, quantity, price)) { playerWallet.Deposit(price); Debug.Log("You have been credited $" + price); inv.SubtractQuantityFromItem(item, quantity); //create new item to go to shop Item soldItem = new Item(item); soldItem.quantity = quantity; shop.AddItem(soldItem); shopDialogue.SetCurrentMessage(LoadShop.MessageType.SUCCESS); } else { shopDialogue.SetCurrentMessage(LoadShop.MessageType.INVAL_QNTY); } }