Exemplo n.º 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");
     }
 }
Exemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        HQ dock = GetComponentInParent <HQ>();

        if (other.tag == "ship")
        {
            Ship othership = other.GetComponent <Ship>();
            if (othership.getTeam() == dock.getTeam())
            {
                dock.addAllyShip(othership);
            }
            else
            {
                dock.addEnemyShip(othership);
            }
        }
    }