Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        // Preps reference to the scary object sense, which knows when a scary
        // object has been found, and what the scary object is.
        _sense = GetComponentInChildren <ScaryObjectSense>();

        // Ready the Finite State Machine.  We do this by passing the State Machine
        // construct a list of States, which are pairs of a Condition method name,
        // and a Behavior method name that gets fired if A) the condition holds true,
        // and B) the condition has priority.  A condition has priority if it's the
        // last condition to be true during an EvaluateState() call.
        _states = new StateMachine(new List <State> {
            new State(DefaultCondition, PrepareNewAction),
            new State(IsPerformingTask, KeepPerformingTask),
            new State(HasSeenScaryObject, FleeFromScaryObject)
        });
    }
    // Use this for initialization
    void Start()
    {
        // Preps reference to the scary object sense, which knows when a scary
        // object has been found, and what the scary object is.
        _sense = GetComponentInChildren<ScaryObjectSense>();

        // Ready the Finite State Machine.  We do this by passing the State Machine
        // construct a list of States, which are pairs of a Condition method name,
        // and a Behavior method name that gets fired if A) the condition holds true,
        // and B) the condition has priority.  A condition has priority if it's the
        // last condition to be true during an EvaluateState() call.
        _states = new StateMachine(new List<State> {
            new State(DefaultCondition, PrepareNewAction),
            new State(IsPerformingTask, KeepPerformingTask),
            new State(HasSeenScaryObject, FleeFromScaryObject)
        });
    }