Refactor minimap
This commit is contained in:
@@ -16,10 +16,6 @@ public partial class GameLogic
|
||||
|
||||
public readonly record struct CloseInventory;
|
||||
|
||||
public readonly record struct MiniMapButtonPressed;
|
||||
|
||||
public readonly record struct MiniMapButtonReleased;
|
||||
|
||||
public readonly record struct FloorExitReached;
|
||||
public readonly record struct HideFloorClearMenu;
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record MinimapOpen : Playing, IGet<Input.MiniMapButtonReleased>
|
||||
{
|
||||
public MinimapOpen()
|
||||
{
|
||||
this.OnEnter(() => { Get<IGameRepo>().Pause(); Output(new Output.ShowMiniMap()); });
|
||||
this.OnExit(() => { Get<IGameRepo>().Resume(); Output(new Output.HideMiniMap()); });
|
||||
}
|
||||
|
||||
public Transition On(in Input.MiniMapButtonReleased input) => To<Playing>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ public partial class GameLogic
|
||||
[Meta]
|
||||
public partial record Playing : State,
|
||||
IGet<Input.OpenInventory>,
|
||||
IGet<Input.MiniMapButtonPressed>,
|
||||
IGet<Input.GameOver>,
|
||||
IGet<Input.AskForTeleport>,
|
||||
IGet<Input.PauseGame>,
|
||||
@@ -25,7 +24,6 @@ public partial class GameLogic
|
||||
|
||||
public Transition On(in Input.OpenInventory input) => To<InventoryOpened>();
|
||||
|
||||
public Transition On(in Input.MiniMapButtonPressed input) => To<MinimapOpen>();
|
||||
|
||||
public Transition On(in Input.GameOver input) => To<Quit>();
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
public static class Input
|
||||
{
|
||||
public readonly record struct ShowMinimap;
|
||||
public readonly record struct HideMinimap;
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,7 @@ public partial class InGameUILogic
|
||||
public readonly record struct AnnounceMessageOnMainScreen(string Message);
|
||||
public readonly record struct AnnounceMessageInInventory(string Message);
|
||||
public readonly record struct RemoveItemFromInventory(IInventoryItem Item);
|
||||
public readonly record struct DisplayMinimap();
|
||||
public readonly record struct HideMinimap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ public partial class InGameUILogic
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Active : State
|
||||
public partial record Active : State, IGet<Input.ShowMinimap>
|
||||
{
|
||||
|
||||
public Transition On(in Input.ShowMinimap input) => To<MinimapOpen>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record MinimapOpen : State, IGet<Input.HideMinimap>
|
||||
{
|
||||
public MinimapOpen()
|
||||
{
|
||||
OnAttach(() => { Get<IGameRepo>().Pause(); Output(new Output.DisplayMinimap()); });
|
||||
OnDetach(() => { Get<IGameRepo>().Resume(); Output(new Output.HideMinimap()); });
|
||||
}
|
||||
|
||||
public Transition On(in Input.HideMinimap input) => To<Active>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,11 @@ public partial class Sproingy : Enemy, IHasPrimaryAttack, ICanPatrol
|
||||
if (_enemyLogic.Value is not EnemyLogic.State.Activated)
|
||||
return;
|
||||
|
||||
if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(_player.CurrentPosition) < 3.5f)
|
||||
if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(_player.CurrentPosition) < 1.5f)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.StartAttacking());
|
||||
if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(_player.CurrentPosition) > 30f)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.LostPlayer());
|
||||
if (_enemyLogic.Value is EnemyLogic.State.Attacking && GlobalPosition.DistanceTo(_player.CurrentPosition) > 5f)
|
||||
if (_enemyLogic.Value is EnemyLogic.State.Attacking && GlobalPosition.DistanceTo(_player.CurrentPosition) > 3f)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Alerted());
|
||||
|
||||
_navigationAgentClient.CalculateVelocity(GlobalPosition, true);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
[sub_resource type="Resource" id="Resource_oln85"]
|
||||
script = ExtResource("2_oln85")
|
||||
CurrentHP = 30.0
|
||||
MaximumHP = 30.0
|
||||
MaximumHP = 0
|
||||
CurrentAttack = 12
|
||||
CurrentDefense = 7
|
||||
MaxAttack = 12
|
||||
@@ -32,7 +32,7 @@ height = 5.0
|
||||
radius = 1.0
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_8vcnq"]
|
||||
radius = 0.762524
|
||||
radius = 0.57308
|
||||
|
||||
[node name="Sproingy" type="CharacterBody3D"]
|
||||
process_mode = 1
|
||||
|
||||
@@ -195,8 +195,6 @@ public partial class Game : Node3D, IGame
|
||||
.Handle((in GameLogic.Output.ExitFloorClearMenu _) => { FloorClearMenu.FadeOut(); })
|
||||
.Handle((in GameLogic.Output.OpenInventory _) => { InGameUI.ShowInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(true); })
|
||||
.Handle((in GameLogic.Output.CloseInventory _) => { InGameUI.HideInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(false); })
|
||||
.Handle((in GameLogic.Output.ShowMiniMap _) => { InGameUI.ShowMiniMap(); })
|
||||
.Handle((in GameLogic.Output.HideMiniMap _) => { InGameUI.HideMiniMap(); })
|
||||
.Handle((in GameLogic.Output.ShowAskForTeleport _) => { GameRepo.Pause(); InGameUI.UseTeleportPrompt.FadeIn(); InGameUI.SetProcessInput(true); })
|
||||
.Handle((in GameLogic.Output.HideAskForTeleport _) => { GameRepo.Resume(); InGameUI.UseTeleportPrompt.FadeOut(); InGameUI.SetProcessInput(false); })
|
||||
.Handle((in GameLogic.Output.ShowLostScreen _) => { DeathMenu.Show(); DeathMenu.FadeIn(); })
|
||||
@@ -218,7 +216,6 @@ public partial class Game : Node3D, IGame
|
||||
PauseMenu.TransitionCompleted += OnPauseMenuTransitioned;
|
||||
PauseMenu.UnpauseButtonPressed += PauseMenu_UnpauseButtonPressed;
|
||||
InGameUI.InventoryMenu.ClosedMenu += InventoryMenu_CloseInventory;
|
||||
InGameUI.MinimapButtonReleased += Player_MinimapButtonReleased;
|
||||
|
||||
InGameUI.UseTeleportPrompt.TeleportToNextFloor += UseTeleportPrompt_TeleportToNextFloor;
|
||||
InGameUI.UseTeleportPrompt.CloseTeleportPrompt += UseTeleportPrompt_CloseTeleportPrompt;
|
||||
@@ -256,11 +253,6 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Input(new GameLogic.Input.OpenInventory());
|
||||
}
|
||||
|
||||
public void ToggleMinimap()
|
||||
{
|
||||
GameLogic.Input(new GameLogic.Input.MiniMapButtonPressed());
|
||||
}
|
||||
|
||||
public void FloorExitReached()
|
||||
{
|
||||
GameLogic.Input(new GameLogic.Input.AskForTeleport());
|
||||
@@ -399,11 +391,6 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Input(new GameLogic.Input.PauseGame());
|
||||
}
|
||||
|
||||
private void Player_MinimapButtonReleased()
|
||||
{
|
||||
GameLogic.Input(new GameLogic.Input.MiniMapButtonReleased());
|
||||
}
|
||||
|
||||
private void FloorClearMenu_TransitionCompleted()
|
||||
{
|
||||
GameRepo.Resume();
|
||||
|
||||
@@ -29,8 +29,6 @@ public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvid
|
||||
|
||||
public void ToggleInventory();
|
||||
|
||||
public void ToggleMinimap();
|
||||
|
||||
public void FloorExitReached();
|
||||
|
||||
public void NextFloorLoaded();
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://by67pn7fdsg1m"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://by67pn7fdsg1m"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://14e8mu48ed4" path="res://src/map/Map.cs" id="1_bw70o"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl6h1djc27ddl" path="res://src/map/dungeon/floors/Floor00.tscn" id="2_0m8h8"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc1sp6xwe0j65" path="res://src/map/dungeon/floors/Floor01.tscn" id="2_merfv"]
|
||||
[ext_resource type="PackedScene" uid="uid://dmiqwmivkjgmq" path="res://src/map/dungeon/floors/Floor02.tscn" id="4_8y0oy"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl1scvkp8r5sw" path="res://src/map/dungeon/floors/Floor03.tscn" id="5_uag72"]
|
||||
[ext_resource type="PackedScene" uid="uid://cikq7vuorlpbl" path="res://src/map/dungeon/floors/Floor04.tscn" id="6_55rmo"]
|
||||
[ext_resource type="PackedScene" uid="uid://t7cac7801bnk" path="res://src/map/dungeon/floors/Floor05.tscn" id="7_f6kwn"]
|
||||
[ext_resource type="PackedScene" uid="uid://da107mywg18x1" path="res://src/map/dungeon/floors/Floor06.tscn" id="8_ne2vg"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgtqjgh1f5fqi" path="res://src/map/dungeon/floors/Floor07.tscn" id="9_abpbr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dg20ovvj2m2lp" path="res://src/map/dungeon/floors/Floor08.tscn" id="10_caf7v"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5jk743ng6fqg" path="res://src/map/dungeon/floors/Floor09.tscn" id="11_y74f3"]
|
||||
|
||||
[node name="Map" type="Node3D"]
|
||||
script = ExtResource("1_bw70o")
|
||||
_floors = Array[PackedScene]([ExtResource("2_0m8h8"), ExtResource("2_merfv"), ExtResource("4_8y0oy"), ExtResource("5_uag72")])
|
||||
_floors = Array[PackedScene]([ExtResource("2_0m8h8"), ExtResource("2_merfv"), ExtResource("4_8y0oy"), ExtResource("5_uag72"), ExtResource("6_55rmo"), ExtResource("7_f6kwn"), ExtResource("8_ne2vg"), ExtResource("9_abpbr"), ExtResource("10_caf7v"), ExtResource("11_y74f3")])
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
|
||||
@@ -12,8 +12,6 @@ public interface IPlayer : IKillable, IProvide<ISaveChunk<PlayerData>>
|
||||
|
||||
public void ToggleInventory();
|
||||
|
||||
public void ToggleMinimap();
|
||||
|
||||
public void PlayerPause();
|
||||
|
||||
public void TakeDamage(double damage, ElementType elementType = ElementType.None, bool isCriticalHit = false);
|
||||
|
||||
@@ -271,11 +271,6 @@ public partial class Player : CharacterBody3D, IPlayer
|
||||
Game.ToggleInventory();
|
||||
}
|
||||
|
||||
public void ToggleMinimap()
|
||||
{
|
||||
Game.ToggleMinimap();
|
||||
}
|
||||
|
||||
public void PlayerPause()
|
||||
{
|
||||
Game.TogglePause();
|
||||
@@ -404,9 +399,6 @@ public partial class Player : CharacterBody3D, IPlayer
|
||||
if (@event.IsActionPressed(GameInputs.Inventory))
|
||||
ToggleInventory();
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.MiniMap))
|
||||
ToggleMinimap();
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.Pause))
|
||||
PlayerPause();
|
||||
|
||||
|
||||
@@ -64,17 +64,31 @@ public partial class InGameUI : Control, IInGameUI
|
||||
.Handle((in InGameUILogic.Output.RemoveItemFromInventory output) =>
|
||||
{
|
||||
InventoryMenu.RemoveItem(output.Item);
|
||||
})
|
||||
.Handle((in InGameUILogic.Output.DisplayMinimap _) =>
|
||||
{
|
||||
ShowMiniMap();
|
||||
})
|
||||
.Handle((in InGameUILogic.Output.HideMinimap _) =>
|
||||
{
|
||||
HideMiniMap();
|
||||
});
|
||||
;
|
||||
|
||||
InGameUILogic.Start();
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionPressed(GameInputs.MiniMap))
|
||||
{
|
||||
GD.Print("MiniMap button pressed");
|
||||
InGameUILogic.Input(new InGameUILogic.Input.ShowMinimap());
|
||||
}
|
||||
if (@event.IsActionReleased(GameInputs.MiniMap))
|
||||
{
|
||||
GD.Print("MiniMap button released");
|
||||
EmitSignal(SignalName.MinimapButtonReleased);
|
||||
InGameUILogic.Input(new InGameUILogic.Input.HideMinimap());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user