public void EnemyDetection()
    {
        enemiesNearby.Clear();
        Collider[] hitColliders = Physics.OverlapSphere(transform.position, panicDistance);
        foreach (var hitCollider in hitColliders)
        {
            if (ld.isBlue && ld.isInOpponentArea)
            {
                if (hitCollider.gameObject.CompareTag("Red"))
                {
                    enemiesNearby.Add(hitCollider.GetComponent <LittleDude>());
                }
            }
            else if (ld.isRed && ld.isInOpponentArea)
            {
                if (hitCollider.gameObject.CompareTag("Blue"))
                {
                    enemiesNearby.Add(hitCollider.GetComponent <LittleDude>());
                }
            }
        }

        if (enemiesNearby.Count > 0)
        {
            emergencyOverride = true;
            closestEnemy      = GetClosestEnemy();
            ld.SetSprint();
        }
        else
        {
            emergencyOverride = false;
        }
    }
Beispiel #2
0
    private void Update()
    {
        if (target != null)
        {
            if (target.tagged || !target.isInOpponentArea)
            {
                target    = null;
                hasTarget = false;
            }
        }

        if (!ld.tagged)
        {
            if (hasTarget)
            {
                if (ld.isBlue)
                {
                    if (battleInfo.redHasBlueFlag && target != battleInfo.redGuyWithBlueFlag)
                    {
                        target = battleInfo.redGuyWithBlueFlag;
                    }
                }
                else
                {
                    if (battleInfo.blueHasRedFlag && target != battleInfo.blueGuyWithRedFlag)
                    {
                        target = battleInfo.blueGuyWithRedFlag;
                    }
                }
                ld.SetDestination(target.transform.position);
                ld.SetSprint();
            }
            else
            {
                ld.SetDestination(transform.position);
            }
        }
    }