UnityPlatformer.CharacterHealth.Die C# (CSharp) Method

Die() public method

Disable HitBox(es) and DamageType(s) Trigger onDeath
public Die ( ) : void
return void
    public void Die() {
      --lives;

      if (onDeath != null) {
        Debug.Log(this.name + " died!");
        onDeath();
      }

      if (lives == 0) {
        // game over
        Debug.Log(this.name + " disable all HitBox(es)");
        var lch = GetComponentsInChildren<HitBox> ();
        foreach (var x in lch) {
           x.gameObject.SetActive(false);
        }

        Debug.Log(this.name + " disable all Damage(s)");
        var ldt = GetComponentsInChildren<Damage> ();
        foreach (var x in ldt) {
           x.gameObject.SetActive(false);
        }

        if (onGameOver != null) {
          Debug.Log(this.name + " game-over!");
          onGameOver();
        }
      } else {
        // disable invulnerability

        // respawn
        Heal(startingHealth);

        if (onRespawn != null) {
          onRespawn();
        }
      }
    }
  }