diff --git a/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs b/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs index 925aa2d1..83640152 100644 --- a/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs +++ b/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs @@ -21,6 +21,8 @@ public partial class InGameAudioLogic public readonly record struct PlayEquipSound; + public readonly record struct PlayUnequipSound; + public readonly record struct PlayInventorySortedSound; public readonly record struct PlayMenuBackSound; diff --git a/Zennysoft.Game.Ma.Implementation/Audio/state/states/InGameAudioLogic.State.Enabled.cs b/Zennysoft.Game.Ma.Implementation/Audio/state/states/InGameAudioLogic.State.Enabled.cs index bc5c34e7..18ccbcf1 100644 --- a/Zennysoft.Game.Ma.Implementation/Audio/state/states/InGameAudioLogic.State.Enabled.cs +++ b/Zennysoft.Game.Ma.Implementation/Audio/state/states/InGameAudioLogic.State.Enabled.cs @@ -20,9 +20,8 @@ public partial class InGameAudioLogic gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered; gameEventDepot.MenuScrolled += OnMenuScrolled; gameEventDepot.MenuBackedOut += OnMenuBackedOut; - player.EquippedWeapon.Changed += OnEquippedItem; - player.EquippedArmor.Changed += OnEquippedItem; - player.EquippedAccessory.Changed += OnEquippedItem; + gameRepo.EquippedItem += OnEquippedItem; + gameRepo.UnequippedItem += OnUnequippedItem; gameEventDepot.InventorySorted += OnInventorySorted; gameEventDepot.HealingItemConsumed += OnHealingItemConsumed; gameEventDepot.RestorativePickedUp += OnRestorativePickedUp; @@ -39,9 +38,8 @@ public partial class InGameAudioLogic gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered; gameEventDepot.MenuScrolled -= OnMenuScrolled; gameEventDepot.MenuBackedOut -= OnMenuBackedOut; - player.EquippedWeapon.Changed -= OnEquippedItem; - player.EquippedArmor.Changed -= OnEquippedItem; - player.EquippedAccessory.Changed -= OnEquippedItem; + gameRepo.EquippedItem -= OnEquippedItem; + gameRepo.UnequippedItem -= OnUnequippedItem; gameEventDepot.InventorySorted -= OnInventorySorted; gameEventDepot.TeleportEntered -= OnTeleportEntered; gameRepo.PlayerAttack -= OnPlayerAttack; @@ -63,6 +61,8 @@ public partial class InGameAudioLogic private void OnEquippedItem(InventoryItem equipableItem) => Output(new Output.PlayEquipSound()); + private void OnUnequippedItem(InventoryItem equipableItem) => Output(new Output.PlayUnequipSound()); + private void OnOverworldEntered() => Output(new Output.PlayOverworldMusic()); private void OnDungeonAThemeEntered() => Output(new Output.PlayDungeonThemeAMusic()); diff --git a/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs b/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs index 3fad5786..b2640f87 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs @@ -25,6 +25,10 @@ public interface IGameRepo : IDisposable event Action? PlayerAttackedEnemy; + event Action? EquippedItem; + + event Action? UnequippedItem; + void Pause(); void Resume(); @@ -51,6 +55,10 @@ public interface IGameRepo : IDisposable public void GameEnded(); + public void OnEquippedItem(EquipableItem item); + + public void OnUnequippedItem(EquipableItem item); + public double ExpRate { get; } } @@ -66,6 +74,8 @@ public class GameRepo : IGameRepo public event Action? PlayerAttack; public event Action? PlayerAttackedWall; public event Action? PlayerAttackedEnemy; + public event Action? EquippedItem; + public event Action? UnequippedItem; public IAutoProp IsPaused => _isPaused; private readonly AutoProp _isPaused; @@ -141,6 +151,10 @@ public class GameRepo : IGameRepo CloseInventoryEvent?.Invoke(); } + public void OnEquippedItem(EquipableItem item) => EquippedItem?.Invoke(item); + + public void OnUnequippedItem(EquipableItem item) => UnequippedItem?.Invoke(item); + public void GameEnded() { Pause(); diff --git a/Zennysoft.Game.Ma/src/audio/InGameAudio.cs b/Zennysoft.Game.Ma/src/audio/InGameAudio.cs index fdee1386..d131805b 100644 --- a/Zennysoft.Game.Ma/src/audio/InGameAudio.cs +++ b/Zennysoft.Game.Ma/src/audio/InGameAudio.cs @@ -43,6 +43,8 @@ public partial class InGameAudio : Node [Node] public IAudioStreamPlayer EquipSFX { get; set; } = default!; + [Node] public IAudioStreamPlayer UnequipSFX { get; set; } = default!; + [Node] public IAudioStreamPlayer MenuBackSFX { get; set; } = default!; [Node] public IAudioStreamPlayer InventorySortedSFX { get; set; } = default!; @@ -57,86 +59,93 @@ public partial class InGameAudio : Node public void Setup() { - InGameAudioLogic = new InGameAudioLogic(); + InGameAudioLogic = new InGameAudioLogic(); } public void OnResolved() { - InGameAudioLogic.Set(AppRepo); - InGameAudioLogic.Set(GameEventDepot); - InGameAudioLogic.Set(Player); - InGameAudioLogic.Set(GameRepo); + InGameAudioLogic.Set(AppRepo); + InGameAudioLogic.Set(GameEventDepot); + InGameAudioLogic.Set(Player); + InGameAudioLogic.Set(GameRepo); - InGameAudioBinding = InGameAudioLogic.Bind(); + InGameAudioBinding = InGameAudioLogic.Bind(); - InGameAudioBinding - .Handle((in InGameAudioLogic.Output.PlayOverworldMusic _) => StartOverworldMusic()) - .Handle((in InGameAudioLogic.Output.PlayDungeonThemeAMusic _) => StartDungeonThemeA()) - .Handle((in InGameAudioLogic.Output.PlayMenuScrollSound _) => PlayMenuScrollSound()) - .Handle((in InGameAudioLogic.Output.PlayEquipSound _) => PlayEquipSound()) - .Handle((in InGameAudioLogic.Output.PlayMenuBackSound _) => PlayMenuBackSound()) - .Handle((in InGameAudioLogic.Output.PlayInventorySortedSound _) => PlayInventorySortedSound()) - .Handle((in InGameAudioLogic.Output.PlayHealingItemSound _) => PlayHealingItemSound()) - .Handle((in InGameAudioLogic.Output.PlayTeleportSound _) => PlayTeleportSound()) - .Handle((in InGameAudioLogic.Output.PlayPlayerAttackSound _) => { PlayerAttackSFX.Stop(); PlayerAttackSFX.Play(); }) - .Handle((in InGameAudioLogic.Output.PlayPlayerAttackWallSound _) => { PlayerAttackWallSFX.Stop(); PlayerAttackWallSFX.Play(); }) - .Handle((in InGameAudioLogic.Output.PlayPlayerAttackEnemySound _) => { PlayerAttackEnemySFX.Stop(); PlayerAttackEnemySFX.Play(); }); + InGameAudioBinding + .Handle((in InGameAudioLogic.Output.PlayOverworldMusic _) => StartOverworldMusic()) + .Handle((in InGameAudioLogic.Output.PlayDungeonThemeAMusic _) => StartDungeonThemeA()) + .Handle((in InGameAudioLogic.Output.PlayMenuScrollSound _) => PlayMenuScrollSound()) + .Handle((in InGameAudioLogic.Output.PlayEquipSound _) => PlayEquipSound()) + .Handle((in InGameAudioLogic.Output.PlayUnequipSound _) => PlayUnequipSound()) + .Handle((in InGameAudioLogic.Output.PlayMenuBackSound _) => PlayMenuBackSound()) + .Handle((in InGameAudioLogic.Output.PlayInventorySortedSound _) => PlayInventorySortedSound()) + .Handle((in InGameAudioLogic.Output.PlayHealingItemSound _) => PlayHealingItemSound()) + .Handle((in InGameAudioLogic.Output.PlayTeleportSound _) => PlayTeleportSound()) + .Handle((in InGameAudioLogic.Output.PlayPlayerAttackSound _) => { PlayerAttackSFX.Stop(); PlayerAttackSFX.Play(); }) + .Handle((in InGameAudioLogic.Output.PlayPlayerAttackWallSound _) => { PlayerAttackWallSFX.Stop(); PlayerAttackWallSFX.Play(); }) + .Handle((in InGameAudioLogic.Output.PlayPlayerAttackEnemySound _) => { PlayerAttackEnemySFX.Stop(); PlayerAttackEnemySFX.Play(); }); - InGameAudioLogic.Start(); + InGameAudioLogic.Start(); } public void OnExitTree() { - InGameAudioLogic.Stop(); - InGameAudioBinding.Dispose(); + InGameAudioLogic.Stop(); + InGameAudioBinding.Dispose(); } private void StartOverworldMusic() { - OverworldBgm.Stop(); - OverworldBgm.FadeIn(); + OverworldBgm.Stop(); + OverworldBgm.FadeIn(); } private void StartDungeonThemeA() { - OverworldBgm.FadeOut(); - DungeonThemeABgm.Stop(); - DungeonThemeABgm.FadeIn(); + OverworldBgm.FadeOut(); + DungeonThemeABgm.Stop(); + DungeonThemeABgm.FadeIn(); } private void PlayMenuScrollSound() { - MenuScrollSFX.Stop(); - MenuScrollSFX.Play(); + MenuScrollSFX.Stop(); + MenuScrollSFX.Play(); } private void PlayEquipSound() { - EquipSFX.Stop(); - EquipSFX.Play(); + EquipSFX.Stop(); + EquipSFX.Play(); + } + + private void PlayUnequipSound() + { + UnequipSFX.Stop(); + UnequipSFX.Play(); } private void PlayMenuBackSound() { - MenuBackSFX.Stop(); - MenuBackSFX.Play(); + MenuBackSFX.Stop(); + MenuBackSFX.Play(); } private void PlayInventorySortedSound() { - InventorySortedSFX.Stop(); - InventorySortedSFX.Play(); + InventorySortedSFX.Stop(); + InventorySortedSFX.Play(); } private void PlayHealingItemSound() { - HealingItemSFX.Stop(); - HealingItemSFX.Play(); + HealingItemSFX.Stop(); + HealingItemSFX.Play(); } private void PlayTeleportSound() { - TeleportSFX.Stop(); - TeleportSFX.Play(); + TeleportSFX.Stop(); + TeleportSFX.Play(); } } diff --git a/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn b/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn index 797300ce..8dd53c20 100644 --- a/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn +++ b/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3 uid="uid://b16ejcwanod72"] +[gd_scene load_steps=17 format=3 uid="uid://b16ejcwanod72"] [ext_resource type="Script" uid="uid://2mnouyn1jcqs" path="res://src/audio/InGameAudio.cs" id="1_gpmcr"] [ext_resource type="AudioStream" uid="uid://dfu0fksb6slhx" path="res://src/audio/music/droney.mp3" id="2_8hfyr"] @@ -10,11 +10,12 @@ [ext_resource type="AudioStream" uid="uid://dor0in0x2fg48" path="res://src/audio/sfx/MenuScrollSFX.ogg" id="7_777nl"] [ext_resource type="AudioStream" uid="uid://d1mlduwauechv" path="res://src/audio/sfx/PlayerAttackSFX.wav" id="7_wtvpb"] [ext_resource type="AudioStream" uid="uid://r1tryiit38i8" path="res://src/audio/sfx/MenuBackSFX.ogg" id="8_1xcgo"] -[ext_resource type="AudioStream" uid="uid://bjj61s8q2gwb8" path="res://src/audio/sfx/EquipSFX.ogg" id="8_kwybb"] [ext_resource type="AudioStream" uid="uid://4u8f1tpgs08b" path="res://src/audio/sfx/PlayerHitEnemySFX.wav" id="9_hertr"] [ext_resource type="AudioStream" uid="uid://myx4s8lmarc2" path="res://src/audio/sfx/HealSFX.ogg" id="10_3lcw5"] [ext_resource type="AudioStream" uid="uid://dci08kmwsu6k1" path="res://src/audio/sfx/ExitSFX.ogg" id="11_offhc"] +[ext_resource type="AudioStream" uid="uid://d0wd6xgjoadbc" path="res://src/audio/sfx/EquipSFX.wav" id="12_hertr"] [ext_resource type="AudioStream" uid="uid://d3sn7c614uj2n" path="res://src/audio/sfx/SortSFX.ogg" id="12_wprjr"] +[ext_resource type="AudioStream" uid="uid://f5agx4ewe04d" path="res://src/audio/sfx/UnequipSFX.wav" id="13_y7w0c"] [node name="InGameAudio" type="Node"] process_mode = 3 @@ -88,8 +89,11 @@ volume_db = -10.0 [node name="EquipSFX" type="AudioStreamPlayer" parent="SFX"] unique_name_in_owner = true -stream = ExtResource("8_kwybb") -volume_db = -10.0 +stream = ExtResource("12_hertr") + +[node name="UnequipSFX" type="AudioStreamPlayer" parent="SFX"] +unique_name_in_owner = true +stream = ExtResource("13_y7w0c") [node name="HealSFX" type="AudioStreamPlayer" parent="SFX"] unique_name_in_owner = true diff --git a/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg deleted file mode 100644 index 9fc560d1..00000000 Binary files a/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg and /dev/null differ diff --git a/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg.import deleted file mode 100644 index 19e16920..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg.import +++ /dev/null @@ -1,19 +0,0 @@ -[remap] - -importer="oggvorbisstr" -type="AudioStreamOggVorbis" -uid="uid://bjj61s8q2gwb8" -path="res://.godot/imported/EquipSFX.ogg-6a8dd8843f1eb38662d6d370e4b2f930.oggvorbisstr" - -[deps] - -source_file="res://src/audio/sfx/EquipSFX.ogg" -dest_files=["res://.godot/imported/EquipSFX.ogg-6a8dd8843f1eb38662d6d370e4b2f930.oggvorbisstr"] - -[params] - -loop=false -loop_offset=0 -bpm=0 -beat_count=0 -bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav new file mode 100644 index 00000000..e012177d Binary files /dev/null and b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav differ diff --git a/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav.import b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav.import new file mode 100644 index 00000000..b519aa9e --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://d0wd6xgjoadbc" +path="res://.godot/imported/EquipSFX.wav-ec813b83f09b5b1011f86476dc0f2aba.sample" + +[deps] + +source_file="res://src/audio/sfx/EquipSFX.wav" +dest_files=["res://.godot/imported/EquipSFX.wav-ec813b83f09b5b1011f86476dc0f2aba.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav b/Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav new file mode 100644 index 00000000..b887fe16 Binary files /dev/null and b/Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav differ diff --git a/Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav.import b/Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav.import new file mode 100644 index 00000000..31a09034 --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://f5agx4ewe04d" +path="res://.godot/imported/UnequipSFX.wav-b40e3365fde607f5fc81ee5c782ed02e.sample" + +[deps] + +source_file="res://src/audio/sfx/UnequipSFX.wav" +dest_files=["res://.godot/imported/UnequipSFX.wav-b40e3365fde607f5fc81ee5c782ed02e.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index 50666fe0..06034d43 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -384,6 +384,9 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide