Beispiel #1
0
 public void TakeDamage(float damage)
 {
     if (damage < CurrentHealth)
     {
         CurrentHealth -= damage;
         lifeDisplay.UpdateDisplay();
     }
     else
     {
         CurrentHealth = 0;
         lifeDisplay.UpdateDisplay();
         FindObjectOfType <SceneLoader>().LoadLoseScene();
     }
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        // cache
        lifeDisplay = FindObjectOfType <PlayerLifeDisplay>();

        CurrentHealth = startingHealth;
        lifeDisplay.UpdateDisplay();
    }