Exemple #1
0
 public void ResetTarget()
 {
     if (target == null && targets.Count != 0)
     {
         target = targets [0];
     }
     try{
         foreach (IPDTarget t in pdTargets)
         {
             if (t == null || t.GetGameObject() == null)
             {
                 RemoveTargetT(t);
             }
         }
     }
     catch {
         pdTargets.Remove(pdTargets [0]);
         Debug.Log("<color=red>Avoiding Target Lockup Error</color> This warning can be safely ignored.");
     }
     if (pdTargets.Count != 0)
     {
         pdTargets.OrderBy(
             targ => Vector3.Distance(this.transform.position, targ.GetGameObject().transform.position)).ToList();
         pdtarget = pdTargets [0];
     }
 }
Exemple #2
0
 public void AssignTarget(IPDTarget s)
 {
     if (pdTargets.Contains(s))
     {
         pdTarget = s;
     }
 }
Exemple #3
0
 public virtual void OnTriggerEnter(Collider col)
 {
     if (tType == TurretType.CAPITAL)
     {
         ICAPTarget s = col.GetComponent <ICAPTarget> ();
         if (s != null)
         {
             if (s.isHostile(self.faction))
             {
                 targets.Add(s);
             }
         }
     }
     else if (tType == TurretType.PD)
     {
         IPDTarget s = col.GetComponent <IPDTarget> ();
         if (s != null)
         {
             if (s.isHostile(self.faction))
             {
                 pdTargets.Add(s);
             }
             SortList();
         }
     }
 }
Exemple #4
0
 public void RemoveTargetT(IPDTarget s)
 {
     if (pdTargets.Contains(s))
     {
         pdTargets.Remove(s);
     }
     if (pdtarget == s)
     {
         pdtarget = null;
         //		ResetTarget ();
     }
 }
Exemple #5
0
    public void ResetTarget()
    {
        if (target == null && targets.Count != 0)
        {
            target = targets [0];
        }

        if (pdTargets.Count != 0)
        {
            pdTarget = pdTargets [0];
        }
    }
Exemple #6
0
    public void OnTriggerExit(Collider col)
    {
        Ship s = col.GetComponent <Ship> ();

        if (s)
        {
            if (targets.Contains(s))
            {
                targets.Remove(s);
            }
            if (target == s)
            {
                target = null;
            }
            if (targets.Count != 0)
            {
                target = targets [0];
            }
        }

        IPDTarget t = col.GetComponent <IPDTarget> ();

        if (t != null)
        {
            if (pdTargets.Contains(t))
            {
                pdTargets.Remove(t);
            }
            if (pdtarget == t)
            {
                pdtarget = null;
            }
            if (pdTargets.Count != 0)
            {
                pdtarget = pdTargets [0];
            }
        }
    }
Exemple #7
0
    public void OnTriggerEnter(Collider col)
    {
        IPDTarget t = col.GetComponent <IPDTarget> ();

        if (t != null)
        {
            if (t.isHostile(self.faction))
            {
                pdTargets.Add(t);
                //	ResetTarget ();
            }
        }
        ICAPTarget s = col.GetComponent <ICAPTarget> ();

        if (s != null)
        {
            if (s.isHostile(self.faction))
            {
                targets.Add(s);
                //	ResetTarget ();
            }
        }
    }
Exemple #8
0
    public virtual void OnTriggerExit(Collider col)
    {
        ICAPTarget s = col.GetComponent <ICAPTarget> ();
        IPDTarget  t = col.GetComponent <IPDTarget> ();

        if (s != null)
        {
            if (targets.Contains(s))
            {
                targets.Remove(s);
            }
            if (target == s)
            {
                target = null;
            }
            if (targets.Count != 0)
            {
                target = targets [0];
            }
        }
        else if (t != null)
        {
            if (pdTargets.Contains(t))
            {
                pdTargets.Remove(t);
            }
            if (pdTarget == t)
            {
                pdTarget = null;
            }
            if (pdTargets.Count != 0)
            {
                pdTarget = pdTargets [0];
            }
        }
    }