Example #1
0
    public override bool CheckPreCondition(GameObject agent)
    {
        CS_IntelComponent goTotem = (CS_IntelComponent)UnityEngine.GameObject.FindObjectOfType(typeof(CS_IntelComponent));

        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_RadioComponent[] goDistractingObjects = (CS_RadioComponent[])UnityEngine.GameObject.FindObjectsOfType(typeof(CS_RadioComponent));
        CS_RadioComponent   goClosestDistraction = null;
        CS_IntelComponent   cIntel = GameObject.FindObjectOfType <CS_IntelComponent>();

        if (cIntel == 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 - cIntel.transform.position).magnitude;
            }
            else
            {
                // is this one closer than the last?
                float dist = (distraction.gameObject.transform.position - cIntel.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);
    }
Example #3
0
    public override bool CheckPreCondition(GameObject agent)
    {
        CS_IntelComponent cIntelRef = GameObject.FindObjectOfType <CS_IntelComponent>();

        if (cIntelRef == null)
        {
            return(false);
        }
        if (!cIntelRef.GetComponent <CS_KnowledgeComponent>().HasBeenLocated())
        {
            return(false);
        }
        Collider[] cTargetsInViewRadius = Physics.OverlapSphere(cIntelRef.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);
    }