Beispiel #1
0
 private void OnTriggerEnter2D(Collider2D collision)     // Should this live here or on the sheep/wolf?
 {
     if (collision.gameObject.CompareTag("Sheep"))
     {
         SheepController sheep = collision.gameObject.GetComponent <SheepController>();
         if (sheep)
         {
             sheep.UnpanicSheep();
             sheep.ChangeVelocity(transform.position, velocity);
         }                     // unpanic sheep from dashjump
     }
     else if (collision.gameObject.CompareTag("Wolf"))
     {
         WolfController wolf = collision.gameObject.GetComponent <WolfController>();
         wolf.Die();
     }
 }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     // lightning hits sheep
     if (collision.gameObject.CompareTag("Sheep"))
     {
         SheepController sheep = collision.gameObject.GetComponent <SheepController>();
         if (sheep.isPanicked == false)
         {
             sheep.PanicSheep();
             sheep.ChangeVelocity(transform.position, sheepHitVelocity);
         }
         else if (collision.gameObject.CompareTag("Wolf"))
         {
             WolfController wolf = collision.gameObject.GetComponent <WolfController>();
             wolf.Die();
         }
     }
 }