Пример #1
0
    private float EvaluatePriority(EnemyAIAgent ea, Rigidbody rb)//How Good of a Target rb is for this turret, Lower = Better
    {
        //Estimate Reaction Time for Target
        Vector3 D = ea.transform.position - rb.position; float Dmag = D.magnitude;
        float   Vn = ea.PROJECTILE_SPEED + Vector3.Dot(D, rb.velocity) / Dmag; //Estimate Net Vel from Turret

        if (Vn <= 0)
        {
            return(Mathf.Infinity);
        }                                                                    //At Current Velocity, Can't Hit (Makes Cautious Estimate, Only gives False Positives)
        float EstReactTime = Dmag / Vn;
        float affinity     = (rb == ea.CurrentTarget ? 0 : TARGET_AFFINITY); //Accounts for Loyalty to Current Target

        return(EstReactTime + affinity);                                     //Add factors for more refined Priority controll
    }
Пример #2
0
    public SortedList <float, Rigidbody> GetPriorityTargets(EnemyAIAgent ea)
    {
        if (ea == null)
        {
            throw new System.Exception("Priority for Null");
        }

        SortedList <float, Rigidbody> targetPriority = new SortedList <float, Rigidbody>(Targets.Count);

        foreach (Rigidbody rb in Targets)
        {
            float score = EvaluatePriority(ea, rb);
            if (score != Mathf.Infinity)
            {
                targetPriority.Add(score, rb);
            }
        }
        return(targetPriority);
    }
Пример #3
0
 protected override void InitPersonSystems()
 {
     base.InitPersonSystems();
     EnemyAI = GetComponent <EnemyAIAgent>();
 }