Load screen with pausing
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
@@ -25,28 +25,54 @@ namespace GameJamDungeon
|
||||
public IAppLogic AppLogic { get; set; } = default!;
|
||||
public AppLogic.IBinding AppBinding { get; set; } = default!;
|
||||
|
||||
[Node] public IMenu Menu { get; set; } = default!;
|
||||
|
||||
[Node] public ISubViewport GameWindow { get; set; } = default!;
|
||||
|
||||
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Instantiator = new Instantiator(GetTree());
|
||||
AppRepo = new AppRepo();
|
||||
AppLogic = new AppLogic();
|
||||
AppLogic.Set(AppRepo);
|
||||
|
||||
Menu.NewGame += OnNewGame;
|
||||
Menu.Quit += OnQuit;
|
||||
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
|
||||
this.Provide();
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
Game = Instantiator.LoadAndInstantiate<Game>(GAME_SCENE_PATH);
|
||||
GameWindow.AddChildEx(Game);
|
||||
AppBinding = AppLogic.Bind();
|
||||
AppLogic.Start();
|
||||
|
||||
Instantiator.SceneTree.Paused = false;
|
||||
AppBinding
|
||||
.Handle((in AppLogic.Output.ShowLoadingScreen _) =>
|
||||
{
|
||||
Menu.Hide();
|
||||
AnimationPlayer.Play("load");
|
||||
})
|
||||
.Handle((in AppLogic.Output.SetupGameScene _) =>
|
||||
{
|
||||
Instantiator.SceneTree.Paused = true;
|
||||
Game = Instantiator.LoadAndInstantiate<Game>(GAME_SCENE_PATH);
|
||||
GameWindow.AddChildEx(Game);
|
||||
})
|
||||
.Handle((in AppLogic.Output.ShowGame _) =>
|
||||
{
|
||||
Instantiator.SceneTree.Paused = false;
|
||||
Game.Show();
|
||||
});
|
||||
|
||||
|
||||
AppLogic.Start();
|
||||
}
|
||||
|
||||
private void AnimationPlayer_AnimationFinished(StringName animName)
|
||||
{
|
||||
AppLogic.Input(new AppLogic.Input.LoadGameFinished());
|
||||
}
|
||||
|
||||
public void OnNewGame() => AppLogic.Input(new AppLogic.Input.NewGame());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user