示例#1
0
        private void OnRebuySellItem(ShopItemSlot itemSlot)
        {
            // ReSharper disable once PossibleLossOfFraction
            float g = itemSlot.ShopItem.item.BuyPrice * itemSlot.ShopItem.Amount * 30 / 100;

            if (g < 1)
            {
                g = 1;
            }
            if (CurrencyManager.Instance.CanPurchasing((int)g))
            {
                if (!InventoryManager.Instance.inventory.IsFull())
                {
                    InventoryManager.Instance.inventory.AddItem
                    (
                        itemSlot.ShopItem.item.GetCopy(),
                        itemSlot.ShopItem.Amount,
                        itemSlot.ShopItem.Amount
                    );

                    CurrencyManager.Instance.AddGold((int)-g);
                    if (itemSlot.ShopItem.Amount > 0)
                    {
                        return;
                    }
                    Destroy(itemSlot.gameObject);
                }
            }
        }
示例#2
0
 private void OnPurchasingEvent(ShopItemSlot itemSlot)
 {
     if (CurrencyManager.Instance.CanPurchasing(itemSlot.ShopItem.item.BuyPrice * itemSlot.ShopItem.Amount))
     {
         if (!InventoryManager.Instance.inventory.IsFull())
         {
             InventoryManager.Instance.inventory.AddItem
             (
                 itemSlot.ShopItem.item.GetCopy(),
                 itemSlot.ShopItem.Amount,
                 itemSlot.ShopItem.Amount
             );
             CurrencyManager.Instance.AddGold
             (
                 -itemSlot.ShopItem.item.BuyPrice * itemSlot.ShopItem.Amount
             );
             Destroy(itemSlot.gameObject);
         }
     }
 }