Exemple #1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "food")
        {
            ui.score            += 1;
            ui.currentScore.text = ui.score.ToString();
            Destroy(col.gameObject);
        }

        else
        {
            if (ui.score > ui.uHighScore)
            {
                PlayerPrefs.SetInt("HighScore", ui.score);
            }
            ui.highScore.text = "High Score: " + PlayerPrefs.GetInt("HighScore").ToString();
            Destroy(gameObject);
            ui.gameOverAcivate();
        }
    }