/// <summary> /// Pauses a scene. /// A paused scene is continued to be rendered but is not updated. /// </summary> /// <param name="id">The ID of the scene.</param> public void PauseScene(int id) { // Check if the scene exists. if (scenes.ContainsKey(id)) { // Get scene as scene state. ISceneState state = (ISceneState)scenes[id]; // If scene is already paused or stopped, don't attempt to pause; return. if (state.State == SceneState.Paused || state.State == SceneState.Stopped) { return; } // Pause scene. IReadOnlyList <IEntity> entities = state.Pause(); // Remove entities from collision, input and update systems. foreach (IEntity entity in entities) { collisionSystem.RemoveEntity(entity.Id); inputSystem.RemoveEntity(entity.Id); updateSystem.RemoveEntity(entity.Id); } } }
public void SetState(ISceneState state) { if (_state != null) { _state.StateEnd(); //让 上一个状态 结束 } _state = state; if (isLoadScene) { _async = SceneManager.LoadSceneAsync(_state.SceneName); } else { isLoadScene = true; _state.StateStart(); _isStart = true; } _isStart = false; //场景加载成功后调用 //_state.StateStart(); //开始下一个状态 }
/// <summary> /// Sets up the object prior to rendering. /// </summary> /// <param name="scenestate"/> public void BeginFrameRendering(ISceneState scenestate) { foreach (SpriteContainer container in _containers.Keys) { if (container.RenderableMeshes.Count == _containers[container].Count && container.UpdateType == UpdateType.None) { continue; } container.Begin(); foreach (SpriteObject sprite in _containers[container]) { if (sprite.UpdateType == UpdateType.Automatic) { if (sprite.Material == null) { continue; } container.Add(sprite.Material, sprite.Size, sprite.Position, sprite.Rotation, sprite.Origin, sprite.UVSize, sprite.UVPosition, sprite.LayerDepth); } } container.End(); } }
public override void Update() { if (targetAsyncOperation != null && Mathf.Approximately(isDelayToLoadTime, 0f)) { if (targetAsyncOperation.progress < 0.89) { textProgress.text = (int)(targetAsyncOperation.progress * 100) + "%"; } else { textProgress.text = "100%"; isDelayToLoadTime = Time.time + 1; } } if (isDelayToLoadTime > 0 && isDelayToLoadTime < Time.time) { isDelayToLoadTime = 0; loadSceneAction = null; targetAsyncOperation.allowSceneActivation = true; targetAsyncOperation = null; StateController.SetState(targetState, ""); targetState = null; } }
//GameObject loadingscreen; //Slider slider; //private IEnumerator LoadAsynchronously(string LoadSceneName) //{ // loadingscreen.SetActive(true); // AsyncOperation operation = SceneManager.LoadSceneAsync(LoadSceneName); // while(!operation.isDone) // { // float process = Mathf.Clamp01(operation.progress / .9f); // slider.value = process; // yield return null; // } //} private IEnumerator LoadAsynchronously(string LoadSceneName, ISceneState State) { if (LoadSceneName != "") { gameLoop.loadingscreen.SetActive(true); AsyncOperation operation = SceneManager.LoadSceneAsync(LoadSceneName); while (!operation.isDone) { float process = Mathf.Clamp01(operation.progress / .9f); gameLoop.imgBar.fillAmount = process; yield return(null); } if (m_State != null) { m_State.StateEnd(); } //設定 m_State = State; } else { yield return(null); if (m_State != null) { m_State.StateEnd(); } //設定 m_State = State; } }
public void SetState(ISceneState state, bool isLoadScene = true) { if (state == null) { return; } if (mState != null) { mState.Exit(); } mState = state; if (isLoadScene) { // 异步加载场景 mAO = SceneManager.LoadSceneAsync(mState.SceneName); mIsRunEnter = false; } else { //本身就在这个场景就无需加载场景了,例如: StartScene mState.Enter(); mIsRunEnter = true; mAO = null; } }
/// <summary> /// 设置状态 /// </summary> /// <param name="LoadSceneName"></param> /// <param name="isLoadScene"></param> public void SetState(string LoadSceneName, bool isLoadScene = false) { m_bRunBegin = false; //如果上一次的状态还存在 则先释放 if (m_State != null) { m_State.StateEnd(); } //先保存一下要切换到那个场景 m_NextSceneName = LoadSceneName; //判断是否要进行加载过渡 if (isLoadScene) { LoadScene(m_LoadSceneName); m_State = FindState(m_LoadSceneName); if (m_State != null) { m_State.LoadTransitionScene(m_NextSceneName); } } else { LoadScene(m_NextSceneName); m_State = FindState(m_NextSceneName); } if (m_State == null) { Debug.LogError("切换状态失败"); } }
/// <summary> /// Sets up the object prior to rendering. /// </summary> /// <param name="scenestate"/> public void BeginFrameRendering(ISceneState scenestate) { if (Space.ForceUpdater.Gravity.Y != -scenestate.Environment.Gravity) { Space.ForceUpdater.Gravity = new Vector3(0, -scenestate.Environment.Gravity, 0); } }
// 設定狀態 public void SetState(ISceneState State, string LoadSceneName) { m_LoadSceneName = LoadSceneName; //if (LoadSceneName!="") //{ // m_LoadSceneName = LoadSceneName; //} //else //{ // m_LoadSceneName = "StartScene"; //} Debug.Log("SetState:" + State.ToString()); m_bRunBegin = false; // 載入場景 LoadScene(LoadSceneName); // 通知前一個State結束 if (m_State != null) { m_State.StateEnd(); Debug.Log(m_State); } // 設定 m_State = State; Debug.Log(m_State); }
public void Push(ISceneState state) { DebugOnly.Check(!states.Contains(state), $"GameState is already on the stack."); states.Add(state); statesListChanged = true; (state as ISceneStateInternal)?.InternalActivate(); }
/// <summary> /// 切换场景 /// </summary> /// <param name="state"></param> /// <param name="isLoadScene"></param> public void SwitchScene(ISceneState state, bool isLoadScene = true) { if (mCurSceneController == null) { return; } mCurSceneController.SetState(state, isLoadScene); }
void ChangeState(ISceneState sceneState) { if (m_state != null) { m_state.SceneEnd(); } m_state = sceneState; m_state.SceneBegin(); }
public void pauseGame() { if (tempFromPause == null) { tempFromPause = currentState; PopState(); //PushState(pauseState); } }
public void resumeGame() { if (tempFromPause != null) { PopState(); PushState(tempFromPause); tempFromPause = null; } }
//场景切换 public void setState(ISceneState state, string sceneName) { m_bRunBegin = false; loadScene(sceneName); if (m_state != null) { m_state.stateEnd(); } m_state = state; }
public void Update(ISceneState scenestate) { Vector3 vector3 = this._Position; Matrix viewToWorld = scenestate.ViewToWorld; Vector3? nullable = null; Vector3? nullable1 = null; Matrix billboardtransform = Matrix.CreateConstrainedBillboard(vector3, viewToWorld.Translation, Vector3.Up, nullable, nullable1); Matrix scaletransform = Matrix.CreateScale(this._Scale); this._SceneObject.World = scaletransform * billboardtransform; }
private void LoadScene(ISceneState state) { this.sceneState = state; if (sceneState.SceneStateController == null) { sceneState.SceneStateController = this; } //SceneManager.LoadScene(state.SceneName); loadSceneOperation = SceneManager.LoadSceneAsync(state.SceneName); isBegin = false; }
/// <summary> /// 设置过渡场景状态 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="LoadSceneName"></param> /// <returns></returns> public T SetLoadScene <T>(string LoadSceneName) where T : ISceneState, new() { ISceneState temp = FindState(LoadSceneName); if (temp == null) { temp = AddState <T>(LoadSceneName); } m_LoadSceneName = LoadSceneName; return(temp as T); }
public void SetState(ISceneState State, string LoadSceneName) { m_bRunBegin = false; LoadScene(LoadSceneName); if (m_State != null) { m_State.StateEnd(); } m_State = State; }
public void SetStateAsync(ISceneState state, string loadSceneName) { isAsync = true; LoadingSceneState loadingSceneState = new LoadingSceneState(this); setStateMode = LoadSceneMode.Additive; waitForUnloadIndex = SceneManager.GetActiveScene().buildIndex; SetState(loadingSceneState, "Loading"); loadingSceneState.SetInfos(state, () => LoadSceneAsync(loadSceneName)); }
internal void SetState(ISceneState state) { if (loadSceneOperation != null && !loadSceneOperation.isDone) { return; } if (sceneState != null) { sceneState.StateEnd(); } LoadScene(state); }
public void SetState(ISceneState state, string loadSceneName) { isRunEnter = false; LoadScene(loadSceneName); if (this.state != null) { this.state.Exit(); } this.state = state; }
public void SetState(ISceneState State, string LoadSceneName) { m_bRunBegin = false; LoadScene(LoadSceneName); // if last state haven't close, force close state if (m_State != null) { m_State.StateEnd(); } m_State = State; }
IEnumerable <ISceneState> CachedGameStates() { int n; if (!statesListChanged) { n = statesCache.Count; } else { statesListChanged = false; statesCache.Clear(); statesCache.AddRange(states); n = statesCache.Count; if (n == 0) { if (CurrentState != null) { (CurrentState as ISceneStateInternal)?.InternalResignTopmost(); CurrentState = null; } } else { if (CurrentState != statesCache[n - 1]) { var oldState = CurrentState; CurrentState = statesCache[n - 1]; (CurrentState as ISceneStateInternal)?.InternalBecomeTopmost(); if (oldState != null) { (oldState as ISceneStateInternal)?.InternalResignTopmost(); } } } int index = 0; foreach (var it in statesCache) { (it as ISceneStateInternal)?.InternalSetSortingOrder(index++); } } while (n-- > 0) { var state = statesCache[n]; yield return(state); } }
public void SetState(ISceneState _sceneState, string _sceneName) { runBegin = false; LoadScene(_sceneName); //如果当前有状态,则通知它结束 if (sceneState != null) { sceneState.StateEnd(); } sceneState = _sceneState; }
//------------------------------------------------------ //场景设置 public void SetState(string statename, ISceneState state) { _mRunBegin = false; LoadScene(statename); //如果m_state不为空,说明存在上一个场景 if (_mstate != null) { //释放上一个场景的资源 _mstate.StateEnd(); } _mstate = state; }
/// <summary> /// 添加状态的缓存 /// </summary> /// <param name="State">对应状态的对象</param> public void AddSceneState(ISceneState State) { if (State == null) { Debug.LogError("新增的状态为空!!!"); return; } if (caChe.ContainsKey(State.StateName)) { Debug.LogError("状态已存在,无法重复添加!!!"); return; } caChe.Add(State.StateName, State); }
private IEnumerator CheckLoadFinish(ISceneState State) { while (SceneLoadProcess < 1) { yield return(null); } if (m_State != null) { m_State.StateEnd(); } //設定 m_State = State; }
public void Pop(ISceneState state) { statesListChanged = true; states.Remove(state); if (CurrentState == state) { (CurrentState as ISceneStateInternal)?.InternalResignTopmost(); CurrentState = null; } (state as ISceneStateInternal)?.InternalDeactivate(); DebugOnly.Check(states.Count != 0, "GameState stack is empty."); }
// 設定狀態 public void SetState(ISceneState State, string LoadSceneName) { //Debug.Log ("SetState:"+State.ToString()); m_bRunBegin = false; // 載入場景 LoadScene( LoadSceneName ); // 通知前一個State結束 if( m_State != null ) m_State.StateEnd(); // 設定 m_State=State; }
/// <summary> /// 设置状态 /// </summary> /// <param name="state">具体状态的实例</param> /// <param name="loadSceneName">场景名称</param> public void SetState(ISceneState state, string loadSceneName) { m_bRunBegin = false; //加载场景 LoadScene(loadSceneName); //释放前一个状态 if (m_State != null) { m_State.StateEnd(); } //更新状态 m_State = state; }
public void SetState(ISceneState State, string LoadSceneName) { Debug.Log("SetState:" + State.ToString()); m_bRunBegin = false; LoadScene(LoadSceneName); //close the front(facade) scene if (m_State != null) { m_State.StateEnd(); } m_State = State; }
/// <summary> /// Sets up the object prior to rendering. /// </summary> /// <param name="scenestate"/> public virtual void BeginFrameRendering(ISceneState scenestate) { _sceneState = scenestate; ElapsedSeconds = (float) _sceneState.GameTime.ElapsedGameTime.TotalSeconds; Frustum = _sceneState.ViewFrustum; for (int i = 0; i < ParticleSystems.Count; i++) { ParticleSystem particleSystem = ParticleSystems[i]; if (particleSystem.Effect != null) { particleSystem.Effect.Update(ElapsedSeconds); _activeParticles.AccumulationValue += particleSystem.Effect.ActiveParticlesCount; } } }
//次の状態へ遷移 public void SwitchState(ISceneState newState) { managerCtrl.SwitchState (newState); }
/// <summary> /// Called when the game begins rendering the current frame. /// </summary> /// <param name="scenestate"></param> public void BeginFrameRendering(ISceneState scenestate) { }
//状態の初期化 public void InitState(SceneManager manager){ this.activeState = new TitleState(manager); }
//次の状態へ遷移 public void SwitchState(ISceneState newState) { this.activeState = newState; }