public void ChangeState(LoginStateCode eState) { Type type = Type.GetType("GameLogin.State." + eState.ToString()); if (type == null) { ClientLogger.Error("ChangeState:找不到登录状态类型 " + eState.ToString()); return; } LoginStateBase loginStateBase = Activator.CreateInstance(type) as LoginStateBase; if (loginStateBase == null) { ClientLogger.Error("ChangeState:无法实例化登录状态 " + eState.ToString()); return; } this._nextState = loginStateBase; }
public void OnUpdate() { if (!this.enable) { return; } if (this._nextState != null) { if (this._curState != null) { this._curState.OnExit(); } this._curState = this._nextState; this._nextState = null; if (this._curState != null) { this._curState.OnEnter(); } return; } if (this._curState != null) { this._curState.OnUpdate(); } if (this.lTask != null && this.lTask.Count > 0) { for (int i = this.lTask.Count - 1; i >= 0; i--) { this.lTask[i].Update(); if (!this.lTask[i].Valid) { this.lTask[i].Destroy(); this.lTask[i] = null; this.lTask.RemoveAt(i); } } } }
public void OnAwake() { LoginStateManager.m_instance = this; this._curState = null; this._nextState = null; }