diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs index 8f6fa714..bbc50592 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.MenuBackdrop.cs @@ -20,7 +20,6 @@ public partial class GameLogic public Transition On(in Input.StartGame input) { - Output(new Output.LoadMap()); return To(); } diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs index 9c2b47ab..1176116f 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Playing.cs @@ -17,6 +17,7 @@ public partial class GameLogic OnAttach(() => { Output(new Output.StartGame()); + Output(new Output.LoadMap()); }); } diff --git a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs index 0e605b06..025f2ec5 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/state/states/GameLogic.State.Quit.cs @@ -8,12 +8,18 @@ public partial class GameLogic public partial record State { [Meta] - public partial record Quit : State + public partial record Quit : State, IGet { public Quit() { this.OnEnter(() => Output(new Output.ShowLostScreen())); } + + public Transition On(in Input.GoToOverworld input) + { + Input(new Input.StartGame()); + return To(); + } } } } \ No newline at end of file diff --git a/Zennysoft.Game.Ma.Implementation/Player/IPlayer.cs b/Zennysoft.Game.Ma.Implementation/Player/IPlayer.cs index b294ba8e..50047c5a 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/IPlayer.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/IPlayer.cs @@ -6,6 +6,8 @@ namespace Zennysoft.Ma.Adapter; public interface IPlayer : IKillable { + public void InitializePlayerState(); + public void Attack(); public void PlayerPause(); diff --git a/Zennysoft.Game.Ma/src/enemy/state/EnemyLogic.g.puml b/Zennysoft.Game.Ma/src/enemy/state/EnemyLogic.g.puml index e4b80aee..33157ae0 100644 --- a/Zennysoft.Game.Ma/src/enemy/state/EnemyLogic.g.puml +++ b/Zennysoft.Game.Ma/src/enemy/state/EnemyLogic.g.puml @@ -1,14 +1,14 @@ @startuml EnemyLogic state "EnemyLogic State" as Zennysoft_Game_Ma_EnemyLogic_State { - state "Defeated" as Zennysoft_Game_Ma_EnemyLogic_State_Defeated state "Alive" as Zennysoft_Game_Ma_EnemyLogic_State_Alive { state "Activated" as Zennysoft_Game_Ma_EnemyLogic_State_Activated { - state "FollowPlayer" as Zennysoft_Game_Ma_EnemyLogic_State_FollowPlayer 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 } Zennysoft_Game_Ma_EnemyLogic_State_Alive --> Zennysoft_Game_Ma_EnemyLogic_State_Attacking : AttackTimer diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 14ee9dd8..75f64cef 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -78,7 +78,6 @@ public partial class Game : Node3D, IGame { _container = new SimpleInjector.Container(); Module.Bootstrap(_container); - //_container.Verify(); GameRepo = _container.GetInstance(); GameLogic = _container.GetInstance(); @@ -164,6 +163,7 @@ public partial class Game : Node3D, IGame { GameRepo.Resume(); InGameUI.Show(); + Player.InitializePlayerState(); }) .Handle((in GameLogic.Output.GoToOverworld _) => { diff --git a/Zennysoft.Game.Ma/src/game/Game.tscn b/Zennysoft.Game.Ma/src/game/Game.tscn index 9a2d6318..48fd0b0a 100644 --- a/Zennysoft.Game.Ma/src/game/Game.tscn +++ b/Zennysoft.Game.Ma/src/game/Game.tscn @@ -38,7 +38,7 @@ stretch = true [node name="SubViewport" type="SubViewport" parent="SubViewportContainer"] transparent_bg = true handle_input_locally = false -size = Vector2i(1280, 960) +size = Vector2i(1920, 1080) render_target_update_mode = 4 [node name="PauseContainer" type="Node3D" parent="SubViewportContainer/SubViewport"] diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index 975ab6fd..2d4350f7 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -98,9 +98,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide { { 2, 12 }, @@ -112,15 +111,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide(Lifestyle.Singleton); - //container.Verify(); - - Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration }; Stats = new PlayerStatController(); Stats.Init( new PlayerStats @@ -143,12 +134,6 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide(); - PlayerLogic.Set(this as IPlayer); - PlayerLogic.Set(Settings); - PlayerLogic.Set(Stats); - PlayerLogic.Set(_gameRepo); - var defaultWeapon = new Weapon { Stats = _defaultWeapon @@ -160,19 +145,35 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide(Lifestyle.Singleton); + //container.Verify(); + + Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration }; + + PlayerLogic = container.GetInstance(); + PlayerLogic.Set(this as IPlayer); + PlayerLogic.Set(Settings); + PlayerLogic.Set(Stats); + PlayerLogic.Set(_gameRepo); } public void OnResolved() @@ -363,7 +364,21 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide PlayerLogic.Input(new PlayerLogic.Input.Die()); + public void Die() + { + EquippedWeapon.Sync -= EquippedWeapon_Sync; + EquippedArmor.Sync -= EquippedArmor_Sync; + EquippedAccessory.Sync -= EquippedAccessory_Sync; + Stats.CurrentHP.Sync -= CurrentHP_Sync; + Stats.CurrentExp.Sync -= CurrentEXP_Sync; + + HealthTimer.WaitTime = _healthTimerWaitTime; + HealthTimer.Timeout -= OnHealthTimerTimeout; + Hitbox.AreaEntered -= Hitbox_AreaEntered; + CollisionDetector.AreaEntered -= CollisionDetector_AreaEntered; + AnimationPlayer.AnimationFinished -= OnAnimationFinished; + PlayerLogic.Input(new PlayerLogic.Input.Die()); + } public override void _UnhandledInput(InputEvent @event) { diff --git a/Zennysoft.Game.Ma/src/player/Player.tscn b/Zennysoft.Game.Ma/src/player/Player.tscn index 9c409eb1..a5e706f3 100644 --- a/Zennysoft.Game.Ma/src/player/Player.tscn +++ b/Zennysoft.Game.Ma/src/player/Player.tscn @@ -17,9 +17,9 @@ script = ExtResource("2_xq68d") RotationSpeed = 1.5 MoveSpeed = 8.0 Acceleration = 1.0 -CurrentHP = 50 +CurrentHP = 100 MaximumHP = 100 -CurrentVT = 90 +CurrentVT = 0 MaximumVT = 90 CurrentExp = 0 ExpToNextLevel = 10 diff --git a/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.cs b/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.cs index a91ca5d4..8176036e 100644 --- a/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.cs +++ b/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.cs @@ -2,6 +2,7 @@ using Chickensoft.AutoInject; using Chickensoft.GodotNodeInterfaces; using Chickensoft.Introspection; using Godot; +using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -16,8 +17,40 @@ public partial class DeathMenu : Control, IDeathMenu { public override void _Notification(int what) => this.Notify(what); + [Dependency] Game Game => this.DependOn(); + [Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!; + [Node] public IButton Continue { get; set; } = default!; + + [Node] public IButton Exit { get; set; } = default!; + + public void OnReady() + { + Continue.Pressed += Continue_Pressed; + Exit.Pressed += Exit_Pressed; + VisibilityChanged += DeathMenu_VisibilityChanged; + } + + private void DeathMenu_VisibilityChanged() + { + if (Visible) + Continue.CallDeferred(MethodName.GrabFocus, []); + else + ReleaseFocus(); + } + + private void Exit_Pressed() + { + GetTree().Quit(); + } + + private void Continue_Pressed() + { + FadeOut(); + Game.GameLogic.Input(new GameLogic.Input.GoToOverworld()); + } + public void FadeIn() => AnimationPlayer.Play("fade_in"); public void FadeOut() => AnimationPlayer.Play("fade_out"); diff --git a/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.tscn b/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.tscn index 79d098c4..690b3ad7 100644 --- a/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.tscn +++ b/Zennysoft.Game.Ma/src/ui/death_menu/DeathMenu.tscn @@ -90,10 +90,33 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="GameOverPlaceholder" type="Label" parent="CenterContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] +layout_mode = 2 + +[node name="GameOverPlaceholder" type="Label" parent="CenterContainer/VBoxContainer"] layout_mode = 2 theme_override_colors/font_color = Color(0.545098, 0, 0, 1) theme_override_constants/outline_size = 12 theme_override_fonts/font = ExtResource("2_ip5p6") theme_override_font_sizes/font_size = 72 text = "Game Over" + +[node name="Continue" type="Button" parent="CenterContainer/VBoxContainer"] +unique_name_in_owner = true +process_mode = 3 +layout_mode = 2 +focus_neighbor_top = NodePath(".") +focus_neighbor_bottom = NodePath("../Exit") +focus_next = NodePath("../Exit") +focus_previous = NodePath(".") +text = "Continue" + +[node name="Exit" type="Button" parent="CenterContainer/VBoxContainer"] +unique_name_in_owner = true +process_mode = 3 +layout_mode = 2 +focus_neighbor_top = NodePath("../Continue") +focus_neighbor_bottom = NodePath(".") +focus_next = NodePath(".") +focus_previous = NodePath("../Continue") +text = "Exit"