Implement Equip/Unequip SFX
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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