Implement Equip/Unequip SFX
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -25,6 +25,10 @@ public interface IGameRepo : IDisposable
|
||||
|
||||
event Action? PlayerAttackedEnemy;
|
||||
|
||||
event Action<EquipableItem>? EquippedItem;
|
||||
|
||||
event Action<EquipableItem>? 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<EquipableItem>? EquippedItem;
|
||||
public event Action<EquipableItem>? UnequippedItem;
|
||||
|
||||
public IAutoProp<bool> IsPaused => _isPaused;
|
||||
private readonly AutoProp<bool> _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();
|
||||
|
||||
@@ -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!;
|
||||
@@ -74,6 +76,7 @@ public partial class InGameAudio : Node
|
||||
.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())
|
||||
@@ -116,6 +119,12 @@ public partial class InGameAudio : Node
|
||||
EquipSFX.Play();
|
||||
}
|
||||
|
||||
private void PlayUnequipSound()
|
||||
{
|
||||
UnequipSFX.Stop();
|
||||
UnequipSFX.Play();
|
||||
}
|
||||
|
||||
private void PlayMenuBackSound()
|
||||
{
|
||||
MenuBackSFX.Stop();
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
@@ -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
|
||||
BIN
Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav
Normal file
BIN
Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav
Normal file
Binary file not shown.
24
Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav.import
Normal file
24
Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.wav.import
Normal file
@@ -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
|
||||
BIN
Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav
Normal file
BIN
Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav
Normal file
Binary file not shown.
24
Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav.import
Normal file
24
Zennysoft.Game.Ma/src/audio/sfx/UnequipSFX.wav.import
Normal file
@@ -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
|
||||
@@ -384,6 +384,9 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
|
||||
public void Equip(EquipableItem equipable)
|
||||
{
|
||||
if (string.IsNullOrEmpty(equipable.ItemName))
|
||||
return;
|
||||
|
||||
if (equipable is Weapon weapon)
|
||||
{
|
||||
Unequip(_equippedWeapon.Value);
|
||||
@@ -404,10 +407,15 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
}
|
||||
else
|
||||
throw new NotImplementedException("Item type is not supported.");
|
||||
|
||||
_gameRepo.OnEquippedItem(equipable);
|
||||
}
|
||||
|
||||
public void Unequip(EquipableItem equipable)
|
||||
{
|
||||
if (string.IsNullOrEmpty(equipable.ItemName))
|
||||
return;
|
||||
|
||||
if (equipable is Weapon weapon)
|
||||
{
|
||||
weapon.IsEquipped = false;
|
||||
@@ -435,6 +443,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
|
||||
if (equipable.ItemTag == ItemTag.BreaksOnChange)
|
||||
Inventory.Remove(equipable);
|
||||
|
||||
_gameRepo.OnUnequippedItem(equipable);
|
||||
}
|
||||
|
||||
private static Vector3 GlobalInputVector
|
||||
|
||||
Reference in New Issue
Block a user