public void addState(STATEMACHINE_NAME machineName, int stateType, StateBase state) { StateMachine val = null; mStateMachineMap.TryGetValue(machineName, out val); val.addState(stateType, state); }
public void ActivateState(StateBase s) { if (activeState != null) activeState.OnDeactivateState(); activeState = s; s.OnActivateState(); }
/// <summary> /// 切换状态 /// </summary> /// <param name="state"></param> public void ChangeState(StateBase state) { if (state == this.m_CurState) return; this.m_CurState.Exit(); this.m_PreState = this.m_CurState; state.Enter(); this.m_CurState = state; }
/// <summary> /// 切换状态 /// </summary> /// <param name="AIState"></param> public void ChangeState(AIStateType AIState) { if (AIState == this.m_CurState.AIState) return; this.m_CurState.Exit(); this.m_PreState = this.m_CurState; this.m_CurState = this.GetState(AIState); this.m_CurState.Enter(); }
public SearchNode Find(StateBase state) { if (!_hashByState.ContainsKey(state) || _hashByState[state].Count == 0) { return null; } return _hashByState[state].First(); }
//Replace Top Most State With A New State By Reference public void ChangeState(StateBase nextState) { _CurrentState.OnExit(); //Call state OnExit() nextState.PrevState = _CurrentState.PrevState; //set nextState's PrevState to the Previous State in line _CurrentState.PrevState = null; //Empty the old states PrevState _CurrentState = nextState; //Set the _CurrentState to NextState _CurrentState.PrevState.NextState = _CurrentState; //Set the Previous state's NextState to the new _CurrentState _CurrentState.OnEnter(); //call the new _CurrentState's OnEnter() }
public void addState(int stateType, StateBase state) { StateBase val = null; if(mStateMap.TryGetValue(stateType, out val) == true) { return; } //mStateMap.insert(std::make_pair(stateType, state)); mStateMap.Add(stateType, state); }
void Start() { m_gameStates = new StateBase<GameManager>[(int)GameManagerState.GMS_Length]; m_gameStates[(int)GameManagerState.GMS_Logo] = new LogoScene(); m_gameStates[(int)GameManagerState.GMS_IntroMenu] = new IntroMenuScene(); m_gameStates[(int)GameManagerState.GMS_InGame] = new InGameScene(); m_gameStates[(int)GameManagerState.GMS_AdShow] = new LevelOutroScene(); QualitySettings.vSyncCount = 1; Application.targetFrameRate = 30; setNextState(); }
//Remove Top State From Stack public void PopState() { if (_CurrentState.PrevState == null) { Debug.Log("FSM Error: Trying to pop an empty cache"); return; } _CurrentState.OnExit(); _CurrentState = _CurrentState.PrevState; _CurrentState.PrevState = null; _CurrentState.NextState = null; _CurrentState.OnWakeUp(); }
public void SetState(StateBase state, bool canGoBack = true) { if (canGoBack) { if (_currentState != null) { _previousStates.Push(_currentState); } } Debug.Log("Try to set state: " + state.GetType().Name); // StartCoroutine(SetStateCoroutine(state)); }
/// <summary> /// 发送文件 /// </summary> /// <param name="fileLable">文件标签</param> /// <param name="fileName">文件地址</param> /// <param name="stateOne">StateBase</param> /// <returns>形成之后的数据</returns> internal byte[] Send(ref int fileLable, string fileName, StateBase stateOne) { int fileLenth = 0; FileStream fs; try { fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); fileLenth = (int)fs.Length; } catch (Exception Ex) { throw new Exception(Ex.Message); } fileLable = RandomPublic.RandomNumber(16787); var fileState = new FileState(fileLable, fileLenth, fileName, fs); fileState.StateOne = stateOne; FS.Add(fileState); byte[] haveByte = EncryptionDecryptFile.FileHeadEncryption(fileState); return(haveByte); }
public SimpleDatum Preprocess(StateBase s, bool bUseRawInput) { SimpleDatum sd = new SimpleDatum(s.Data, true); if (bUseRawInput) { return(sd); } if (m_sdLast == null) { sd.Zero(); } else { sd.Sub(m_sdLast); } m_sdLast = s.Data; return(sd); }
/// <summary> /// Run a set of iterations and return the resuts. /// </summary> /// <param name="nN">Specifies the number of samples to run.</param> /// <param name="strRunProperties">Optionally specifies properties to use when running.</param> /// <param name="type">Returns the data type contained in the byte stream.</param> /// <returns>The results of the run containing the action are returned as a byte stream.</returns> public byte[] Run(int nIterations, out string type) { IxTrainerCallbackRNN icallback = m_icallback as IxTrainerCallbackRNN; if (icallback == null) { throw new Exception("The Run method requires an IxTrainerCallbackRNN interface to convert the results into the native format!"); } StateBase s = getData(Phase.RUN, -1); int nIteration = 0; List <float> rgResults = new List <float>(); while (!m_brain.Cancel.WaitOne(0) && (nIterations == -1 || nIteration < nIterations)) { // Preprocess the observation. SimpleDatum x = m_brain.Preprocess(s, m_bUseRawInput); // Forward the policy network and sample an action. float[] rgfAprob; int action = m_brain.act(x, s.Clip, out rgfAprob); rgResults.Add(s.Data.TimeStamp.ToFileTime()); rgResults.Add((float)s.Data.RealData[0]); rgResults.Add(action); // Take the next step using the action StateBase s_ = getData(Phase.RUN, action); nIteration++; } ConvertOutputArgs args = new ConvertOutputArgs(nIterations, rgResults.ToArray()); icallback.OnConvertOutput(args); type = args.RawType; return(args.RawOutput); }
/// <summary> /// ステートの変更. /// </summary> /// <param name="stateType">変更後のステート</param> public void ChangeState(int stateType) { // 仮 ここ、直す必要がある。途中で呼び出された場合に、流れがおかしくなる可能性がある if (ManageState != MachineState.AfterInit && ManageState != MachineState.UpdateMain) { Debug.Log("StateMachine::changeState"); Debug.Log((int)ManageState + " state isnt use changeState"); } if (NowState != null) { NextState = stateType; ManageState = MachineState.AfterMain; } else { StateBase val = null; StateMap.TryGetValue(stateType, out val); NowState = val; ManageState = MachineState.BeforeInit; } }
/// <summary> /// 今のステートを保存して、次回戻ってきた際に初期化処理を呼ばないようにしたステートの変更. /// </summary> /// <param name="stateType">変更後のステート</param> public void ChangeStateNowStatePause(int stateType) { if (ManageState != MachineState.AfterInit && ManageState != MachineState.UpdateMain) { Debug.Log("StateMachine::changeState"); Debug.Log(ManageState + " state isnt use changeState"); } if (NowState != null) { NowState.PauseEnable(); NextState = stateType; ManageState = MachineState.Release; // 即リリース状態にしているが、PAUSEをかけているので、リリースの処理は呼び出されない } else { StateBase val = null; StateMap.TryGetValue(stateType, out val); NowState = val; ManageState = MachineState.BeforeInit; } }
private void GoToState(StateBase state) { int idx = States.IndexOf(state); if (idx == -1) { throw new Exception("Error: Trying to go to unknown state"); } _index = idx; if (_currentState == null) { CurrentState = state; CurrentState.StateEnter(this); return; } var prev = _currentState; CurrentState = state; prev.StateExit(this); _currentState.StateEnter(this); }
public bool TryChangeState(EntityState state, StateArgsBase args) { if (state == GetCurState()) { return(curState.SameStateEnter(this, args)); } StateBase targetState = allStates[state]; if (targetState.ChechChangeState(this, args)) { if (curState != null) { curState.Exit(this); } curState = targetState; targetState.Enter(this, args); return(true); } else { return(false); } }
public void changeState(int stateType) { // 仮 ここ、直す必要がある。途中で呼び出された場合に、流れがおかしくなる可能性がある if (mManageState != MACHINE_STATE.AFTER_INIT && mManageState != MACHINE_STATE.UPDATE_MAIN) { Debug.Log("StateMachine::changeState"); Debug.Log((int)mManageState + " state isnt use changeState"); } if (mNowState != null) { mNextState = stateType; mManageState = MACHINE_STATE.AFTER_MAIN; } else { StateBase val = null; mStateMap.TryGetValue(stateType, out val); mNowState = val; mManageState = MACHINE_STATE.BEFORE_INIT; } }
/// <summary> /// Targets the visibility test. /// </summary> /// <param name="currentState">The current state of the agent.</param> /// <param name="visibilityCosineFactor">The visibility cosine factor.</param> /// <param name="cellularFloor">The cellular floor.</param> /// <returns>UV.</returns> public UV TargetVisibilityTest(StateBase currentState, double visibilityCosineFactor, CellularFloorBaseGeometry cellularFloor) { var vantageCell = cellularFloor.FindCell(currentState.Location); if (!this.AllVisibleCells.Contains(vantageCell.ID)) { return(null); } UV target = null; foreach (var cellID in this.ReferencedVantageCells[vantageCell.ID]) { UV targetCell = cellularFloor.FindCell(cellID); UV direction = targetCell - currentState.Location; direction.Unitize(); if (direction.DotProduct(currentState.Direction) >= visibilityCosineFactor) { target = targetCell; break; } } return(target); }
/// <summary> /// Determines whether a visual the event is raised. /// </summary> /// <param name="currentState">The current state of the agent.</param> /// <param name="visibilityCosineFactor">The visibility cosine factor.</param> /// <param name="cellularFloor">The cellular floor.</param> /// <returns><c>true</c> if visual the event is raised, <c>false</c> otherwise.</returns> public bool VisualEventRaised(StateBase currentState, double visibilityCosineFactor, CellularFloorBaseGeometry cellularFloor) { var vantageCell = cellularFloor.FindCell(currentState.Location); if (!this.AllVisibleCells.Contains(vantageCell.ID)) { return(false); } bool raised = false; foreach (var cellID in this.ReferencedVantageCells[vantageCell.ID]) { UV targetCell = cellularFloor.FindCell(cellID); UV direction = targetCell - currentState.Location; direction.Unitize(); if (direction.DotProduct(currentState.Direction) >= visibilityCosineFactor) { raised = true; break; } } return(raised); }
public void changeStateNowStatePause(int stateType) { if (mManageState != MACHINE_STATE.AFTER_INIT && mManageState != MACHINE_STATE.UPDATE_MAIN) { Debug.Log("StateMachine::changeState"); Debug.Log(mManageState + " state isnt use changeState"); } if (mNowState != null) { mNowState.pauseEnable(); mNextState = stateType; mManageState = MACHINE_STATE.RELEASE; // 即リリース状態にしているが、PAUSEをかけているので、リリースの処理は呼び出されない } else { StateBase val = null; mStateMap.TryGetValue(stateType, out val); mNowState = val; mManageState = MACHINE_STATE.BEFORE_INIT; } }
/// <summary> /// The Run method provides the main 'actor' loop that performs the following steps: /// 1.) Feed data into the network. /// 2.) either Test the network... /// 3.) ... or Train the network. /// </summary> /// <param name="phase">Specifies the phae.</param> /// <param name="nN">Specifies the number of iterations (based on the ITERATION_TYPE) to run, or -1 to ignore.</param> /// <param name="type">Specifies the iteration type (required = ITERATION).</param> /// <param name="step">Specifies the training step (used only during debugging).</param> /// <returns>The vocabulary built up during training and testing is returned.</returns> public void Run(Phase phase, int nN, ITERATOR_TYPE type, TRAIN_STEP step) { if (type != ITERATOR_TYPE.ITERATION) { throw new Exception("The TrainerRNN only supports the ITERATION type."); } StateBase s = getData(phase, -1); while (!m_brain.Cancel.WaitOne(0) && !s.Done) { if (phase == Phase.TEST) { m_brain.Test(s, nN); } else if (phase == Phase.TRAIN) { m_brain.Train(s, nN, step); } s = getData(phase, 1); } }
public void changeState(int stateType) { // 仮 ここ、直す必要がある。途中で呼び出された場合に、流れがおかしくなる可能性がある if (mManageState != MACHINE_STATE.AFTER_INIT && mManageState != MACHINE_STATE.UPDATE_MAIN ) { Debug.Log("StateMachine::changeState"); Debug.Log((int)mManageState + " state isnt use changeState"); } if(mNowState != null) { mNextState = stateType; mManageState = MACHINE_STATE.AFTER_MAIN; } else { StateBase val = null; mStateMap.TryGetValue(stateType, out val); mNowState = val; mManageState = MACHINE_STATE.BEFORE_INIT; } }
/* * 所有状态机均需要处理状态的转换 */ public void TransactionState(StateBase state) { /* * 状态退出的收尾工作 */ if (currentState != null) { currentState.OnExit(this); } /* * 切换状态 */ currentState = state; /* * 调用状态的构造函数 */ currentState.OnEnter(this); }
private void terminateRegionGeneration_Enter() { this.unregisterRegionGenerationEvents(); if (this._pnts.Count > 1) { Polygon polygon = new Polygon(); polygon.Points = this._polyline.Points.CloneCurrentValue(); polygon.Stroke = Brushes.Black; polygon.StrokeThickness = this._stroke_thickness; polygon.StrokeMiterLimit = 0; Brush brush = Brushes.LightBlue.Clone(); brush.Opacity = .3; polygon.Fill = brush; this.Children.Add(polygon); this._barrier = new BarrierPolygon(this._pnts.ToArray()); if (!this._barrier.IsConvex()) { MessageBox.Show("The destination region should be a convex polygon. \nTry again...", "Concavity Problem", MessageBoxButton.OK, MessageBoxImage.Information); this._barrier = null; } else { this._stateBase = new StateBase(this._barrier.GetCenter(), new UV(0, 0)); this._fieldGenerator._addDirection.IsEnabled = true; } } this.Children.Remove(this._polyline); this.Children.Remove(this._line); this._polyline.Points.Clear(); this._polyline = null; this._line = null; this._host.Menues.IsEnabled = true; this._host.UIMessage.Visibility = System.Windows.Visibility.Collapsed; this._host.Cursor = Cursors.Arrow; this._fieldGenerator.ShowDialog(); }
protected void RegisterState(StateBase state) { var stateType = state.GetType(); bool replaced = false; for (int i = 0; i < states.Count; i++) { var otherState = states[i]; var otherType = otherState.GetType(); if (stateType.IsSubclassOf(otherType)) { states[i] = state; replaced = true; } } state.Initialize(this); if (replaced == false) { states.Add(state); } }
/// <summary> /// 実行ステートを遷移する /// </summary> public void Next() { // ステート離脱処理 if (_state != null) { _state.OnStateExit(); } _offset++; if (_offset < _stateList.Count) { // 次のステートがあるとき // そのまま遷移 _state = _stateList[_offset]; _state.OnStateEnter(); } else { // 次のステートがないとき // ステートをNULLに _state = null; } }
static int CancelInvoke(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1) { StateBase obj = LuaScriptMgr.GetNetObject <StateBase>(L, 1); obj.CancelInvoke(); return(0); } else if (count == 2) { StateBase obj = LuaScriptMgr.GetNetObject <StateBase>(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 2); obj.CancelInvoke(arg0); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: StateBase.CancelInvoke"); } return(0); }
/// <summary> /// 最基础的Udp异步发送 /// </summary> /// <param name="stateBase">StateBase</param> /// <param name="bytes">数据</param> internal override void Send(StateBase stateBase, byte[] bytes) { if (stateBase == null) { return; } EndPoint remoteEndPoint = stateBase.IpEndPoint; byte[] sendDate = UdpPortSetGet.SetPort(Port, bytes); try { state.WorkSocket.BeginSendTo(sendDate, 0, sendDate.Length, 0, remoteEndPoint, SendCallback, state.WorkSocket); } catch { } #region 异步发送的另一种方法 //try //{ // EndPoint remoteEndPoint = (EndPoint)stateBase.IpEndPoint; // state.SendSocketArgs.SetBuffer(bytes, 0, bytes.Length); // state.SendSocketArgs.RemoteEndPoint = remoteEndPoint; // bool bb= state.WorkSocket.SendToAsync(state.SendSocketArgs); // if (bb == false) // { // state.SendSocketArgs = new SocketAsyncEventArgs(); // Send(stateBase, bytes); // } //} //catch {} #endregion }
static int StopCoroutine(IntPtr L) { int count = LuaDLL.lua_gettop(L); Type[] types0 = { typeof(StateBase), typeof(Coroutine) }; Type[] types1 = { typeof(StateBase), typeof(IEnumerator) }; Type[] types2 = { typeof(StateBase), typeof(string) }; if (count == 2 && LuaScriptMgr.CheckTypes(L, types0, 1)) { StateBase obj = LuaScriptMgr.GetNetObject <StateBase>(L, 1); Coroutine arg0 = LuaScriptMgr.GetNetObject <Coroutine>(L, 2); obj.StopCoroutine(arg0); return(0); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, types1, 1)) { StateBase obj = LuaScriptMgr.GetNetObject <StateBase>(L, 1); IEnumerator arg0 = LuaScriptMgr.GetNetObject <IEnumerator>(L, 2); obj.StopCoroutine(arg0); return(0); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, types2, 1)) { StateBase obj = LuaScriptMgr.GetNetObject <StateBase>(L, 1); string arg0 = LuaScriptMgr.GetString(L, 2); obj.StopCoroutine(arg0); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: StateBase.StopCoroutine"); } return(0); }
private void getRawData(StateBase s) { int nTestLen = (int)(s.Data.ItemCount * 0.2); int nTrainLen = s.Data.ItemCount - nTestLen; if (s.Data.IsRealData) { m_bIsDataReal = true; m_rgdfTestData = new double[nTestLen]; m_rgdfTrainData = new double[nTrainLen]; Array.Copy(s.Data.GetData <double>(), 0, m_rgdfTrainData, 0, nTrainLen); Array.Copy(s.Data.GetData <double>(), nTrainLen, m_rgdfTestData, 0, nTestLen); } else { m_bIsDataReal = false; m_rgTestData = new byte[nTestLen]; m_rgTrainData = new byte[nTrainLen]; Array.Copy(s.Data.ByteData, 0, m_rgTrainData, 0, nTrainLen); Array.Copy(s.Data.ByteData, nTrainLen, m_rgTestData, 0, nTestLen); } }
public void GoToState(string stateId) { _activeState?.SetStateActive(false); _activeState = _states.FirstOrDefault(x => x.StateID == stateId); _activeState?.SetStateActive(true); }
public FSM() { _StateCache = new Dictionary<System.Enum, StateBase>(); //Registry Of All Available States, Sorted By Enum Int _CurrentState = new StateBase(); }
//Method that switches the active state to a new state public void SwitchState(StateBase newState) { activeState = newState; }
public VaccineState(StateBase stateBase) { StateBase = stateBase; VaccineData = new List <VaccineDay>(); }
public virtual void Init(StateBase parent) { }
public void RemoveState(StateBase <T> state) { allStates.Remove(GetStateName(state)); }
/// <summary> /// Generic search algorithm /// </summary> private static SearchResult GenericSearch(StateBase initialState, StateBase goalState, string algName, OpenListComparator comparator, CostFunc cost, IHeuristic heuristic, int? depthLimit = null) { var openList = new OpenList(comparator); var closedList = new ClosedList(); var cache = new HeuristicCache(goalState, heuristic); var nodesGenerated = 0; var nodesPrevGenerated = 0; // add initial node to open list openList.Push(new SearchNode(cost, initialState, null, null, cache.Evaluate)); while (true) { // if nothing on open list, fail if (openList.Count == 0) { return new SearchResult(null, nodesGenerated, nodesPrevGenerated, openList.Count, closedList.Count, algName, heuristic); } // get next node to expand var node = openList.Pop(); closedList.Push(node); // if at goal state, success if (node.State.Equals(goalState)) { return new SearchResult(node, nodesGenerated, nodesPrevGenerated, openList.Count, closedList.Count, algName, heuristic); } // if at depth limit, don't generate successors if (depthLimit != null && node.Depth == depthLimit) { continue; } var daughters = node.Successors(cost, cache.Evaluate); foreach (var daughter in daughters) { nodesGenerated++; // if this state is already in open list, replace old node with new node if g-hat is better var foundInOpen = openList.Find(daughter.State); if (foundInOpen != null) { nodesPrevGenerated++; if (daughter.Ghat < foundInOpen.Ghat) { openList.Replace(foundInOpen, daughter); } } else { // else if this state is already in closed list, move from closed to open if g-hat is better var foundInClosed = closedList.Find(daughter.State); if (foundInClosed != null) { nodesPrevGenerated++; if (daughter.Ghat < foundInClosed.Ghat) { openList.Push(daughter); closedList.Remove(foundInClosed); } } else { // else didn't find in open or closed, add to open openList.Push(daughter); } } } } }
/// <summary> /// 设置状态 /// </summary> /// <param name="AIState"></param> public void SetCurState(AIStateType AIState) { this.m_CurState = this.GetState(AIState); this.m_CurState.Enter(); }
internal NewStatus(TwitterAccount account) { this.Text = ""; this.InReplyTo = null; this.MediaPaths = new ObservableSynchronizedCollection<string>(); this.MediaPaths.CollectionChanged += (sender, e) => this.RaiseAllPropertyChanged(); this._Account = account; this._State = new Normal(account); // 自身のプロパティ変更通知イベントを監視 // Text の変更を検出し、最後の変更から 1000 ミリ秒間変更がなければ、入力中のツイートを分析 this.analyzer = Observable.FromEventPattern<PropertyChangedEventHandler, PropertyChangedEventArgs>( h => this.PropertyChanged += h, h => this.PropertyChanged -= h) .Where(e => e.EventArgs.PropertyName == "Text") .Throttle(TimeSpan.FromMilliseconds(1000)) .Subscribe(_ => this.AnalyzeCore()); }
public void setupStates() { m_states = new StateBase<Enemy>[(int)StateEnum.SE_Length]; m_states[(int)StateEnum.SE_IDLE] = new EnemyIdleState(this); m_states[(int)StateEnum.SE_MOVEUP] = new EnemyMoveState(this); m_states[(int)StateEnum.SE_EAT] = new EnemyEatingState(this); m_states[(int)StateEnum.SE_DEAD] = new EnemyDeadState(this); m_curState = (int)StateEnum.SE_IDLE; }
public override bool Equals(StateBase other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } if (other as PuzzleState == null) { return false; } return other.GetHashCode().Equals(GetHashCode()); }
private StateViewModel ToStateViewModel(StateBase state) { var notfound = state as AccountNotSelected; if (notfound != null) { return new AccountNotSelectedViewModel(notfound); } var normal = state as Normal; if (normal != null) { return new NormalViewModel(normal); } var reply = state as Reply; if (reply != null) { return new ReplyViewModel(reply) { DeleteAction = () => this.NewStatus.Clear(this.NewStatus.Text), }; } var mReply = state as MultiReply; if (mReply != null) { return new MultiReplyViewModel(mReply); } return null; }
private void initStates() { m_states = new StateBase<EnemyTarget>[(int)StateEnum.SE_Length]; m_states[(int)StateEnum.SE_HAPPY] = new TargetHappy(this); m_states[(int)StateEnum.SE_OK] = new TargetOk(this); m_states[(int)StateEnum.SE_SAD] = new TargetSad(this); m_states[(int)StateEnum.SE_EATEN] = new TargetEaten(this); m_states[(int)StateEnum.SE_ATTACKED] = new TargetAttacked(this); m_states[(int)StateEnum.SE_WIN] = new TargetWin(this); }
public override bool CanEnter(StateBase currentStateBase) { return(true); }
public Searcher(StateBase initialState, StateBase goalState) { _initialState = initialState; _goalState = goalState; }
public void AddState(StateBase <T> state) { allStates.Add(GetStateName(state), state); }
/// <summary> /// Sets current state and loads new scene if needed /// </summary> /// <param name="type"></param> /// <returns></returns> private IEnumerator SetStateCoroutine(StateBase state) { // if (_currentState != null) { _currentState.Deactivate(); _currentState = null; } _currentState = state; if (!string.IsNullOrEmpty(_currentState.StateSceneName)) { if (Application.loadedLevelName != _currentState.StateSceneName || _currentState.ForceReload) { string curState = _currentState.StateSceneName; yield return null; _aoLoadScene = Application.LoadLevelAsync(curState); Debug.Log("Start load: " + _currentState.StateSceneName); yield return _aoLoadScene; Debug.Log("End load: " + _currentState.StateSceneName); _aoLoadScene = null; } } _currentState.Activate(); }
private string GetStateName(StateBase <T> state) { Type stateType = state.GetType(); return(stateType.ToString()); }
/// <summary> /// adds previous state without setting current /// </summary> public void InjectPreviousState(StateBase type) { _previousStates.Push(type); }
/// <summary> /// sets the current state /// </summary> /// <param name="state">the state to set as current</param> public void setCurrentState(StateBase state) { currentState = state; }
internal StateChangedEventArgs(StateBase state) { this.State = state; }
public void StartArena() { Application.LoadLevel("Arena"); //WaitForLevelLoad (); activeState = new ArenaState (this); }
/// <summary> /// Set state /// </summary> public void SetState(EStateId stateId) { print("SetState = " + stateId); if(!_states.ContainsKey(stateId)) { print ("State " + stateId + " does not exist"); return; } if(_currentState != null) { if(_currentState.StateId != stateId) { _currentState.Deactivate(); _currentState = null; } } StateBase nState = _states[stateId]; _currentState = nState; _currentState.Activate(); }
// Use this for initialization void Start() { activeState = new MenuState (this); networkManager = gameObject.GetComponent<PunNetworkManager>(); }
void SetNextState(StateBase s) { StateManager.Instance.ActivateState(s); }
public Context(StateBase state) { State = state; Console.WriteLine("Create object of context class with initial State."); }
/// <summary> /// Awake this instance. /// </summary> void Awake() { // instance = this; // mStates = new List<StateBase>(); mStates.Add( new StateMenu() ); mStates.Add( new StateEnd() ); foreach ( StateBase sb in mStates ) { if ( sb.Name == Application.loadedLevelName ) { mCurrentState = sb; } } if ( mCurrentState == null ) { mCurrentState = new StateLevel(); } mCurrentState.Awake(); }
private protected virtual void CloneCore(StateBase state) { state.WindowedBuffer = WindowedBuffer.Clone(); state.InitialWindowedBuffer = InitialWindowedBuffer.Clone(); }
public Context(StateBase s) //use an initial state to construct the Context instance { this.State = s; }