Ejemplo n.º 1
0
 public virtual bool isValidTarget(BaseUnit target)
 {
     if ((target.GetClassification() == Classification.Heli || target.GetClassification() == Classification.Plane) && !antiAir)
     {
         return(false);
     }
     if ((target.GetClassification() == Classification.Structure || target.GetClassification() == Classification.Tank || target.GetClassification() == Classification.Simple) && !antiGround)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
    private void Update()
    {
        if (host.GetClassification() == Classification.Structure)
        {
            agent.speed = 0;
            agent.SetDestination(transform.position);
            return;
        }
        if (host.selected && travelingByInstruction && waypoint == null)
        {
            waypoint = Instantiate(PlayerControl.waypointGlobal, givenDestination, new Quaternion(0, 0, 0, 0));
        }
        if (travelingByInstruction)
        {
            //if the player said to go somewhere, go there and thats it.

            agent.SetDestination(givenDestination);
            if (Vector3.Distance(transform.position, givenDestination) <= 10)
            {
                travelingByInstruction = false; //we have arrived
            }
            return;
        }
        else
        {
            if (foe != null)
            {
                //there is a foe around, go to it
                agent.SetDestination(foe.transform.position);
                if (Vector3.Distance(foe.transform.position, transform.position) <= host.getWeaponRnage() + 0) //+2 so we go alittle under the required range
                {
                    agent.SetDestination(transform.position);                                                  //stop once in range
                    if (host.hullMountedWeapon != null)
                    {
                        host.transform.LookAt(foe.transform);
                        if (host.hullMountedWeapon.readyToFire())
                        {
                            host.hullMountedWeapon.fire(foe);
                        }
                    }
                }
            }
        }
    }