Fix menus between floors

This commit is contained in:
2025-06-28 00:30:16 -07:00
parent 39f791e2b4
commit f33616dda4
11 changed files with 104 additions and 11 deletions

View File

@@ -24,6 +24,12 @@ public partial class GameState
public readonly record struct FloorExitEntered; public readonly record struct FloorExitEntered;
public readonly record struct AskForTeleport;
public readonly record struct UseTeleport;
public readonly record struct CloseTeleport;
public readonly record struct GameOver; public readonly record struct GameOver;
} }
} }

View File

@@ -22,6 +22,8 @@ public partial class GameState
public readonly record struct LoadNextFloor; public readonly record struct LoadNextFloor;
public readonly record struct OpenTeleportScreen;
public readonly record struct OpenFloorExitScreen; public readonly record struct OpenFloorExitScreen;
public readonly record struct OpenDebugMenu; public readonly record struct OpenDebugMenu;

View File

@@ -0,0 +1,36 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Godot;
namespace Zennysoft.Ma.Adapter;
public partial class GameState
{
public partial record State
{
[Meta, LogicBlock(typeof(State), Diagram = true)]
public partial record AskForTeleportScreen : State, IGet<Input.UseTeleport>, IGet<Input.CloseTeleport>
{
public AskForTeleportScreen()
{
OnAttach(() => Get<IGameRepo>().Pause());
}
public Transition On(in Input.ReturnToMainMenu input)
{
return To<MainMenu>();
}
public Transition On(in Input.UseTeleport input)
{
Output(new Output.OpenFloorExitScreen());
return To<FloorExitScreen>();
}
public Transition On(in Input.CloseTeleport input)
{
return To<InGame>();
}
}
}
}

View File

@@ -42,8 +42,8 @@ public partial class GameState
public Transition On(in Input.FloorExitEntered input) public Transition On(in Input.FloorExitEntered input)
{ {
Output(new Output.OpenFloorExitScreen()); Output(new Output.OpenTeleportScreen());
return To<FloorExitScreen>(); return To<AskForTeleportScreen>();
} }
public Transition On(in Input.GameOver input) public Transition On(in Input.GameOver input)

View File

@@ -10,6 +10,8 @@ public interface IPlayer : IKillable
public void Activate(); public void Activate();
public void Deactivate();
public void Attack(); public void Attack();
public void TakeDamage(double damage, ElementType elementType = ElementType.None, bool isCriticalHit = false); public void TakeDamage(double damage, ElementType elementType = ElementType.None, bool isCriticalHit = false);

View File

@@ -1,12 +1,12 @@
@startuml EnemyLogic @startuml EnemyLogic
state "EnemyLogic State" as Zennysoft_Game_Ma_EnemyLogic_State { state "EnemyLogic State" as Zennysoft_Game_Ma_EnemyLogic_State {
state "Alive" as Zennysoft_Game_Ma_EnemyLogic_State_Alive { state "Alive" as Zennysoft_Game_Ma_EnemyLogic_State_Alive {
state "Idle" as Zennysoft_Game_Ma_EnemyLogic_State_Idle
state "Activated" as Zennysoft_Game_Ma_EnemyLogic_State_Activated { state "Activated" as Zennysoft_Game_Ma_EnemyLogic_State_Activated {
state "Patrolling" as Zennysoft_Game_Ma_EnemyLogic_State_Patrolling
state "FollowPlayer" as Zennysoft_Game_Ma_EnemyLogic_State_FollowPlayer
state "Attacking" as Zennysoft_Game_Ma_EnemyLogic_State_Attacking state "Attacking" as Zennysoft_Game_Ma_EnemyLogic_State_Attacking
state "FollowPlayer" as Zennysoft_Game_Ma_EnemyLogic_State_FollowPlayer
state "Patrolling" as Zennysoft_Game_Ma_EnemyLogic_State_Patrolling
} }
state "Idle" as Zennysoft_Game_Ma_EnemyLogic_State_Idle
} }
state "Defeated" as Zennysoft_Game_Ma_EnemyLogic_State_Defeated state "Defeated" as Zennysoft_Game_Ma_EnemyLogic_State_Defeated
} }

View File

@@ -211,14 +211,20 @@ public partial class Game : Node3D, IGame
InGameUI.PlayerInfoUI.Show(); InGameUI.PlayerInfoUI.Show();
GameRepo.Resume(); GameRepo.Resume();
}) })
.Handle((in GameState.Output.OpenFloorExitScreen _) => .Handle((in GameState.Output.OpenTeleportScreen _) =>
{ {
InGameUI.UseTeleportPrompt.Show(); InGameUI.UseTeleportPrompt.Show();
InGameUI.UseTeleportPrompt.FadeIn(); InGameUI.UseTeleportPrompt.FadeIn();
}) })
.Handle((in GameState.Output.LoadNextFloor _) => .Handle((in GameState.Output.OpenFloorExitScreen _) =>
{ {
InGameUI.UseTeleportPrompt.FadeOut(); InGameUI.UseTeleportPrompt.FadeOut();
FloorClearMenu.Show();
FloorClearMenu.FadeIn();
})
.Handle((in GameState.Output.LoadNextFloor _) =>
{
FloorClearMenu.FadeOut();
Map.SpawnNextFloor(); Map.SpawnNextFloor();
if (Player.EquippedWeapon.Value.ItemTag == ItemTag.BreaksOnChange) if (Player.EquippedWeapon.Value.ItemTag == ItemTag.BreaksOnChange)
{ {
@@ -249,6 +255,9 @@ public partial class Game : Node3D, IGame
GameState.Start(); GameState.Start();
this.Provide(); this.Provide();
InGameUI.UseTeleportPrompt.TeleportToNextFloor += UseTeleportPrompt_TeleportToNextFloor; InGameUI.UseTeleportPrompt.TeleportToNextFloor += UseTeleportPrompt_TeleportToNextFloor;
InGameUI.UseTeleportPrompt.CloseTeleportPrompt += UseTeleportPrompt_CloseTeleportPrompt;
FloorClearMenu.GoToNextFloor += FloorClearMenu_GoToNextFloor;
FloorClearMenu.SaveAndExit += FloorClearMenu_SaveAndExit;
FloorClearMenu.TransitionCompleted += FloorClearMenu_TransitionCompleted; FloorClearMenu.TransitionCompleted += FloorClearMenu_TransitionCompleted;
GameRepo.RestorativePickedUp += GameEventDepot_RestorativePickedUp; GameRepo.RestorativePickedUp += GameEventDepot_RestorativePickedUp;
@@ -269,6 +278,16 @@ public partial class Game : Node3D, IGame
MainMenu.Show(); MainMenu.Show();
} }
private void FloorClearMenu_SaveAndExit()
{
//SaveFile.Save();
Player.Deactivate();
GameState.Input(new GameState.Input.ReturnToMainMenu());
InGameUI.Hide();
MainMenu.FadeIn();
}
private void FloorClearMenu_GoToNextFloor() => GameState.Input(new GameState.Input.LoadNextFloor());
public void LoadExistingGame() => SaveFile.Load().ContinueWith((_) => CallDeferred(nameof(FinishedLoadingSaveFile))); public void LoadExistingGame() => SaveFile.Load().ContinueWith((_) => CallDeferred(nameof(FinishedLoadingSaveFile)));
public void InitializeGame() public void InitializeGame()
@@ -382,16 +401,19 @@ public partial class Game : Node3D, IGame
restorative.GlobalPosition = vector; restorative.GlobalPosition = vector;
} }
private void UseTeleportPrompt_TeleportToNextFloor() private void UseTeleportPrompt_CloseTeleportPrompt()
{ {
InGameUI.UseTeleportPrompt.FadeIn(); GameState.Input(new GameState.Input.CloseTeleport());
GameState.Input(new GameState.Input.LoadNextFloor()); InGameUI.UseTeleportPrompt.FadeOut();
GameEventDepot.OnDungeonAThemeAreaEntered(); GameRepo.Resume();
} }
private void UseTeleportPrompt_TeleportToNextFloor() => GameState.Input(new GameState.Input.UseTeleport());
private void FloorClearMenu_TransitionCompleted() private void FloorClearMenu_TransitionCompleted()
{ {
GameRepo.Resume(); GameRepo.Resume();
GameEventDepot.OnDungeonAThemeAreaEntered();
} }
private void GameEventDepot_RestorativePickedUp(IHealthPack obj) => Player.Stats.SetCurrentVT(Player.Stats.CurrentVT.Value + (int)obj.RestoreAmount); private void GameEventDepot_RestorativePickedUp(IHealthPack obj) => Player.Stats.SetCurrentVT(Player.Stats.CurrentVT.Value + (int)obj.RestoreAmount);

View File

@@ -10,6 +10,8 @@ public interface IMainMenu : IControl
event MainMenu.NewGameEventHandler NewGame; event MainMenu.NewGameEventHandler NewGame;
event MainMenu.LoadGameEventHandler LoadGame; event MainMenu.LoadGameEventHandler LoadGame;
event MainMenu.QuitEventHandler Quit; event MainMenu.QuitEventHandler Quit;
void FadeIn();
} }
[Meta(typeof(IAutoNode))] [Meta(typeof(IAutoNode))]
@@ -38,6 +40,12 @@ public partial class MainMenu : Control, IMainMenu
NewGameButton.GrabFocus(); NewGameButton.GrabFocus();
} }
public void FadeIn()
{
NewGameButton.GrabFocus();
Show();
}
public void OnExitTree() public void OnExitTree()
{ {
NewGameButton.Pressed -= OnNewGamePressed; NewGameButton.Pressed -= OnNewGamePressed;

View File

@@ -11,6 +11,15 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_y6722") script = ExtResource("1_y6722")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.137255, 0.121569, 0.12549, 1)
[node name="MarginContainer" type="MarginContainer" parent="."] [node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15

View File

@@ -215,6 +215,13 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
HealthTimer.Start(); HealthTimer.Start();
} }
public void Deactivate()
{
SetProcessInput(false);
SetPhysicsProcess(false);
HealthTimer.Stop();
}
public void Attack() public void Attack()
{ {
PlayerLogic.Input(new PlayerLogic.Input.Attack()); PlayerLogic.Input(new PlayerLogic.Input.Attack());

View File

@@ -51,6 +51,7 @@ public partial class FloorClearMenu : Control, IFloorClearMenu
{ {
ContinueButton.Disabled = true; ContinueButton.Disabled = true;
SaveAndExitButton.Disabled = true; SaveAndExitButton.Disabled = true;
FadeOut();
EmitSignal(SignalName.SaveAndExit); EmitSignal(SignalName.SaveAndExit);
} }