More inventory menu improvements

This commit is contained in:
2024-09-13 16:43:10 -07:00
parent f0e75703f6
commit 1d7d70e033
41 changed files with 995 additions and 275 deletions

View File

@@ -4,7 +4,9 @@ namespace GameJamDungeon;
using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using DialogueManagerRuntime;
using Godot;
using System;
public interface IGame : IProvide<IGameRepo>, IProvide<IGame>, INode3D
{
@@ -36,9 +38,11 @@ public partial class Game : Node3D, IGame
#region Nodes
[Node] public IMap Map { get; set; } = default!;
[Node] public IPlayer Player { get; set; } = default!;
[Node] public InGameUI InGameUI { get; set; } = default!;
[Node] public FloorClearMenu FloorClearMenu { get; set; } = default!;
[Node] public IFloorClearMenu FloorClearMenu { get; set; } = default!;
[Node] public DeathMenu DeathMenu { get; set; } = default!;
@@ -54,40 +58,6 @@ public partial class Game : Node3D, IGame
Instantiator = new Instantiator(GetTree());
}
private void PlayerInventory_InventoryAtCapacity(string rejectedItem)
{
InGameUI.PlayerInfoUI.DisplayInventoryFullMessage(rejectedItem);
}
private void OnInventoryAtCapacity(string rejectedItemName) => InGameUI.PlayerInfoUI.DisplayInventoryFullMessage(rejectedItemName);
private void InventoryMenu_CloseInventory() => GameLogic.Input(new GameLogic.Input.InventoryMenuToggle());
private void Map_DungeonFinishedGenerating()
{
GameRepo.SetPlayerGlobalPosition(Map.GetPlayerSpawnPosition());
}
private void Map_DialogueChoiceMade()
{
GameRepo.Resume();
}
private void Map_TeleportReached()
{
GameRepo.Pause();
}
private void OnFloorClearTransitionCompleted()
{
GameLogic.Input(new GameLogic.Input.FloorClearTransitioned());
}
private void OnPauseMenuTransitioned()
{
GameLogic.Input(new GameLogic.Input.PauseMenuTransitioned());
}
public void OnResolved()
{
GameBinding = GameLogic.Bind();
@@ -101,13 +71,19 @@ public partial class Game : Node3D, IGame
{
PauseMenu.Show();
PauseMenu.FadeIn();
Input.MouseMode = Input.MouseModeEnum.Visible;
PauseMenu.SetProcessUnhandledInput(true);
})
.Handle((in GameLogic.Output.LoadNextFloor _) =>
{
Map.SpawnNextFloor();
})
.Handle((in GameLogic.Output.HidePauseMenu _) => { PauseMenu.Hide(); })
.Handle((in GameLogic.Output.ExitPauseMenu _) => { PauseMenu.FadeOut(); })
.Handle((in GameLogic.Output.ExitPauseMenu _) => { PauseMenu.FadeOut(); Input.MouseMode = Input.MouseModeEnum.Captured; PauseMenu.SetProcessUnhandledInput(false); })
.Handle((in GameLogic.Output.ShowFloorClearMenu _) => { FloorClearMenu.Show(); FloorClearMenu.FadeIn(); })
.Handle((in GameLogic.Output.ExitFloorClearMenu _) => { FloorClearMenu.FadeOut(); })
.Handle((in GameLogic.Output.SetInventoryMode _) => { InGameUI.ShowInventoryScreen(); })
.Handle((in GameLogic.Output.HideInventory _) => { InGameUI.HideInventoryScreen(); })
.Handle((in GameLogic.Output.OpenInventory _) => { InGameUI.ShowInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(true); })
.Handle((in GameLogic.Output.HideInventory _) => { InGameUI.HideInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(false); })
.Handle((in GameLogic.Output.ShowMiniMap _) => { InGameUI.ShowMiniMap(); })
.Handle((in GameLogic.Output.HideMiniMap _) => { InGameUI.HideMiniMap(); })
.Handle((in GameLogic.Output.ShowLostScreen _) => { DeathMenu.Show(); DeathMenu.FadeIn(); })
@@ -118,14 +94,69 @@ public partial class Game : Node3D, IGame
this.Provide();
FloorClearMenu.TransitionCompleted += OnFloorClearTransitionCompleted;
PauseMenu.TransitionCompleted += OnPauseMenuTransitioned;
PauseMenu.UnpauseButtonPressed += PauseMenu_UnpauseButtonPressed;
Map.TeleportReached += Map_TeleportReached;
Map.DialogueDecisionMade += Map_DialogueChoiceMade;
Map.DungeonFinishedGenerating += Map_DungeonFinishedGenerating;
InGameUI.InventoryMenu.ClosedMenu += InventoryMenu_CloseInventory;
InGameUI.MinimapButtonReleased += Player_MinimapButtonReleased;
GameRepo.PlayerData.Inventory.InventoryAtCapacity += PlayerInventory_InventoryAtCapacity;
GameRepo.PlayerData.Inventory.RaiseStatRequest += Inventory_RaiseStatRequest;
FloorClearMenu.GoToNextFloor += FloorClearMenu_GoToNextFloor;
FloorClearMenu.ReturnToHubWorld += ReturnToHubWorld;
FloorClearMenu.TransitionCompleted += FloorClearMenu_TransitionCompleted;
Player.InventoryButtonPressed += Player_InventoryButtonPressed;
Player.MinimapButtonHeld += Player_MinimapButtonHeld;
Player.PauseButtonPressed += Player_PauseButtonPressed;
}
private void PauseMenu_UnpauseButtonPressed()
{
GameLogic.Input(new GameLogic.Input.UnpauseGame());
}
private void Player_PauseButtonPressed()
{
GameLogic.Input(new GameLogic.Input.PauseGame());
}
private void Player_MinimapButtonReleased()
{
GameLogic.Input(new GameLogic.Input.MiniMapButtonReleased());
}
private void Player_MinimapButtonHeld()
{
GameLogic.Input(new GameLogic.Input.MiniMapButtonPressed());
}
private void Player_InventoryButtonPressed()
{
GameLogic.Input(new GameLogic.Input.OpenInventory());
}
private void FloorClearMenu_TransitionCompleted()
{
GameRepo.Resume();
}
private void FloorClearMenu_GoToNextFloor()
{
GameLogic.Input(new GameLogic.Input.GoToNextFloor());
}
private void ReturnToHubWorld()
{
// Implement a return to overworld state
// Don't carry over stats/equipment but we'll need to persist the overworld state
// Which may include rescued items and npc/questline state
GameLogic.Input(new GameLogic.Input.HideFloorClearMenu());
}
public void GoToNextFloor()
{
GameLogic.Input(new GameLogic.Input.FloorExitReached());
}
private void Inventory_RaiseStatRequest(ConsumableItemStats consumableItemStats)
@@ -143,7 +174,7 @@ public partial class Game : Node3D, IGame
private void RaiseHP(int amountToRaise)
{
if (GameRepo.PlayerData.CurrentHP == GameRepo.PlayerData.MaximumHP)
if (GameRepo.PlayerData.CurrentHP.Value == GameRepo.PlayerData.MaximumHP.Value)
{
GameRepo.PlayerData.SetMaximumHP(GameRepo.PlayerData.MaximumHP.Value + amountToRaise);
GameRepo.PlayerData.SetCurrentHP(GameRepo.PlayerData.MaximumHP.Value);
@@ -151,38 +182,6 @@ public partial class Game : Node3D, IGame
}
}
public void ToggleInventory()
{
GameLogic.Input(new GameLogic.Input.InventoryMenuToggle());
}
public override void _UnhandledInput(InputEvent @event)
{
if (@event.IsActionPressed(GameInputs.Inventory))
{
GD.Print("Inventory button pressed");
GameLogic.Input(new GameLogic.Input.InventoryMenuToggle());
}
if (@event.IsActionPressed(GameInputs.MiniMap))
{
GD.Print("MiniMap button pressed");
GameLogic.Input(new GameLogic.Input.MiniMapButtonPressed());
}
if (@event.IsActionReleased(GameInputs.MiniMap))
{
GD.Print("MiniMap button released");
GameLogic.Input(new GameLogic.Input.MiniMapButtonReleased());
}
if (@event.IsActionPressed(GameInputs.Pause))
{
GD.Print("Pause button pressed");
GameLogic.Input(new GameLogic.Input.PauseButtonPressed());
}
}
private void SetPauseMode(bool isPaused)
{
if (GetTree() != null)
@@ -197,7 +196,7 @@ public partial class Game : Node3D, IGame
private void RaiseVT(int amountToRaise)
{
if (GameRepo.PlayerData.CurrentVT == GameRepo.PlayerData.MaximumVT)
if (GameRepo.PlayerData.CurrentVT.Value == GameRepo.PlayerData.MaximumVT.Value)
{
GameRepo.PlayerData.SetMaximumVT(GameRepo.PlayerData.MaximumVT.Value + amountToRaise);
GameRepo.PlayerData.SetCurrentVT(GameRepo.PlayerData.MaximumVT.Value);
@@ -211,5 +210,33 @@ public partial class Game : Node3D, IGame
EmitSignal(SignalName.StatRaisedAlert, $"{amountToRaise}VT Up.");
}
private void PlayerInventory_InventoryAtCapacity(string rejectedItem)
{
InGameUI.PlayerInfoUI.DisplayInventoryFullMessage(rejectedItem);
}
private void OnInventoryAtCapacity(string rejectedItemName) => InGameUI.PlayerInfoUI.DisplayInventoryFullMessage(rejectedItemName);
private void InventoryMenu_CloseInventory() => GameLogic.Input(new GameLogic.Input.CloseInventory());
private void Map_DungeonFinishedGenerating()
{
GameRepo.SetPlayerGlobalPosition(Map.GetPlayerSpawnPosition());
GameLogic.Input(new GameLogic.Input.HideFloorClearMenu());
}
private void Map_TeleportReached()
{
GameRepo.Pause();
DialogueManager.GetCurrentScene = (() => this);
var dialogueResource = GD.Load<Resource>("res://src/ui/dialogue/FloorExit.dialogue");
DialogueController.ShowDialogue(dialogueResource, "floor_exit");
}
private void OnPauseMenuTransitioned()
{
GameLogic.Input(new GameLogic.Input.PauseMenuTransitioned());
}
public void OnStart() => GameLogic.Input(new GameLogic.Input.StartGame());
}