Esempio n. 1
0
        public virtual void StartNewState(MAIState newState)
        {
            StateLastTime = Time.time;      //Store the last time the Animal made a transition


            if (currentState != null && currentState != newState)
            {
                currentState.Finish_Tasks(this);                 //Finish all the Task on the Current State
                //   currentState.Finish_Decisions(this);             //Finish all the Decisions on the Current State
            }

            currentState = newState;                            //Set a new State

            ResetVarsOnNewState();

            OnAIStateChanged.Invoke(currentState.ID);
            currentState.Start_AIState(this);                   //Start all Tasks on the new State
            currentState.Prepare_Decisions(this);               //Start all Tasks on the new State
        }
Esempio n. 2
0
        void StartNewState(MAIState newState)
        {
            StateLastTime = Time.time;           //Store the last time the Animal made a transition

            currentState.Finish_Tasks(this);     //Finish all the Task on the Current State
            currentState.Finish_Decisions(this); //Finish all the Decisions on the Current State

            currentState = newState;             //Set a new State

            PrepareVarsOnNewState();

            currentState.Start_Taks(this);                      //Start all Tasks on the new State
            currentState.Prepare_Decisions(this);               //Start all Tasks on the new State


            foreach (var tasks in currentState.tasks)         //Invoke the Task Events in case anyone wants to listen
            {
                int taskID = tasks.MessageID;
                if (taskID != 0)
                {
                    OnTaskStarted.Invoke(taskID);
                }
            }
        }