Player put items in basket with UI indication
This commit is contained in:
@@ -14,7 +14,7 @@ public class Fridge : BaseInteractableObject
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
|
||||
_actionsMenu.Show(_containerSO.Name, $"Max items:{_containerSO.MaxCapacity} current items: {_containerSO.CurrentItemsCount}");
|
||||
//_actionsMenu.Show(_containerSO.Name, $"Max items:{_containerSO.MaxCapacity} current items: {_containerSO.CurrentItemsCount}");
|
||||
//if (player.IsHoldContainer())
|
||||
//{
|
||||
// if (_foodObjects.Count < _containerSO.MaxCapacity)
|
||||
|
||||
@@ -7,11 +7,11 @@ public class ContainerItem : MonoBehaviour
|
||||
private ContainerSO _containerSO;
|
||||
|
||||
|
||||
private List<SellableItem> _items;
|
||||
private List<SellableItemSO> _items;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_items = new List<SellableItem>();
|
||||
_items = new List<SellableItemSO>();
|
||||
}
|
||||
|
||||
public ContainerSO GetContainerObjectSO()
|
||||
@@ -19,17 +19,21 @@ public class ContainerItem : MonoBehaviour
|
||||
return _containerSO;
|
||||
}
|
||||
|
||||
public void AddItem(SellableItem item)
|
||||
public void AddItem(SellableItemSO item)
|
||||
{
|
||||
if (_containerSO.CurrentItemsCount < _containerSO.MaxCapacity)
|
||||
if (_items.Count < _containerSO.MaxCapacity)
|
||||
{
|
||||
Debug.Log($"Player put to container a {item.GetSellableItemSO().objectName}");
|
||||
Debug.Log($"Player put to container a {item.ItemName}");
|
||||
_items.Add(item);
|
||||
_containerSO.CurrentItemsCount = _items.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is full");
|
||||
}
|
||||
}
|
||||
|
||||
public List<SellableItemSO> GetItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ShopingContainer : BaseInteractableObject
|
||||
public class ShopingBasket : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
+3
-4
@@ -1,7 +1,7 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class ColaFreezer : BaseInteractableObject
|
||||
public class StoreContainer : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private SellableItemSO _sellableItemSO;
|
||||
@@ -10,11 +10,10 @@ public class ColaFreezer : BaseInteractableObject
|
||||
{
|
||||
if (player.IsHoldContainerItem())
|
||||
{
|
||||
var transform = Instantiate(_sellableItemSO.prefab, player.GetContainerItem().transform);
|
||||
var sellableItem = transform.GetComponent<SellableItem>();
|
||||
var clone = Instantiate(_sellableItemSO);
|
||||
|
||||
var container = player.GetContainerItem();
|
||||
container.AddItem(sellableItem);
|
||||
container.AddItem(clone);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user