Implement BGM and SFX event system
This commit is contained in:
@@ -4,11 +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
|
||||
public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvide<IGame>, INode3D
|
||||
{
|
||||
event Game.StatRaisedAlertEventHandler StatRaisedAlert;
|
||||
}
|
||||
@@ -22,10 +20,14 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
IGame IProvide<IGame>.Value() => this;
|
||||
|
||||
IGameEventDepot IProvide<IGameEventDepot>.Value() => GameEventDepot;
|
||||
|
||||
public IInstantiator Instantiator { get; set; } = default!;
|
||||
|
||||
public IGameLogic GameLogic { get; set; } = default!;
|
||||
|
||||
public IGameEventDepot GameEventDepot { get; set; } = default!;
|
||||
|
||||
public IGameRepo GameRepo { get; set; } = default!;
|
||||
|
||||
public GameLogic.IBinding GameBinding { get; set; } = default!;
|
||||
@@ -47,14 +49,18 @@ public partial class Game : Node3D, IGame
|
||||
[Node] public DeathMenu DeathMenu { get; set; } = default!;
|
||||
|
||||
[Node] public IPauseMenu PauseMenu { get; set; } = default!;
|
||||
|
||||
[Node] public InGameAudio InGameAudio { get; set; } = default!;
|
||||
#endregion
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
GameRepo = new GameRepo();
|
||||
GameLogic = new GameLogic();
|
||||
GameEventDepot = new GameEventDepot();
|
||||
GameLogic.Set(GameRepo);
|
||||
GameLogic.Set(AppRepo);
|
||||
GameLogic.Set(GameEventDepot);
|
||||
Instantiator = new Instantiator(GetTree());
|
||||
}
|
||||
|
||||
@@ -66,6 +72,10 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
InGameUI.Show();
|
||||
})
|
||||
.Handle((in GameLogic.Output.GoToOverworld _) =>
|
||||
{
|
||||
GameEventDepot.OnOverworldEntered();
|
||||
})
|
||||
.Handle((in GameLogic.Output.SetPauseMode output) => CallDeferred(nameof(SetPauseMode), output.IsPaused))
|
||||
.Handle((in GameLogic.Output.ShowPauseMenu _) =>
|
||||
{
|
||||
@@ -93,12 +103,13 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Start();
|
||||
|
||||
GameLogic.Input(new GameLogic.Input.Initialize());
|
||||
InGameAudio.OverworldBgm.FadeIn();
|
||||
|
||||
this.Provide();
|
||||
|
||||
PauseMenu.TransitionCompleted += OnPauseMenuTransitioned;
|
||||
PauseMenu.UnpauseButtonPressed += PauseMenu_UnpauseButtonPressed;
|
||||
Map.TeleportReached += Map_TeleportReached;
|
||||
GameEventDepot.TeleportEntered += Map_TeleportReached;
|
||||
Map.DungeonFinishedGenerating += Map_DungeonFinishedGenerating;
|
||||
InGameUI.InventoryMenu.ClosedMenu += InventoryMenu_CloseInventory;
|
||||
InGameUI.MinimapButtonReleased += Player_MinimapButtonReleased;
|
||||
@@ -115,6 +126,13 @@ public partial class Game : Node3D, IGame
|
||||
Player.InventoryButtonPressed += Player_InventoryButtonPressed;
|
||||
Player.MinimapButtonHeld += Player_MinimapButtonHeld;
|
||||
Player.PauseButtonPressed += Player_PauseButtonPressed;
|
||||
|
||||
GameRepo.PlayerData.Inventory.EquippedItem += Inventory_EquippedItem;
|
||||
}
|
||||
|
||||
private void Inventory_EquippedItem()
|
||||
{
|
||||
GameEventDepot.OnEquippedItem();
|
||||
}
|
||||
|
||||
private void UseTeleportPrompt_CloseTeleportPrompt()
|
||||
@@ -125,6 +143,7 @@ public partial class Game : Node3D, IGame
|
||||
private void UseTeleportPrompt_TeleportToNextFloor()
|
||||
{
|
||||
GameLogic.Input(new GameLogic.Input.FloorExitReached());
|
||||
GameEventDepot.OnDungeonAThemeAreaEntered();
|
||||
}
|
||||
|
||||
private void PauseMenu_UnpauseButtonPressed()
|
||||
@@ -170,10 +189,6 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Input(new GameLogic.Input.HideFloorClearMenu());
|
||||
}
|
||||
|
||||
public void GoToNextFloor()
|
||||
{
|
||||
GameLogic.Input(new GameLogic.Input.FloorExitReached());
|
||||
}
|
||||
|
||||
private void Inventory_RaiseStatRequest(ConsumableItemStats consumableItemStats)
|
||||
{
|
||||
@@ -186,6 +201,8 @@ public partial class Game : Node3D, IGame
|
||||
RaiseVT(consumableItemStats.RaiseVTAmount);
|
||||
else if (consumableItemStats.HealVTAmount > 0)
|
||||
HealVT(consumableItemStats.HealVTAmount);
|
||||
|
||||
GameEventDepot.OnHealingItemConsumed(consumableItemStats);
|
||||
}
|
||||
|
||||
private void RaiseHP(int amountToRaise)
|
||||
|
||||
Reference in New Issue
Block a user