Big refactor in place: Organize nodes in line with dependency injection expectations, use state machine flow more
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
namespace GameJamDungeon;
|
||||
|
||||
using Chickensoft.AutoInject;
|
||||
@@ -5,6 +6,7 @@ using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using DialogueManagerRuntime;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -32,25 +34,17 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
[Dependency] public IAppRepo AppRepo => this.DependOn<IAppRepo>();
|
||||
|
||||
[Node] public IInventoryMenu InventoryMenu { get; set; } = default!;
|
||||
|
||||
[Node] public Control MiniMap { get; set; } = default!;
|
||||
|
||||
[Node] public Area3D Teleport { get; set; } = default!;
|
||||
|
||||
[Node] public IDungeonFloor Overworld { get; set; } = default!;
|
||||
|
||||
[Node] public IDungeonFloor Floor1 { get; set; } = default!;
|
||||
|
||||
[Node] public IDungeonFloor Floor2 { get; set; } = default!;
|
||||
|
||||
[Node] public IDungeonFloor Floor3 { get; set; } = default!;
|
||||
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
[Node] public IMap Map { get; set; } = default!;
|
||||
|
||||
[Node] public DialogueController DialogueController { get; set; } = default!;
|
||||
|
||||
private List<IDungeonFloor> Floors;
|
||||
[Node] public IPauseMenu PauseMenu { get; set; } = default!;
|
||||
|
||||
[Node] public FloorClearMenu FloorClearMenu { get; set; } = default!;
|
||||
|
||||
[Node] public DeathMenu DeathMenu { get; set; } = default!;
|
||||
|
||||
[Node] public InGameUI InGameUI { get; set; } = default!;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
@@ -59,17 +53,13 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Set(GameRepo);
|
||||
GameLogic.Set(AppRepo);
|
||||
Instantiator = new Instantiator(GetTree());
|
||||
Floors = new List<IDungeonFloor> { Overworld, Floor1, Floor2, Floor3 };
|
||||
Teleport.BodyEntered += OnTeleportEntered;
|
||||
|
||||
FloorClearMenu.TransitionCompleted += OnFloorClearTransitionCompleted;
|
||||
}
|
||||
|
||||
private void OnTeleportEntered(Node3D body)
|
||||
private void OnFloorClearTransitionCompleted()
|
||||
{
|
||||
GameRepo.Pause();
|
||||
DialogueManager.GetCurrentScene = (() => this);
|
||||
var dialogueResource = GD.Load<Resource>("res://src/ui/dialogue/FloorExit.dialogue");
|
||||
DialogueController.ShowDialogue(dialogueResource, "floor_exit");
|
||||
DialogueManager.DialogueEnded += (Resource resource) => { GameRepo.Resume(); };
|
||||
GameLogic.Input(new GameLogic.Input.FloorClearTransitioned());
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
@@ -84,36 +74,27 @@ public partial class Game : Node3D, IGame
|
||||
GameBinding
|
||||
.Handle((in GameLogic.Output.StartGame _) =>
|
||||
{
|
||||
InGameUI.Show();
|
||||
GameRepo.SetPlayerGlobalPosition(Map.GetPlayerSpawnPoint());
|
||||
})
|
||||
.Handle((in GameLogic.Output.LoadNextFloor _) =>
|
||||
.Handle((in GameLogic.Output.SetPauseMode output) => CallDeferred(nameof(SetPauseMode), output.IsPaused))
|
||||
.Handle((in GameLogic.Output.ShowPauseMenu _) =>
|
||||
{
|
||||
AnimationPlayer.Play("wait_and_load");
|
||||
var currentFloor = Floors.ElementAt(GameRepo.CurrentFloor);
|
||||
currentFloor.CallDeferred(MethodName.QueueFree, []);
|
||||
|
||||
if (GameRepo.EquippedWeapon.Value.WeaponInfo != null && GameRepo.EquippedWeapon.Value.WeaponInfo.WeaponTags.Contains(WeaponTag.BreaksOnChange))
|
||||
{
|
||||
GameRepo.InventoryItems.Value.Remove(GameRepo.EquippedWeapon.Value);
|
||||
GameRepo.OnWeaponEquipped(new Weapon());
|
||||
}
|
||||
|
||||
PauseMenu.Show();
|
||||
PauseMenu.FadeIn();
|
||||
})
|
||||
.Handle((in GameLogic.Output.SetPauseMode output) =>
|
||||
{
|
||||
CallDeferred(nameof(SetPauseMode), output.IsPaused);
|
||||
})
|
||||
.Handle((in GameLogic.Output.SetInventoryMode _) => { InventoryMenu.RedrawInventory(); InventoryMenu.Show(); })
|
||||
.Handle((in GameLogic.Output.HideInventory _) => { InventoryMenu.Hide(); })
|
||||
.Handle((in GameLogic.Output.ShowMiniMap _) => { MiniMap.Show(); })
|
||||
.Handle((in GameLogic.Output.HideMiniMap _) => { MiniMap.Hide(); })
|
||||
.Handle((in GameLogic.Output.GameOver _) => { AppRepo.OnGameOver(); });
|
||||
.Handle((in GameLogic.Output.HidePauseMenu _) => { PauseMenu.Hide(); })
|
||||
.Handle((in GameLogic.Output.ExitPauseMenu _) => { PauseMenu.FadeOut(); })
|
||||
.Handle((in GameLogic.Output.ShowFloorClearMenu _) => { FloorClearMenu.Show(); FloorClearMenu.FadeIn(); })
|
||||
.Handle((in GameLogic.Output.SetInventoryMode _) => { InGameUI.ShowInventoryScreen(); })
|
||||
.Handle((in GameLogic.Output.HideInventory _) => { InGameUI.HideInventoryScreen(); })
|
||||
.Handle((in GameLogic.Output.ShowMiniMap _) => { InGameUI.ShowMiniMap(); })
|
||||
.Handle((in GameLogic.Output.HideMiniMap _) => { InGameUI.HideMiniMap(); })
|
||||
.Handle((in GameLogic.Output.ShowLostScreen _) => { DeathMenu.Show(); DeathMenu.FadeIn(); })
|
||||
.Handle((in GameLogic.Output.ExitLostScreen _) => { DeathMenu.FadeOut(); });
|
||||
GameLogic.Start();
|
||||
|
||||
GameLogic.Input(new GameLogic.Input.Initialize());
|
||||
AnimationPlayer.AnimationStarted += AnimationPlayer_AnimationStarted;
|
||||
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
|
||||
|
||||
AnimationPlayer.Play("wait_and_load");
|
||||
|
||||
this.Provide();
|
||||
}
|
||||
@@ -123,20 +104,6 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Input(new GameLogic.Input.InventoryMenuToggle());
|
||||
}
|
||||
|
||||
private void AnimationPlayer_AnimationStarted(StringName animName)
|
||||
{
|
||||
var newFloor = Floors.ElementAt(GameRepo.CurrentFloor + 1);
|
||||
newFloor.CallDeferred(nameof(newFloor.InitializeDungeon), []);
|
||||
newFloor.Show();
|
||||
}
|
||||
|
||||
private void AnimationPlayer_AnimationFinished(StringName animName)
|
||||
{
|
||||
var spawnPoints = GetTree().GetNodesInGroup("Exit").OfType<Marker3D>();
|
||||
Teleport.GlobalPosition = spawnPoints.Last().GlobalPosition;
|
||||
GameRepo.CurrentFloor++;
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionPressed(GameInputs.Inventory))
|
||||
|
||||
@@ -1,131 +1,54 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://33ek675mfb5n"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://33ek675mfb5n"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/game/Game.cs" id="1_ytcii"]
|
||||
[ext_resource type="PackedScene" uid="uid://by67pn7fdsg1m" path="res://src/map/Map.tscn" id="3_d8awv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfecvvav8kkp6" path="res://src/player/Player.tscn" id="3_kk6ly"]
|
||||
[ext_resource type="PackedScene" uid="uid://dlj8qdg1c5048" path="res://src/inventory_menu/InventoryMenu.tscn" id="4_wk8gw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dvnc26rebk6o0" path="res://src/map/Overworld.tscn" id="5_4hqe8"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc1sp6xwe0j65" path="res://src/map/dungeon/floors/Floor1.tscn" id="6_75lk5"]
|
||||
[ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="6_owlf4"]
|
||||
[ext_resource type="PackedScene" path="res://src/map/dungeon/floors/Floor2.tscn" id="7_1sm5s"]
|
||||
[ext_resource type="PackedScene" path="res://src/map/dungeon/floors/Floor3.tscn" id="8_87yk1"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjqgl5u05ia04" path="res://src/map/Teleport.tscn" id="9_nwu7r"]
|
||||
[ext_resource type="Script" path="res://src/map/Map.cs" id="4_f5pye"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1muxus5qdbeu" path="res://src/ui/in_game_ui/InGameUI.tscn" id="5_lxtnp"]
|
||||
[ext_resource type="PackedScene" uid="uid://b16ejcwanod72" path="res://src/audio/InGameAudio.tscn" id="6_qc71l"]
|
||||
[ext_resource type="Script" path="res://src/game/DialogueController.cs" id="10_58pbt"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_fke5g"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_nc1gg"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("LoadScreen:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_wewlr"]
|
||||
resource_name = "load"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("LoadScreen:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0.486275, 1, 1), Color(0, 0.486275, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ovny8"]
|
||||
resource_name = "wait_and_load"
|
||||
length = 3.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("LoadScreen:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1.96667, 2.96667),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0.486275, 1, 1), Color(0, 0.486275, 1, 1), Color(0, 0.486275, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_opfbx"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_nc1gg"),
|
||||
"load": SubResource("Animation_wewlr"),
|
||||
"wait_and_load": SubResource("Animation_ovny8")
|
||||
}
|
||||
[ext_resource type="Script" path="res://src/ui/pause_menu/PauseMenu.cs" id="11_5ng8c"]
|
||||
[ext_resource type="PackedScene" uid="uid://pu6gp8de3ck4" path="res://src/ui/floor_clear/FloorClearMenu.tscn" id="11_rya1n"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbtfgrtgpr4qg" path="res://src/ui/death_menu/DeathMenu.tscn" id="11_wypid"]
|
||||
[ext_resource type="PackedScene" uid="uid://blbqgw3wosc1w" path="res://src/ui/pause_menu/PauseMenu.tscn" id="12_yev8k"]
|
||||
|
||||
[node name="Game" type="Node3D"]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_ytcii")
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("3_kk6ly")]
|
||||
[node name="PauseContainer" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 1
|
||||
|
||||
[node name="Player" parent="PauseContainer" instance=ExtResource("3_kk6ly")]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 1
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.74459, 1.22144)
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_fke5g")
|
||||
[node name="Map" parent="PauseContainer" instance=ExtResource("3_d8awv")]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("4_f5pye")
|
||||
|
||||
[node name="MiniMap" parent="." instance=ExtResource("6_owlf4")]
|
||||
[node name="InGameUI" parent="." instance=ExtResource("5_lxtnp")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[node name="InventoryMenu" parent="." instance=ExtResource("4_wk8gw")]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
visible = false
|
||||
|
||||
[node name="OmniLight3D" type="OmniLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 24.5244, 0)
|
||||
layers = 3
|
||||
omni_range = 163.618
|
||||
omni_attenuation = -0.183
|
||||
|
||||
[node name="Overworld" parent="." instance=ExtResource("5_4hqe8")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Floor1" parent="." instance=ExtResource("6_75lk5")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Floor2" parent="." instance=ExtResource("7_1sm5s")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Floor3" parent="." instance=ExtResource("8_87yk1")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_opfbx")
|
||||
}
|
||||
|
||||
[node name="LoadScreen" type="ColorRect" parent="."]
|
||||
process_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(1, 1, 1, 0)
|
||||
|
||||
[node name="Teleport" parent="." instance=ExtResource("9_nwu7r")]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 900, 900, 900)
|
||||
disable_mode = 2
|
||||
[node name="InGameAudio" parent="." instance=ExtResource("6_qc71l")]
|
||||
|
||||
[node name="DialogueController" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
script = ExtResource("10_58pbt")
|
||||
|
||||
[node name="DeathMenu" parent="." instance=ExtResource("11_wypid")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[node name="FloorClearMenu" parent="." instance=ExtResource("11_rya1n")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[node name="PauseMenu" parent="." instance=ExtResource("12_yev8k")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
script = ExtResource("11_5ng8c")
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
[Meta, Id("game_data")]
|
||||
public partial record GameData
|
||||
{
|
||||
[Save("player_data")]
|
||||
public required PlayerData PlayerData { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,14 @@
|
||||
public readonly record struct GameOver;
|
||||
|
||||
public readonly record struct LoadNextFloor;
|
||||
|
||||
public readonly record struct FloorExitReached;
|
||||
|
||||
public readonly record struct FloorClearTransitioned;
|
||||
|
||||
public readonly record struct PauseButtonPressed;
|
||||
|
||||
public readonly record struct PauseMenuTransitioned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,33 @@ namespace GameJamDungeon
|
||||
{
|
||||
public static class Output
|
||||
{
|
||||
public readonly record struct StartGame();
|
||||
public readonly record struct StartGame;
|
||||
|
||||
public readonly record struct ShowPauseMenu;
|
||||
|
||||
public readonly record struct HidePauseMenu;
|
||||
|
||||
public readonly record struct ExitPauseMenu;
|
||||
|
||||
public readonly record struct SetInventoryMode(List<IInventoryItem> Inventory);
|
||||
|
||||
public readonly record struct HideInventory();
|
||||
public readonly record struct HideInventory;
|
||||
|
||||
public readonly record struct SetPauseMode(bool IsPaused);
|
||||
|
||||
public readonly record struct ShowMiniMap();
|
||||
public readonly record struct ShowMiniMap;
|
||||
|
||||
public readonly record struct HideMiniMap();
|
||||
public readonly record struct HideMiniMap;
|
||||
|
||||
public readonly record struct GameOver();
|
||||
public readonly record struct ShowLostScreen;
|
||||
|
||||
public readonly record struct ExitLostScreen;
|
||||
|
||||
public readonly record struct LoadNextFloor;
|
||||
|
||||
public readonly record struct ShowFloorClearMenu;
|
||||
|
||||
public readonly record struct HideFloorClearMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
src/game/GameLogic.g.puml
Normal file
36
src/game/GameLogic.g.puml
Normal file
@@ -0,0 +1,36 @@
|
||||
@startuml GameLogic
|
||||
state "GameLogic State" as GameJamDungeon_GameLogic_State {
|
||||
state "FloorCleared" as GameJamDungeon_GameLogic_State_FloorCleared
|
||||
state "InventoryOpened" as GameJamDungeon_GameLogic_State_InventoryOpened
|
||||
state "MenuBackdrop" as GameJamDungeon_GameLogic_State_MenuBackdrop
|
||||
state "MinimapOpen" as GameJamDungeon_GameLogic_State_MinimapOpen
|
||||
state "Paused" as GameJamDungeon_GameLogic_State_Paused
|
||||
state "Playing" as GameJamDungeon_GameLogic_State_Playing
|
||||
state "Quit" as GameJamDungeon_GameLogic_State_Quit
|
||||
state "Resuming" as GameJamDungeon_GameLogic_State_Resuming
|
||||
}
|
||||
|
||||
GameJamDungeon_GameLogic_State_InventoryOpened --> GameJamDungeon_GameLogic_State_Playing : InventoryMenuToggle
|
||||
GameJamDungeon_GameLogic_State_MenuBackdrop --> GameJamDungeon_GameLogic_State_MenuBackdrop : Initialize
|
||||
GameJamDungeon_GameLogic_State_MenuBackdrop --> GameJamDungeon_GameLogic_State_Playing : Start
|
||||
GameJamDungeon_GameLogic_State_MinimapOpen --> GameJamDungeon_GameLogic_State_Playing : MiniMapButtonReleased
|
||||
GameJamDungeon_GameLogic_State_Playing --> GameJamDungeon_GameLogic_State_FloorCleared : FloorExitReached
|
||||
GameJamDungeon_GameLogic_State_Playing --> GameJamDungeon_GameLogic_State_InventoryOpened : InventoryMenuToggle
|
||||
GameJamDungeon_GameLogic_State_Playing --> GameJamDungeon_GameLogic_State_MinimapOpen : MiniMapButtonPressed
|
||||
GameJamDungeon_GameLogic_State_Playing --> GameJamDungeon_GameLogic_State_Quit : GameOver
|
||||
GameJamDungeon_GameLogic_State_Resuming --> GameJamDungeon_GameLogic_State_Playing : PauseMenuTransitioned
|
||||
|
||||
GameJamDungeon_GameLogic_State : OnIsPaused() → SetPauseMode
|
||||
GameJamDungeon_GameLogic_State_FloorCleared : OnEnter → ShowFloorClearMenu
|
||||
GameJamDungeon_GameLogic_State_FloorCleared : OnExit → HideFloorClearMenu
|
||||
GameJamDungeon_GameLogic_State_InventoryOpened : OnEnter → SetInventoryMode
|
||||
GameJamDungeon_GameLogic_State_InventoryOpened : OnExit → HideInventory
|
||||
GameJamDungeon_GameLogic_State_MinimapOpen : OnEnter → ShowMiniMap
|
||||
GameJamDungeon_GameLogic_State_MinimapOpen : OnExit → HideMiniMap
|
||||
GameJamDungeon_GameLogic_State_Paused : OnExit → ExitPauseMenu
|
||||
GameJamDungeon_GameLogic_State_Playing : OnEnter → StartGame
|
||||
GameJamDungeon_GameLogic_State_Quit : OnEnter → ShowLostScreen
|
||||
GameJamDungeon_GameLogic_State_Resuming : OnExit → HidePauseMenu
|
||||
|
||||
[*] --> GameJamDungeon_GameLogic_State_Playing
|
||||
@enduml
|
||||
@@ -7,6 +7,8 @@ namespace GameJamDungeon;
|
||||
|
||||
public interface IGameRepo : IDisposable
|
||||
{
|
||||
public void OnGameEnded();
|
||||
|
||||
event Action? Ended;
|
||||
|
||||
AutoProp<List<IInventoryItem>> InventoryItems { get; }
|
||||
|
||||
21
src/game/state/states/GameLogic.State.FloorCleared.cs
Normal file
21
src/game/state/states/GameLogic.State.FloorCleared.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public partial class GameLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record FloorCleared : State
|
||||
{
|
||||
public FloorCleared()
|
||||
{
|
||||
this.OnEnter(() => { Get<IGameRepo>().Pause(); Output(new Output.ShowFloorClearMenu()); });
|
||||
this.OnExit(() => { Output(new Output.HideFloorClearMenu()); });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
src/game/state/states/GameLogic.State.Paused.cs
Normal file
23
src/game/state/states/GameLogic.State.Paused.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public partial class GameLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Paused : State
|
||||
{
|
||||
public Paused()
|
||||
{
|
||||
this.OnEnter(() => Get<IGameRepo>().Pause());
|
||||
this.OnExit(() => Output(new Output.ExitPauseMenu()));
|
||||
}
|
||||
|
||||
public virtual Transition On(in Input.PauseButtonPressed input) => To<Resuming>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,11 @@ namespace GameJamDungeon
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Playing : State, IGet<Input.InventoryMenuToggle>, IGet<Input.MiniMapButtonPressed>, IGet<Input.GameOver>, IGet<Input.LoadNextFloor>
|
||||
public partial record Playing : State,
|
||||
IGet<Input.InventoryMenuToggle>,
|
||||
IGet<Input.MiniMapButtonPressed>,
|
||||
IGet<Input.GameOver>,
|
||||
IGet<Input.FloorExitReached>
|
||||
{
|
||||
public Playing()
|
||||
{
|
||||
@@ -24,16 +28,9 @@ namespace GameJamDungeon
|
||||
|
||||
public Transition On(in Input.MiniMapButtonPressed input) => To<MinimapOpen>();
|
||||
|
||||
public Transition On(in Input.GameOver input)
|
||||
{
|
||||
return To<Quit>();
|
||||
}
|
||||
public Transition On(in Input.GameOver input) => To<Quit>();
|
||||
|
||||
public Transition On(in Input.LoadNextFloor input)
|
||||
{
|
||||
Output(new Output.LoadNextFloor());
|
||||
return ToSelf();
|
||||
}
|
||||
public Transition On(in Input.FloorExitReached input) => To<FloorCleared>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace GameJamDungeon
|
||||
{
|
||||
public Quit()
|
||||
{
|
||||
this.OnEnter(() => Output(new Output.GameOver()));
|
||||
this.OnEnter(() => Output(new Output.ShowLostScreen()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
src/game/state/states/GameLogic.State.Resuming.cs
Normal file
23
src/game/state/states/GameLogic.State.Resuming.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace GameJamDungeon;
|
||||
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Resuming : State, IGet<Input.PauseMenuTransitioned>
|
||||
{
|
||||
public Resuming()
|
||||
{
|
||||
this.OnEnter(() => Get<IGameRepo>().Resume());
|
||||
this.OnExit(() => Output(new Output.HidePauseMenu()));
|
||||
}
|
||||
|
||||
public Transition On(in Input.PauseMenuTransitioned input) =>
|
||||
To<Playing>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public partial class GameLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Paused : State, IGet<Input.InventoryMenuToggle>, IGet<Input.MiniMapButtonReleased>
|
||||
{
|
||||
public Paused()
|
||||
{
|
||||
this.OnEnter(() => Get<IGameRepo>().Pause());
|
||||
this.OnExit(() => Output(new Output.SetPauseMode(false)));
|
||||
}
|
||||
|
||||
|
||||
public virtual Transition On(in Input.InventoryMenuToggle input) => To<Playing>();
|
||||
|
||||
public virtual Transition On(in Input.MiniMapButtonReleased input) => To<Playing>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user