コード例 #1
0
ファイル: MainMenuScene.cs プロジェクト: default0/Beats
 /// <inheritdoc/>
 public override bool CanTransitionTo(Scene scene)
 {
     if (scene is SongSelectScene)
         return true;
     else
         return false;
 }
コード例 #2
0
ファイル: PlayScene.cs プロジェクト: default0/Beats
 /// <inheritdoc/>
 public override bool CanTransitionTo(Scene scene)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
ファイル: Window.cs プロジェクト: default0/Beats
		/// <summary>
		/// Transitions from the given old scene to the given new scene.
		/// </summary>
		/// <param name="oldScene">The old scene that should be replaced with the new scene.</param>
		/// <param name="newScene">The new scene that should replace the given old scene.</param>
		public void Transition(Scene oldScene, Scene newScene)
		{
			int oldSceneIndex = activeScenes.IndexOf(oldScene);
			if (oldSceneIndex == -1)
				throw new Exception($"Attempted to transition from non-active scene {oldScene.Name} to {newScene.Name}");

			int newSceneIndex = activeScenes.IndexOf(newScene);
			if (newSceneIndex != -1)
				throw new Exception($"Attempted to transition from {oldScene.Name} to already-active scene {newScene.Name}");

			if (!oldScene.CanTransitionTo(newScene))
				throw new Exception($"Attempted invalid transition from {oldScene.Name} to {newScene.Name}");

			Action onTransitionOutFinished = null; // this is necessary due to definite-assignment rules.
			onTransitionOutFinished = () =>
			{
				oldScene.OnExit();
				activeScenes.Remove(oldScene);
				oldScene.TransitionFinished -= onTransitionOutFinished;
			};
			oldScene.TransitionFinished += onTransitionOutFinished;
			oldScene.TransitionOut();

			activeScenes.Add(newScene);
			newScene.TransitionIn();
		}
コード例 #4
0
ファイル: SongSelectScene.cs プロジェクト: default0/Beats
 /// <inheritdoc/>
 public override bool CanTransitionTo(Scene scene)
 {
     return scene is PlayScene;
 }
コード例 #5
0
ファイル: Scene.cs プロジェクト: default0/Beats
 /// <summary>
 /// Returns true if this scene is allowed to transition to the given scene, false otherwise.
 /// </summary>
 /// <param name="scene">The scene that should be transitioned to.</param>
 /// <returns>True if this scene is allowed to transition to the given scene, false otherwise.</returns>
 public abstract bool CanTransitionTo(Scene scene);