radial menu work
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user