Esempio n. 1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != null)
        {
            Destroy(gameObject);
        }
    }
Esempio n. 2
0
 protected void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "GameOver")
     {
         Debug.Log("Game Over");
         GameObject.FindGameObjectWithTag("PlayDirector").GetComponent <PlayDirector>().GameOver();
     }
     else if (collision.tag == "Coin")
     {
         PlayDirector.AddCoin();
         Destroy(collision);
     }
     else if (collision.tag == "Fuel")
     {
         Refill();
         Destroy(collision);
     }
     else if (collision.tag == "Boost")
     {
         Vector2 v = new Vector2(Random.Range(-1, 1), 1);
         gameObject.GetComponent <Rigidbody2D>().AddForce(v, ForceMode2D.Impulse);
     }
 }