//Takes Energy when player is doing certain actions private void SpendEnergy(PlayerController.PlayerAction lastPlayerAction) { switch (lastPlayerAction) { case PlayerController.PlayerAction.Jump: ChangeEnergy(-jumpEnergy); break; } }
public bool HasEnergyForAction(PlayerController.PlayerAction lastPlayerAction) { float energyToSpend = 0; switch (lastPlayerAction) { case PlayerController.PlayerAction.Jump: energyToSpend = jumpEnergy; break; } return(currentEnergy > energyToSpend); }
// Update is called once per frame void Update() { if (lastPlayerAction != playerController.playerAction) { lastPlayerAction = playerController.playerAction; if (HasEnergyForAction(lastPlayerAction)) { SpendEnergy(lastPlayerAction); } } else if (lastPlayerAction == PlayerController.PlayerAction.HangUp) { ChangeEnergy(-hangUpEnergy); } FillEnergy(); energyBar.GetComponent <BarController>().barQuantity = currentEnergy; }
// Use this for initialization void Start() { playerController = GetComponent <PlayerController>(); lastPlayerAction = playerController.playerAction; energyBar.GetComponent <BarController>().barQuantity = currentEnergy; }
// Use this for initialization void Start() { playerController = GetComponent <PlayerController>(); lastPlayerAction = playerController.playerAction; lifeBar.GetComponent <BarController>().barQuantity = currentLife; }