public void PerformTransition(TRANSITION transition) { if (transition == TRANSITION.NullTransition) { WKStaticFunction.WKMessageError("the transition is null"); return; } STATE_ID stateID = _CurrentState.GetState(transition); if (stateID == STATE_ID.NullStateID) { WKStaticFunction.WKMessageError("the state of transition is null ::" + _CurrentState.ID.ToString() + transition.ToString()); return; } _CurrentStateID = stateID; STATE_ID previousState = _CurrentState.ID; foreach (FSMState state in _States) { if (state.ID == _CurrentStateID) { _CurrentState.OnLeave(); _CurrentState = state; _CurrentState._PreviousState = previousState; _CurrentState.OnEnter(); break; } } }
public void AddState(FSMState stateToAdd) { if (stateToAdd == null) { WKStaticFunction.WKMessageError("there is no state to add"); } stateToAdd.SetFSMCaller(_Caller); if (_States.Count == 0) { _States.Add(stateToAdd); _CurrentState = stateToAdd; _CurrentStateID = stateToAdd.ID; _CurrentState.OnEnter(); return; } foreach (FSMState state in _States) { if (state.ID == stateToAdd.ID) { WKStaticFunction.WKMessageError("state is already there"); return; } } _States.Add(stateToAdd); }
// set the transition so the things in the app gonna call this to transition from one state //To another public void SetTransition(TRANSITION transition) { if (_FSM != null) { _FSM.PerformTransition(transition); } else { WKStaticFunction.WKMessageError("there is no fsm system in the app"); MakeFSM(); } }
public static ARModal Instance() { if (_Instance == null) { _Instance = GameObject.FindObjectOfType <ARModal>(); if (_Instance == null) { WKStaticFunction.WKMessageError("there is no ARModal in the system"); } } return(_Instance); }
public void DeleteTransition(TRANSITION transition) { if (transition == TRANSITION.NullTransition) { WKStaticFunction.WKMessageError("The Transition is null, or not fully initialized"); return; } if (_Map.ContainsKey(transition)) { _Map.Remove(transition); return; } WKStaticFunction.WKMessageLog("The Transition is not on the transition _Map"); }
public void DeleteState(STATE_ID stateID) { if (stateID == STATE_ID.NullStateID) { WKStaticFunction.WKMessageError("the state id is null"); return; } foreach (FSMState state in _States) { if (state.ID == stateID) { _States.Remove(state); return; } } WKStaticFunction.WKMessageError("the state is not found in the fsm map"); }
void Awake() { if (Instance == null) { Instance = this; if (Instance == null) { Instantiate(Instance); WKStaticFunction.WKMessageError("error when trying to create singleton"); } DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public void AddTransition(TRANSITION Transition, STATE_ID StateID) { if (Transition == TRANSITION.NullTransition) { WKStaticFunction.WKMessageError("The Transition is error"); return; } if (StateID == STATE_ID.NullStateID) { WKStaticFunction.WKMessageError("The State is error"); return; } if (_Map.ContainsKey(Transition)) { WKStaticFunction.WKMessageError("The FSM already have this transition for state"); return; } _Map.Add(Transition, StateID); }