CleanupCode add eating
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,12 +8,14 @@ public class Fridge : BaseInteractableObject
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
[SerializeField]
|
||||
private ItemActionsUI _actionsMenu;
|
||||
//private ItemActionsUI _actionsMenu;
|
||||
|
||||
private Player _player;
|
||||
private List<FoodItemSO> _foodObjects = new List<FoodItemSO>();
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
_player = player;
|
||||
if (player.IsHoldContainerItem())
|
||||
{
|
||||
var playerContainer = player.GetContainerItem();
|
||||
@@ -32,20 +35,26 @@ public class Fridge : BaseInteractableObject
|
||||
Debug.Log($"Fridge is full");
|
||||
}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// //Eat menu
|
||||
// if (_foodObjects.Count > 0)
|
||||
// {
|
||||
// while (player.Stats[StatsId.Food].Value < player.Stats[StatsId.Food].MaxValue && _foodObjects.Count > 0)
|
||||
// {
|
||||
// _foodObjects.RemoveAt(0);
|
||||
// player.Eat();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//_containerSO.CurrentItemsCount = _foodObjects.Count;
|
||||
else
|
||||
{
|
||||
//Eat menu
|
||||
if (_foodObjects.Count > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator EatRoutine(float timeToEat)
|
||||
{
|
||||
_player.SetPlayerActing(PlayerStates.Eating);
|
||||
yield return new WaitForSeconds(timeToEat);
|
||||
_player.SetPlayerActing(PlayerStates.Awake);
|
||||
yield break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ public class ShopingContainer : BaseInteractableObject
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
[SerializeField]
|
||||
private ItemActionsUI _actionsMenu;
|
||||
//private ItemActionsUI _actionsMenu;
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user