Exemplo n.º 1
0
        private void SellBuyItem(Item item, ClearSlotCallback clearSlotCallback)
        {
            if (item != null)
            {
                Bagpack PlayerBagpack = this.gameObject.GetComponentInParent <ShopInventory>().PlayerBagpack;
                Bagpack ShopBagpack   = this.gameObject.GetComponentInParent <ShopInventory>().ShopBagpack;
                if (PlayerBagpack == this)
                {
                    //this is player bagpack (player sell item)
                    if (this.IfICanSellBuyItem(ShopBagpack.inventory_gold, item.GoldValue))
                    {
                        ShopBagpack.AddItem(item);

                        ShopBagpack.AddItem(this.GetGoldByValue(-item.GoldValue));
                        PlayerBagpack.AddItem(this.GetGoldByValue(item.GoldValue));

                        PlayerBagpack.DeleteFromBagpack(item);
                        clearSlotCallback();
                    }
                    else
                    {
                        this.PrintToInfoPanel("Shop owner dont have gold to buy this item");
                    }
                }
                else
                {
                    //this is shop bagpack (player buy item)
                    if (this.IfICanSellBuyItem(PlayerBagpack.inventory_gold, item.GoldValue))
                    {
                        PlayerBagpack.AddItem(item);

                        PlayerBagpack.AddItem(this.GetGoldByValue(-item.GoldValue));
                        ShopBagpack.AddItem(this.GetGoldByValue(item.GoldValue));

                        ShopBagpack.DeleteFromBagpack(item);
                        clearSlotCallback();
                    }
                    else
                    {
                        this.PrintToInfoPanel("You dont have gold to buy this item");
                    }
                }


                //Debug.Log("Player: " + this.gameObject.GetComponentInParent<ShopInventory>().PlayerBagpack.items.Count);
                //Debug.Log("Shop: " + this.gameObject.GetComponentInParent<ShopInventory>().ShopBagpack.items.Count);
            }
        }
Exemplo n.º 2
0
 private void Awake()
 {
     this.IsOpen        = false;
     this.PlayerBagpack = this.gameObject.GetComponentsInChildren <Bagpack>()[0];
     this.ShopBagpack   = this.gameObject.GetComponentsInChildren <Bagpack>()[1];
 }
Exemplo n.º 3
0
 private void Awake()
 {
     this.PlayerBagpack = this.gameObject.GetComponentInChildren <Bagpack>();
 }