character fall asleep when low energy
This commit is contained in:
@@ -5,10 +5,11 @@ using UnityEngine.AI;
|
||||
|
||||
public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
public Stat money = new Stat("Money", 1000.0f);
|
||||
private enum States { Idle, Walking, Sleeping };
|
||||
public Stat money = new Stat("Money", 100.0f);
|
||||
public Stat rentAccount = new Stat("Rent Account", 0);
|
||||
public Stat food = new Stat("Food Energy", 100);
|
||||
public Stat energy = new Stat("Energy", 100);
|
||||
public Stat energy = new Stat("Energy", 12);
|
||||
|
||||
// bank
|
||||
public Stat bankAccount = new Stat("Bank Account", 0);
|
||||
@@ -47,6 +48,8 @@ public class PlayerManager : MonoBehaviour
|
||||
public ParticleSystem targetDest;
|
||||
public bool allowMovement = true;
|
||||
|
||||
private States _state;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TimeManager.OnMinuteChanged += DecreaseEnergy;
|
||||
@@ -96,8 +99,29 @@ public class PlayerManager : MonoBehaviour
|
||||
|
||||
public void DecreaseEnergy()
|
||||
{
|
||||
food.deduct(1f);
|
||||
energy.deduct(0.096f); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
food.deduct(0.034f); // 48 hours it's 100, 100/2880=~0.034 per minute
|
||||
switch (_state)
|
||||
{
|
||||
case States.Idle:
|
||||
case States.Walking:
|
||||
energy.deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
break;
|
||||
case States.Sleeping:
|
||||
energy.increase(1f);
|
||||
break;
|
||||
}
|
||||
if (energy.Value <= 10 && _state != States.Sleeping)
|
||||
{
|
||||
_state = States.Sleeping;
|
||||
allowMovement = false;
|
||||
playerAnimator.SetBool("IsSleeping", true);
|
||||
}
|
||||
if (energy.Value >= 100 && _state == States.Sleeping)
|
||||
{
|
||||
_state = States.Idle;
|
||||
allowMovement = false;
|
||||
playerAnimator.SetBool("IsSleeping", false);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryBuyAction(BaseAction action)
|
||||
|
||||
Reference in New Issue
Block a user