// Update is called once per frame void Update() { switch (currState) { case GameState_Enum.STATE_CIRCLESHOWING: StateFunc.CircleShowing(); break; case GameState_Enum.STATE_INCIRCLE: StateFunc.InCircle(); break; case GameState_Enum.STATE_OUTCIRCLE: StateFunc.OutCircle(); break; case GameState_Enum.STATE_TRIALSUCCEED: StateFunc.TaskSucceed(); break; case GameState_Enum.STATE_TRIALFAIL: StateFunc.TaskFail(); break; case GameState_Enum.STATE_BREAK: StateFunc.Break(); break; case GameState_Enum.STATE_NULL: break; } }
public static Result Change(StateFunc nextFunc) { return(new Result() { nextFunc = nextFunc }); }
public void Add(T stateId, StateFunc onEnter = null, StateFunc onUpdate = null, StateFunc onLeave = null) { // 枚举类型内部是整型, int的hashcode就是其本身, 因此枚举值的hashcode就是其对应的整型值 int int_id = stateId.GetHashCode(); m_States.Add(int_id, new State(int_id, onEnter, onUpdate, onLeave)); }
//El primer parámetro es la nueva función que queremos asignar al delegate, el segundo es el tiempo. public void ChangeState(StateFunc newState,float newtimer) { stateStartTime=Time.time; initVar=true; timer=newtimer; stateAction = newState; }
public SimpleState(TId id, StateFunc enter, StateFunc update, StateFunc leave) { this.id = id; this.Enter = enter; this.Update = update; this.Leave = leave; }
public State(T id, StateFunc enter, StateFunc update, StateFunc leave) { Id = id; Enter = enter; Update = update; Leave = leave; }
public State(int id, StateFunc enter = null, StateFunc update = null, StateFunc leave = null) { m_Id = id; m_OnEnter = enter; m_OnUpdate = update; m_OnLeave = leave; }
private static StateResult ToState(StateFunc state, string description = null) { return(new StateResult { NextState = state, Description = description }); }
public void Run() { while (true) { stateFunc = stateFunc(); if (stateFunc == Completed) { break; } } }
//注册状态 public void RegistState(T state, StateFunc.EnterFunc enter, StateFunc.UpdateFunc update, StateFunc.ExitFunc exit) { StateFunc func = new StateFunc { enterFunc = enter, updateFunc = update, exitFunc = exit }; this.m_StateFunc.Add(state, func); //Debug.Log("State:" + state); }
// Update is called once per frame void Update() { if (nextStateFunc_ != null) { var next = nextStateFunc_; nextStateFunc_ = null; stateFunc_ = next; stateFrameCount_ = 0; } stateFunc_(this); stateFrameCount_++; }
// Update is called once per frame void Update() { if (EMG.IsConnected()) { EMG.Update(); } switch (currState) { case GameState_Enum.STATE_CMD2ROBOT: StateFunc.Cmd2Robot(); break; case GameState_Enum.STATE_MOVE2START: StateFunc.Move2Start(); break; case GameState_Enum.STATE_TRIALSTART: StateFunc.TrialStart(); break; case GameState_Enum.STATE_INCIRCLE: StateFunc.InCircle(); break; case GameState_Enum.STATE_OUTCIRCLE: StateFunc.OutCircle(); break; case GameState_Enum.STATE_TRIALSUCCEED: StateFunc.TaskSucceed(); break; case GameState_Enum.STATE_BREAK: StateFunc.Break(); break; case GameState_Enum.STATE_BLOCKSET: StateFunc.BlockSet(); break; case GameState_Enum.NULL: break; } }
public void Update(T owner) { var evt = new StateEvent() { owner = owner, sm = this, }; if (nextState_ != null) { curState_ = nextState_; nextState_ = null; evt.type = StateMachineEventType.Enter; time = 0f; curState_(evt); } evt.type = StateMachineEventType.Update; nextState_ = curState_(evt); time += Time.deltaTime; }
public void Run(string input) { _input = input; _start = 0; _pos = 0; _line = 1; _items = new List <Item>(); try { StateFunc state = LexFunc.Start(this); while (state != null) { state = state(this); } } catch (Exception ex) { Error(String.Format("Exception occured: {0}", ex)); } }
public void Process() { if (StateFunc == null) { return; } var state = StateFunc.Invoke(hud); if (state == LastState) { return; } if (state == DefaultState && ExitFunc != noop) { ExitFunc(hud); } if (state != DefaultState && EnterFunc != noop) { EnterFunc(hud); } LastState = state; }
public void Update(IController control, Event e, ref AirlockStatus status) { if (state == null || e == Event.RESET) { state = IDLE; stateTime = DateTime.UtcNow; Update(control, Event.INIT, ref status); if (e == Event.RESET) { return; } } var ctx = new StateCtx { Event = e, Status = status, Control = control, Time = (DateTime.UtcNow - stateTime).TotalSeconds }; var result = state(ref ctx); if (result != null) { description = result.Value.Description; if (state != result.Value.NextState) { state = result.Value.NextState; stateTime = DateTime.UtcNow; Update(control, Event.INIT, ref status); } } }
internal StateM(StateFunc <S, A> func) { Func = func; }
protected Job(string name) { this.name = name; stateFunc = InitialState; }
public State(StateFunc enter, StateFunc exit, StateFunc main) { enterState = enter; exitState = exit; state = main; }
public State(StateFunc main) { state = main; }
protected StateFunc Completed() { stateFunc = Completed; return(Completed); }
public StateMachine(StateFunc firstState) { nextState_ = firstState; }
public void Add(T id, StateFunc enter, StateFunc update, StateFunc leave) { m_States.Add(id, new State(id, enter, update, leave)); }
// Use this for initialization void Start() { nextStateFunc_ = stateInit; }
public FSM(StateFunc startStateMainFunc) { stack = new List <State> { new State(startStateMainFunc) }; }