Beispiel #1
0
 public override void LookForTarget()
 {
     if (mySpawnerWorldObject && mySpawnerWorldObject.paramManager.PlayerOwned)
     {
         List <Collider> possibleTargetColliders = new List <Collider>();
         possibleTargetColliders = WorkManager.DeterminePlayerUnitTargetsInRange(transform.position, paramManager.AggroRange);
         if (possibleTargetColliders.Count > 0)
         {
             foreach (Collider col in possibleTargetColliders)
             {
                 WorldObject wo = col.GetComponentInParent <WorldObject>();
                 if (wo && wo.paramManager.HealthPercentage != 1f)
                 {
                     if (targetCollider)
                     {
                         if ((gameObject.transform.position - col.gameObject.transform.position).sqrMagnitude < (gameObject.transform.position - targetCollider.gameObject.transform.position).sqrMagnitude)
                         {
                             targetCollider = col;
                         }
                     }
                     else
                     {
                         targetCollider = col;
                     }
                     return;
                 }
             }
         }
     }
     targetCollider = null;
 }