Example #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("sprout") || snakeMove.reindeerTrail.Contains(other.transform))
        {
            snakeMove.Die();
        }

        else if (other.gameObject.CompareTag("pickup"))
        {
            snakeMove.AddTail(other.gameObject.transform);
            snakeMove.IncreaseSpeed();
            raindeerSpawner.SpawnRandomReindeer();
        }
    }
Example #2
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.CompareTag("Food"))
     {
         movement.addBody();
         Destroy(col.gameObject);
         SO.spawnFood();
     }
     else
     {
         if (col.transform != movement.bodyParts [1] && !movement.isAlive)
         {
             if (Time.time - movement.timeElapsed > 5)
             {
                 movement.Die();
             }
         }
     }
 }