Added health recovering feature
This commit is contained in:
parent
f1adc298bb
commit
68ec3ed791
@ -20,6 +20,12 @@ public class Player : MonoBehaviour
|
||||
public HealthBar healthBar;
|
||||
private bool attack;
|
||||
|
||||
private float timerRegen = 0f;
|
||||
private float timerTick = 0f;
|
||||
private float waitRegen = 8.0f;
|
||||
private float waitTick = 1.0f;
|
||||
|
||||
private bool startRegen = false;
|
||||
|
||||
private bool canWalk = true;
|
||||
|
||||
@ -40,6 +46,8 @@ public class Player : MonoBehaviour
|
||||
var em = dmgParticleSystem.emission;
|
||||
em.enabled = true;
|
||||
StartCoroutine(Timer());
|
||||
timerRegen = 0.0f;
|
||||
startRegen = false;
|
||||
if (currentHealth <= 0)
|
||||
{
|
||||
Panel.SetActive(true);
|
||||
@ -106,6 +114,26 @@ public class Player : MonoBehaviour
|
||||
myAnimator.SetFloat("lastMoveX", inputHorizontal);
|
||||
myAnimator.SetFloat("lastMoveY", inputVertical);
|
||||
}
|
||||
|
||||
timerRegen += Time.deltaTime;
|
||||
if(timerRegen >= waitRegen)
|
||||
{
|
||||
startRegen = true;
|
||||
}
|
||||
|
||||
if (startRegen == true)
|
||||
{
|
||||
timerTick += Time.deltaTime;
|
||||
if(timerTick >= waitTick)
|
||||
{
|
||||
if(currentHealth < 10)
|
||||
{
|
||||
currentHealth = currentHealth + 1;
|
||||
healthBar.SetHealth(currentHealth);
|
||||
timerTick = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
HandleInput();
|
||||
|
Loading…
Reference in New Issue
Block a user