Ejemplo n.º 1
0
 /// <summary>
 /// Swap possession of the ball from p1 to p2 or the inverse.
 /// </summary>
 void swapPossession()
 {
     if (ballpossesssion == possession.PLAYER1)
     {
         ballpossesssion = possession.PLAYER2;
     }
     else if (ballpossesssion == possession.PLAYER2)
     {
         ballpossesssion = possession.PLAYER1;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// On trigger enter, handle that 'collision'
 /// If the ball hit p1 or p2, swap possession and play the bounce noise
 /// If the ball hit the wall, do what it's supposed to do (bounce, extinguish, or nothing) with associated sound effects.
 /// </summary>
 /// <param name="other"></param>
 private void OnTriggerEnter(Collider other)
 {
     // Basically when you run into the player, you turn around and the player takes possession
     if (other.gameObject.tag == "Player1")
     {
         if (ballpossesssion != possession.PLAYER1)
         {
             ballpossesssion = possession.PLAYER1;
             CardDirection.SoundFXManager.instance.playSound("Bounce");
         }
     }
     else if (other.gameObject.tag == "Player2")
     {
         if (playerExtinguish)
         {
             other.gameObject.GetComponent <MeshRenderer>().enabled = false;
         }
         else if (ballpossesssion != possession.PLAYER2)
         {
             ballpossesssion = possession.PLAYER2;
             CardDirection.SoundFXManager.instance.playSound("Bounce");
         }
     }
     else if (other.gameObject.tag == "Wall")
     {
         if (wallBounce)
         {
             CardDirection.SoundFXManager.instance.playSound("Bounce");
             swapPossession();
         }
         else if (wallExtinguish)
         {
             extinguish();
             CardDirection.SoundFXManager.instance.playSound("Crowbar");
         }
     }
 }