Ejemplo n.º 1
0
    public void UpdateEnemyAndAllyLists(TargetObject[] allies, TargetObject[] enemies)
    {
        if (agent == null)
        {
            return;
        }
        enemyTargets = enemies;

        //if there is no target then exit the engaging state
        if (enemyTargets.Length <= 0)
        {
            agent.EndEngaging();
            engaging = false;
        }

        var lastTargets = currentlyNoticedTargets.ToArray();

        currentlyNoticedTargets = new List <TargetObject>();

        var previousLastKnownTargetPositions = lastKnownTargetPositions.ToArray();

        lastKnownTargetPositions = new List <Vector3>();

        //Take all the existing targets into a new list
        for (var i = 0; i < lastTargets.Length; i++)
        {
            foreach (var t in enemyTargets)
            {
                if (lastTargets[i].uid != t.uid)
                {
                    continue;
                }


                currentlyNoticedTargets.Add(t);
                lastKnownTargetPositions.Add(previousLastKnownTargetPositions[i]);
                break;
            }
        }

        //Check to see if we can see any target
        CheckForLOSAwareness(engaging);

        ChooseTarget();
    }