//
    // Внутренние функции
    //

    // Пытается найти цель из видимых.
    // Если находит, то идет к ней и атакует, но не меняет активный приказ.
    private bool TryFindTarget()
    {
        // Debug.Log("Trying to find new target!");
        List <Visible> potentialTargets = vision.VisiblesInSight();

        // Debug.Log(potentialTargets.ToString());

        foreach (Visible potentialTarget in potentialTargets)
        {
            if (potentialTarget == null)
            {
                continue;
            }

            Health target = potentialTarget.GetComponent <Health>();
            if (target == null)
            {
                continue;
            }

            if (attack.CheckTarget(target))
            {
                attack.AppointTarget(target);
                legs.FollowTarget(target.GetComponent <DTRMPosition>());
                return(true);
            }
        }

        return(false);
    }
Beispiel #2
0
    public void GiveTarget(Health targetVictim)
    {
        Debug.Log("Got target health!");

        if (targetVictim == null)
        {
            return;
        }

        if (!attack.CheckTarget(targetVictim))
        {
            return;
        }

        activeState = PlayerState.Attack;
        attack.AppointTarget(targetVictim);
        legs.FollowTarget(targetVictim.myPosition);
    }