Exemplo n.º 1
0
 protected virtual void OnDie(DieReason reason)
 {
     if (OnDieEvent != null)
     {
         OnDieEvent.Invoke(reason);
     }
 }
Exemplo n.º 2
0
    public void Die(DieReason reason)
    {
        Debug.Log("I died because of reason: " + reason.ToString());
        characterControl.GetComponent <Rigidbody2D>().simulated = false;

        animator.SetBool("IsHanging", false);
        animator.SetBool("IsJumping", false);
        animator.SetBool("IsCrouching", false);
        animator.SetBool("IsClimbing", false);
        if (reason == DieReason.Electrocuted)
        {
            animator.SetBool("IsElectrocuted", true);
            if (audioSource && electrocutedAudio)
            {
                audioSource.PlayOneShot(electrocutedAudio);
            }
            FindObjectOfType <GameControl>().Invoke("GameOver", 2);           //allow for the death-animation
            return;
        }
        if (reason == DieReason.Detected)
        {
            if (detected != null)
            {
                detected.SetActive(true);
            }
            FindObjectOfType <GameControl>().Invoke("GameOver", 2);           //allow for the death-animation
            return;
        }
        FindObjectOfType <GameControl>().Invoke("GameOver", 0);
    }
Exemplo n.º 3
0
 public void Die(DieReason reason)
 {
     if (_alive)
     {
         UpdateDirection(0f);
         _alive = false;
         if ((_rigidbody2D.constraints & RigidbodyConstraints2D.FreezePositionX) == 0)
         {
             _rigidbody2D.constraints = RigidbodyConstraints2D.None;
         }
         _animator.SetTrigger("Die");
         OnDie(reason);
         ReleaseCamera();
     }
 }