示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("Exiting game");
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        if (unityChan.IsDead())
        {
            text1.text = "You died";
            text2.text = "Press R to restart. Press Esc to exit the game.";
        }
        if (levelPassed)
        {
            Time.timeScale         = 0;
            unityChan.Invulnerable = true;
            text1.text             = "Level completed!";
        }
    }
示例#2
0
 public bool IsDead()
 {
     return(unitHealth && unitHealth.IsDead());
 }