Example #1
0
        ///Enter a state providing the state itself
        public bool EnterState(FSMState newState)
        {
            if (!isRunning){
                Debug.LogWarning("Tried to EnterState on an FSM that was not running", this);
                return false;
            }

            if (newState == null){
                Debug.LogWarning("Tried to Enter Null State");
                return false;
            }
            /*
            if (currentState == newState){
                Debug.Log("Trying entering the same state");
                return false;
            }
            */
            if (currentState != null){
                currentState.Finish();
                currentState.Reset();
                if (CallbackExit != null)
                    CallbackExit(currentState);

                //for editor..
                foreach (var inConnection in currentState.inConnections)
                    inConnection.connectionStatus = Status.Resting;
                ///
            }

            previousState = currentState;
            currentState = newState;
            currentState.Execute(agent, blackboard);
            if (CallbackEnter != null)
                CallbackEnter(currentState);
            return true;
        }
 public GUIPort(FSMState parent, Vector2 pos)
 {
     this.parent = parent;
     this.pos = pos;
 }
Example #3
0
 public GUIPort(FSMState parent, Vector2 pos)
 {
     this.parent = parent;
     this.pos    = pos;
 }
Example #4
0
 protected override void OnGraphPaused()
 {
     lastState = currentState;
 }
Example #5
0
 protected override void OnGraphStoped()
 {
     lastState    = null;
     currentState = null;
 }
Example #6
0
 protected override void OnGraphPaused()
 {
     previousState = currentState;
     currentState  = null;
 }
Example #7
0
 protected override void OnGraphStoped()
 {
     previousState = null;
     currentState  = null;
 }
Example #8
0
        ///Enter a state providing the state itself
        public bool EnterState(FSMState newState)
        {
            if (!isRunning){
                Debug.LogWarning("Tried to EnterState on an FSM that was not running", this);
                return false;
            }

            if (newState == null){
                Debug.LogWarning("Tried to Enter Null State");
                return false;
            }

            if (currentState != null){

                if (CallbackExit != null){
                    CallbackExit(currentState);
                }

                currentState.Finish();
                currentState.Reset();

                #if UNITY_EDITOR //Done for visualizing in editor
                for (var i = 0; i < currentState.inConnections.Count; i++)
                    currentState.inConnections[i].connectionStatus = Status.Resting;
                #endif
            }

            previousState = currentState;
            currentState = newState;

            if (CallbackEnter != null){
                CallbackEnter(currentState);
            }

            currentState.Execute(agent, blackboard);
            return true;
        }
Example #9
0
 protected override void OnGraphStoped()
 {
     previousState = null;
     currentState = null;
 }
Example #10
0
 protected override void OnGraphPaused()
 {
     previousState = currentState;
     currentState = null;
 }