コード例 #1
0
    Enemy FindClosestBunnyTarget(Survivor_AI sAI)
    {
        Enemy target = null;

        float closestSoFar = Mathf.Infinity;
        int   worst        = 0;

        List <Enemy> allEnemies = GameManager.getZomBunnyList();

        foreach (Enemy e in allEnemies)
        {
            if (e.getState() != EnemyState.DEAD)
            {
                float dist = (e.transform.position - sAI.transform.position).magnitude;
                if (dist < closestSoFar && dist < sAI.GetCurrWeapon().getRange())
                {
                    target       = e;
                    closestSoFar = dist;
                }
            }
        }


        return(target);
    }