public void Die(sbyte type) //Character loses 1 life (parameter specifies the type of death) { m_Health = 0; //Mantain health in 0 while dead m_Rigidbody.velocity = Vector3.zero; //Stop character m_Capsule.enabled = false; //Disable character collider m_Rigidbody.isKinematic = true; //Disable rigidbody forces while dead transform.GetChild(0).gameObject.SetActive(false); //Make character invisible (disappear) by disabling model m_ManagerMechanics.m_TimeEnabled = false; //Disable level time run while dead //PLAY DEATH ANIMATION //PLay death sound if (type == 2) //Time's up { m_UIManager.ShowTimesUp(); //Show time's up message } if (m_Lives == 1) //Last life lost { m_UIManager.ShowGameOver(); //Show game over message //Play game over sound } else { m_UIManager.ShowDeath(); //Show death message //PLay game over sound } m_RespawnTimer += Time.deltaTime; //Update respawn timer if (m_RespawnTimer >= m_RespawnDelay) //Respawn timer up (must respawn character) { m_RespawnTimer = 0; //Reset respawn timer m_Capsule.enabled = true; //Re-enable collider m_Rigidbody.isKinematic = false; //Re-enable rigidbody forces transform.GetChild(0).gameObject.SetActive(true); //Make character visible by re-enabling model m_Lives -= 1; if (m_Lives <= 0) //Game Over (Restarts game) { m_Lives = 0; m_ManagerMechanics.RestartLevel(); //DEBE SER RestartGame m_Lives = 3; //Reset player lifes m_UIManager.HideGameOver(); //Hide game over message } else //Lifes remaining. Load last checkpoint { m_ManagerMechanics.LoadCheckpoint(); //Return character to checkpoint m_UIManager.HideDeath(); //Hide death message } m_UIManager.HideTimesUp(); //Hide time's up message m_ManagerMechanics.m_TimeEnabled = true; //Re-enable level time run m_Health = 100; //Reset player's health } }