示例#1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "ship")
     {
         Ship otherShip = other.GetComponent <Ship>();
         if (otherShip.getTeam() != getTeam())
         {
             //explode
             otherShip.getDamage(1, getDirection());
             DestroyBall("other");
         }
         // else if (otherShip != GetComponent<CannonBall>().getParentShip())
         // {
         //     GetComponent<CannonBall>().DestroyBall();
         // }
     }
     else if (other.tag == "dock" && cannonType == Cannon.CannonType.ship)
     {
         Dock otherDock = other.GetComponent <Dock>();
         if (otherDock.getTeam() != getTeam())
         {
             //explode
             otherDock.getDamage(1);
             DestroyBall("other");
         }
     }
     else if (other.tag == "hq" && cannonType == Cannon.CannonType.ship)
     {
         HQ otherDock = other.GetComponent <HQ>();
         if (otherDock.getTeam() != getTeam())
         {
             //explode
             otherDock.getDamage(1);
             DestroyBall("other");
         }
     }
     else if (other.tag == "water")
     {
         //play splash sound
         DestroyBall("water");
     }
     else if (other.tag == "ground")
     {
         //explode
         DestroyBall("other");
     }
 }