Example #1
0
    public override void Awake()
    {
        agent = gameObject.GetComponent <Agent>();
        base.Awake();


        //is player close
        ConditionTargetClose ctc = new ConditionTargetClose();

        ctc.origin      = this.gameObject;
        ctc.target      = targetAux;
        ctc.minDistance = minDistance;

        //if player far away
        ConditionTargetFar ctf = new ConditionTargetFar();

        ctf.origin      = this.gameObject;
        ctf.target      = targetAux;
        ctf.maxDistance = minDistance;

        //is health higher than %
        ConditionAgentHealthHigher cahh = new ConditionAgentHealthHigher();

        cahh.target        = agent;
        cahh.targetPercent = targetPercent;

        //is both above true
        ConditionAnd ca = new ConditionAnd();

        ca.conditionA = ctc;
        ca.conditionB = cahh;

        ConditionAnd ca2 = new ConditionAnd();

        ca2.conditionA = ctf;
        ca2.conditionB = cahh;

        //transition to wander state
        State      st         = GetComponent <StateWander>();
        Transition transition = new Transition();

        transition.condition = ca;
        transition.target    = st;
        transitions.Add(transition);

        //transition to seek state
        State      st2         = GetComponent <StateSeek>();
        Transition transition2 = new Transition();

        transition2.condition = ca2;
        transition2.target    = st2;
        transitions.Add(transition2);
    }
Example #2
0
    public override void Awake()
    {
        base.Awake();
        ConditionTargetFar ctf = new ConditionTargetFar();

        ctf.origin      = this.gameObject;
        ctf.target      = targetToFollow;
        ctf.maxDistance = 7f;
        State      st         = GetComponent <StateIdle>();
        Transition transition = new Transition();

        transition.condition = ctf;
        transition.target    = st;
        transitions.Add(transition);
    }