public void ClickDel(UISimpleGameDataButton button, PointerEventData.InputButton buttonEvent) { var item = button.Data as Entity; if (item != null) { Player.MainInventory.Add(item); } }
public void ClickDel(UISimpleGameDataButton button, PointerEventData.InputButton buttonEvent) { var item = button.Data as Entity; if (item != null) { World.Get <ContainerSystem>().TryAdd(Player.MainInventory, item); } }
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)); }
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; }
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; }
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; }
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)); }