Exemple #1
0
        public void PerformTransition(FSMTransistion trans)
        {
            // Check for NullTransition before changing the current state
            if (trans == FSMTransistion.None)
            {
                return;
            }

            // Check if the currentState has the transition passed as argument
            FSMStateID id = currentState.GetOutputState(trans);

            if (id == FSMStateID.None)
            {
                return;
            }


            // Update the currentStateID and currentState
            //currentStateID = id;
            foreach (FSMState state in fsmStates)
            {
                if (state.ID == id)
                {
                    // Store previous state and call exit method.
                    previousState = currentState;
                    previousState.Exit();

                    // Update current state and call enter method.
                    currentState = state;
                    currentState.Enter();

                    break;
                }
            }
        }
Exemple #2
0
 public PlayerOffScreenWithShapesRemainingReason(FSMTransistion identifier, IStateTransitioner controller,
                                                 IConsumerListener consumed, bool shapesRemaining, FSMStateID goToState)
     : base(identifier, goToState, controller)
 {
     m_Consumed = consumed;
     m_ShouldShapesBeRemaining = shapesRemaining;
     m_StatusListener          = new PlayerStatusChangeListener();
 }
Exemple #3
0
        public FSMReason(FSMTransistion transition, FSMStateID goToState, IStateTransitioner controller)
        {
            this.transition = transition;
            this.goToState  = goToState;
            m_Controller    = controller;

            m_DebugLogger = new FSMStateSwitchLogger(this);
        }
Exemple #4
0
        /// <summary>
        /// Deletes a transition, stateID pair from the transition map.
        /// </summary>
        public void DeleteTransition(FSMTransistion transition)
        {
            // Ensures valid transition.
            if (transition == FSMTransistion.None)
            {
                return;
            }

            // Ensure map contains transition before attempting delete.
            if (map.ContainsKey(transition))
            {
                map.Remove(transition);
                return;
            }
        }
Exemple #5
0
        /// <summary>
        /// Adds a transition, stateID pair to the transition map. Every transition called
        /// in the states Reason method should have a corresponding state id in the map.
        /// </summary>
        public void AddTransition(FSMTransistion transition, FSMStateID id)
        {
            // Ensure valid transition.
            if (transition == FSMTransistion.None || id == FSMStateID.None)
            {
                return;
            }

            // Ensure transition not already present in map.
            if (map.ContainsKey(transition))
            {
                return;
            }

            map.Add(transition, id);
        }
Exemple #6
0
        /// <summary>
        /// This method returns the state that would be transitioned into based on the FSMTransition.
        /// </summary>
        public FSMStateID GetOutputState(FSMTransistion transition)
        {
            // Ensures valid transition.
            if (transition == FSMTransistion.None)
            {
                return(FSMStateID.None);
            }

            // Ensure map contains transition before returning new state.
            if (map.ContainsKey(transition))
            {
                return(map [transition]);
            }

            // Transition not in map.
            return(FSMStateID.None);
        }
        /// <summary>
        /// Deletes a transition, stateID pair from the transition map.
        /// </summary>
        public void DeleteTransition(FSMTransistion transition)
        {
            // Ensures valid transition.
            if (transition == FSMTransistion.None)
            {
                Debug.LogError(SCRIPT_NAME + ": None transition is not allowed");
                return;
            }

            // Ensure map contains transition before attempting delete.
            if (map.ContainsKey(transition))
            {
                map.Remove(transition);
                return;
            }

            Debug.LogError(SCRIPT_NAME + ": transition passed was not on this State´s List | " + transition);
        }
        /// <summary>
        /// Adds a transition, stateID pair to the transition map. Every transition called
        /// in the states Reason method should have a corresponding state id in the map.
        /// </summary>
        public void AddTransition(FSMTransistion transition, FSMStateID id)
        {
            // Ensure valid transition.
            if (transition == FSMTransistion.None || id == FSMStateID.None)
            {
                Debug.LogWarning(SCRIPT_NAME + " : Null transition not allowed");
                return;
            }

            // Ensure transition not already present in map.
            if (map.ContainsKey(transition))
            {
                Debug.LogWarning(SCRIPT_NAME + ": transition is already inside the map | " + transition);
                return;
            }

            map.Add(transition, id);
        }
        /// <summary>
        /// This method returns the state that would be transitioned into based on the FSMTransition.
        /// </summary>
        public FSMStateID GetOutputState(FSMTransistion transition)
        {
            // Ensures valid transition.
            if (transition == FSMTransistion.None)
            {
                Debug.LogError(SCRIPT_NAME + ": None transition is not allowed");
                return(FSMStateID.None);
            }

            // Ensure map contains transition before returning new state.
            if (map.ContainsKey(transition))
            {
                return(map [transition]);
            }

            Debug.LogError(SCRIPT_NAME + ": transition passed to the State was not on the list | " + transition);

            // Transition not in map.
            return(FSMStateID.None);
        }
Exemple #10
0
        public void PerformTransition(FSMTransistion trans, Transform extraData)
        {
            // Check for NullTransition before changing the current state
            if (trans == FSMTransistion.None)
            {
                Debug.LogError(SCRIPT_NAME + ": Null transition is not allowed");
                return;
            }

            // Check if the currentState has the transition passed as argument
            FSMStateID id = currentState.GetOutputState(trans);

            if (id == FSMStateID.None)
            {
                Debug.LogError(SCRIPT_NAME + ": Current State does not have a target state for this transition");
                return;
            }


            // Update the currentStateID and currentState
            //currentStateID = id;
            foreach (FSMState state in fsmStates)
            {
                if (state.ID == id)
                {
                    // Store previous state and call exit method.
                    previousState = currentState;
                    previousState.Exit();

                    // Update current state and call enter method.
                    currentState = state;
                    currentState.Enter();

                    break;
                }
            }
        }
Exemple #11
0
 /// <summary>
 /// This performs a transistion from one state to another and is invoked in an individual states Reason method.
 /// </summary>
 public void SetTransistion(FSMTransistion transition)
 {
     m_StateMachine.PerformTransition(transition);
 }
Exemple #12
0
 /// <summary>
 /// This performs a transistion from one state to another and is invoked in an individual states Reason method.
 /// </summary>
 public void SetTransistion(FSMTransistion tran, Transform extraData = default(Transform))
 {
     _statemachine.PerformTransition(tran, extraData);
 }
Exemple #13
0
 public LevelEntryReason(FSMTransistion identifier, IStateTransitioner controller, bool shouldTransition, FSMStateID goToState)
     : base(identifier, goToState, controller)
 {
     m_ShouldTransition = shouldTransition;
 }