Esempio n. 1
0
    void OnCollisionEnter(Collision coll)
    {
        GameObject collidedWith = coll.gameObject;

        if (collidedWith.tag == "Apple")
        {
            Apple apple = collidedWith.GetComponent <Apple>();
            apple.Destroyed(1f);
            //Destroy(collidedWith);
        }

        // Переводим текст в число
        int score = int.Parse(scoreGT.text);

        // Добавляем очки за яблочки
        score += 1;
        // Конвертируем обратно в строчку и отображаем
        scoreGT.text = score.ToString();

        // Отслеживаем лучший результат
        if (score > HighScore.score)
        {
            HighScore.score = score;
        }
    }