radial menu work

This commit is contained in:
2023-11-17 15:02:33 +02:00
parent 37da3bd61a
commit cb2eba5731
39 changed files with 3292 additions and 3050 deletions
+24 -14
View File
@@ -7,18 +7,34 @@ public class Fridge : BaseInteractableObject
{
[SerializeField]
private ContainerSO _containerSO;
[SerializeField]
//private ItemActionsUI _actionsMenu;
private List<FoodItemSO> _foodObjects = new List<FoodItemSO>();
protected override void InteractAction()
{
private bool CheckIfPlayerHaveItems()
{
if (_player.IsHoldContainerItem())
{
var playerContainer = _player.GetContainerItem();
if (!playerContainer.IsSalebleItems())
{
return true;
}
}
return false;
}
protected override void PrepareMenuActions()
{
_menuActions[RadialMenuActions.Put].IsEnabled = CheckIfPlayerHaveItems();
_menuActions[RadialMenuActions.Eat].IsEnabled = _foodObjects.Count > 0;
}
protected override void InteractAction(RadialMenuActions interactAction)
{
switch (interactAction)
{
case RadialMenuActions.Put:
var playerContainer = _player.GetContainerItem();
if (_foodObjects.Count + playerContainer.GetItems().Count <= _containerSO.MaxCapacity)
{
foreach (FoodItemSO item in playerContainer.GetItems())
@@ -31,19 +47,13 @@ public class Fridge : BaseInteractableObject
}
else
Debug.Log($"Fridge is full");
}
}
else
{
//Eat menu
if (_foodObjects.Count > 0)
{
break;
case RadialMenuActions.Eat:
var hunger = _player.Stats[StatsId.Food].MaxValue - _player.Stats[StatsId.Food].Value;
var eatingItems = _foodObjects.Count < (hunger / 10) ? _foodObjects.Count : (hunger / 10);
StartCoroutine(EatRoutine(eatingItems));
_foodObjects.RemoveRange(0, (int)eatingItems);
}
break;
}
}