예제 #1
0
    public override bool CheckPreCondition(GameObject agent)
    {
        CS_RadioComponent[] goDistractingObjects = (CS_RadioComponent[])UnityEngine.GameObject.FindObjectsOfType(typeof(CS_RadioComponent));
        CS_RadioComponent   goClosestDistraction = null;

        CS_TotemComponent cTotem = GameObject.FindObjectOfType <CS_TotemComponent>();

        if (cTotem == null)
        {
            return(false);
        }

        float fDistanceToDistraction = 0;

        foreach (CS_RadioComponent distraction in goDistractingObjects)
        {
            if (goClosestDistraction == null)
            {
                // first one, so choose it for now
                goClosestDistraction   = distraction;
                fDistanceToDistraction = (distraction.gameObject.transform.position - cTotem.transform.position).magnitude;
            }
            else
            {
                // is this one closer than the last?
                float dist = (distraction.gameObject.transform.position - cTotem.transform.position).magnitude;
                if (dist < fDistanceToDistraction)
                {
                    // we found a closer one, use it
                    goClosestDistraction   = distraction;
                    fDistanceToDistraction = dist;
                }
            }
        }
        if (goClosestDistraction == null)
        {
            return(false);
        }
        m_goTarget = goClosestDistraction.gameObject;

        if (m_goTarget != null)
        {
            return(true);
        }

        return(false);
    }
예제 #2
0
    public override bool CheckPreCondition(GameObject agent)
    {
        CS_TotemComponent goTotem = (CS_TotemComponent)UnityEngine.GameObject.FindObjectOfType(typeof(CS_TotemComponent));

        m_goTarget = goTotem.gameObject;

        if (m_goTarget == null)
        {
            return(false);
        }
        if (m_goTarget.GetComponent <CS_KnowledgeComponent>().HasBeenCollected())
        {
            return(true);
        }

        return(false);
    }
    public override bool CheckPreCondition(GameObject agent)
    {
        CS_TotemComponent cTotemRef = GameObject.FindObjectOfType <CS_TotemComponent>();

        if (cTotemRef == null)
        {
            return(false);
        }
        if (!cTotemRef.GetComponent <CS_KnowledgeComponent>().HasBeenLocated())
        {
            return(false);
        }
        Collider[] cTargetsInViewRadius = Physics.OverlapSphere(cTotemRef.transform.position, m_fViewRadius, m_lmTargetMask);//Get colliders in radius that we are interested in
        foreach (Collider cCollider in cTargetsInViewRadius)
        {
            if (cCollider.CompareTag("Guard"))
            {
                return(false);
            }
        }
        return(true);
    }