Esempio n. 1
0
        public void ClickDel(UISimpleGameDataButton button, PointerEventData.InputButton buttonEvent)
        {
            var item = button.Data as Entity;

            if (item != null)
            {
                Player.MainInventory.Add(item);
            }
        }
Esempio n. 2
0
        public void ClickDel(UISimpleGameDataButton button, PointerEventData.InputButton buttonEvent)
        {
            var item = button.Data as Entity;

            if (item != null)
            {
                World.Get <ContainerSystem>().TryAdd(Player.MainInventory, item);
            }
        }
Esempio n. 3
0
        private void SellClickDel(UISimpleGameDataButton button, PointerEventData.InputButton buttonEvent)
        {
            var item = button.Data.Get <InventoryItem>();

            if (item == null)
            {
                return;
            }
            if (Player.MainInventory.IsFull)
            {
                FloatingText(button.RectTransform, "Inventory full");
                return;
            }
            var price = GameOptions.PriceEstimateSell(item.GetEntity());

            _currentButton = button;
            UIModalQuestion.Set(CheckSell, string.Format("Sell for {0} {1}?", price, GameLabels.Currency));
        }
Esempio n. 4
0
        private void CheckSell(int index)
        {
            if (index > 0)
            {
                _currentButton = null;
                return;
            }
            var item = _currentButton.Data.Get <InventoryItem>();

            if (item == null)
            {
                _currentButton = null;
                return;
            }
            var price = GameOptions.PriceEstimateSell(item.GetEntity());

            FloatingText(_currentButton.RectTransform, string.Format("Sold for {0} {1}", price, GameLabels.Currency));
            Player.Currency.AddToValue(price);
            _sellingInventory.TryAdd(item.GetEntity());
            //item.Despawn(); better to be able to buy back
            _currentButton = null;
        }
Esempio n. 5
0
        private void CheckBuy(int index)
        {
            if (index > 0)
            {
                _currentButton = null;
                return;
            }
            var item = _currentButton.Data.Get <InventoryItem>();

            if (item == null)
            {
                _currentButton = null;
                return;
            }
            var sellPrice = item.TotalPrice();

            if (Player.MainInventory.TryAdd(item.GetEntity()))
            {
                Player.Currency.ReduceValue(sellPrice);
                FloatingText(_currentButton.RectTransform, string.Format("Bought for {0} {1}", sellPrice, GameLabels.Currency));
            }
            _currentButton = null;
        }
Esempio n. 6
0
        private void CheckBuy(int index)
        {
            if (index > 0)
            {
                _currentButton = null;
                return;
            }
            var item = _currentButton.Data.Get <InventoryItem>();

            if (item == null)
            {
                _currentButton = null;
                return;
            }
            var sellPrice = RulesSystem.TotalPrice(item);

            if (World.Get <ContainerSystem>().TryAdd(Player.MainInventory, item.GetEntity()))
            {
                Player.DefaultCurrencyHolder.ReduceValue(sellPrice);
                FloatingText(_currentButton.RectTransform, string.Format("Bought for {0} {1}", sellPrice, GameText.DefaultCurrencyLabel));
            }
            _currentButton = null;
        }
Esempio n. 7
0
        private void BuyClickDel(UISimpleGameDataButton button, PointerEventData.InputButton buttonEvent)
        {
            var item = button.Data.Get <InventoryItem>();

            if (item == null)
            {
                return;
            }
            if (Player.MainInventory.IsFull)
            {
                FloatingText(button.RectTransform, "Inventory full");
                return;
            }
            var sellPrice = item.TotalPrice();

            if (Player.Currency.Value < sellPrice)
            {
                FloatingText(button.RectTransform, string.Format("Costs {0}, Not enough {1}", sellPrice, GameLabels.Currency));

                return;
            }
            _currentButton = button;
            UIModalQuestion.Set(CheckBuy, string.Format("Buy for {0} {1}?", sellPrice, GameLabels.Currency));
        }