Started implementing SFX
Fixed Shield animation jumps and secondary attack Fixed demon wall stone behavior Made overworld ambient sounds unpausable
This commit is contained in:
108
Zennysoft.Game.Ma/src/audio/SfxDatabase.cs
Normal file
108
Zennysoft.Game.Ma/src/audio/SfxDatabase.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[Meta(typeof(IAutoNode)), Id("sfx_database")]
|
||||
public partial class SfxDatabase : Node
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
private static SfxDatabase _instance;
|
||||
|
||||
public static SfxDatabase Instance => _instance;
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
if (_instance != null)
|
||||
QueueFree();
|
||||
_instance = this;
|
||||
|
||||
_sfxMap = new Dictionary<SoundEffect, AudioStreamPlayer>
|
||||
{
|
||||
{SoundEffect.HealHP, HealHPSound },
|
||||
{SoundEffect.TakeDamage, TakeDamageSound },
|
||||
{SoundEffect.HealVT, HealVTSound },
|
||||
{SoundEffect.IncreaseStat, IncreaseStatSound },
|
||||
{SoundEffect.WeaponSwing, WeaponSwingSound },
|
||||
{SoundEffect.Crit, CritSound },
|
||||
{SoundEffect.PickupItem, PickupItemSound },
|
||||
{SoundEffect.OpenInventory, OpenInventorySound },
|
||||
{SoundEffect.MoveUI, MoveSound },
|
||||
{SoundEffect.Equip, EquipSound },
|
||||
{SoundEffect.Unequip, UnequipSound },
|
||||
{SoundEffect.SortInventory, SortSound },
|
||||
{SoundEffect.SelectUI, SelectSound },
|
||||
{SoundEffect.CancelUI, CancelSound },
|
||||
{SoundEffect.LevelUp, LevelUpSound },
|
||||
{SoundEffect.Transfer, TransferItemSound },
|
||||
{SoundEffect.RecallEnemies, RecallEnemiesSound},
|
||||
{SoundEffect.KillHalfEnemies, KillHalfEnemiesSound},
|
||||
{SoundEffect.TeleportToRandomRoom, TeleportToRandomRoomSound},
|
||||
{SoundEffect.TeleportToExit, TeleportToExitSound},
|
||||
{SoundEffect.AbsorbHPFromAllEnemies, AbsorbHPFromAllEnemiesSound},
|
||||
{SoundEffect.TurnAllEnemiesIntoHealingItems, TurnAllEnemiesIntoHealingItemsSound},
|
||||
};
|
||||
}
|
||||
|
||||
[Node] private AudioStreamPlayer HealHPSound { get; set; } = default!;
|
||||
[Node] private AudioStreamPlayer TakeDamageSound { get; set; } = default!;
|
||||
[Node] private AudioStreamPlayer HealVTSound { get; set; } = default!;
|
||||
[Node] private AudioStreamPlayer IncreaseStatSound { get; set; } = default!;
|
||||
[Node] private AudioStreamPlayer WeaponSwingSound { get; set; } = default!;
|
||||
[Node] private AudioStreamPlayer CritSound { get; set; } = default!;
|
||||
[Node] private AudioStreamPlayer PickupItemSound { get; set; } = default!;
|
||||
[Node] private AudioStreamPlayer OpenInventorySound { get; set; }
|
||||
[Node] private AudioStreamPlayer MoveSound { get; set; }
|
||||
[Node] private AudioStreamPlayer EquipSound { get; set; }
|
||||
[Node] private AudioStreamPlayer UnequipSound { get; set; }
|
||||
[Node] private AudioStreamPlayer SortSound { get; set; }
|
||||
[Node] private AudioStreamPlayer SelectSound { get; set; }
|
||||
[Node] private AudioStreamPlayer CancelSound { get; set; }
|
||||
[Node] private AudioStreamPlayer LevelUpSound { get; set; }
|
||||
[Node] private AudioStreamPlayer TransferItemSound { get; set; }
|
||||
[Node] private AudioStreamPlayer RecallEnemiesSound { get; set; }
|
||||
[Node] private AudioStreamPlayer KillHalfEnemiesSound { get; set; }
|
||||
[Node] private AudioStreamPlayer TeleportToRandomRoomSound { get; set; }
|
||||
[Node] private AudioStreamPlayer TeleportToExitSound { get; set; }
|
||||
[Node] private AudioStreamPlayer AbsorbHPFromAllEnemiesSound { get; set; }
|
||||
[Node] private AudioStreamPlayer SwapHPAndVTSound { get; set; }
|
||||
[Node] private AudioStreamPlayer TurnAllEnemiesIntoHealingItemsSound { get; set; }
|
||||
|
||||
private Dictionary<SoundEffect, AudioStreamPlayer> _sfxMap;
|
||||
|
||||
public void Play(SoundEffect soundEffect)
|
||||
{
|
||||
_sfxMap.TryGetValue(soundEffect, out var audio);
|
||||
if (audio != null)
|
||||
audio.Play();
|
||||
}
|
||||
}
|
||||
|
||||
public enum SoundEffect
|
||||
{
|
||||
HealHP,
|
||||
TakeDamage,
|
||||
HealVT,
|
||||
IncreaseStat,
|
||||
WeaponSwing,
|
||||
Crit,
|
||||
PickupItem,
|
||||
OpenInventory,
|
||||
MoveUI,
|
||||
Equip,
|
||||
Unequip,
|
||||
SortInventory,
|
||||
SelectUI,
|
||||
CancelUI,
|
||||
LevelUp,
|
||||
Transfer,
|
||||
RecallEnemies,
|
||||
KillHalfEnemies,
|
||||
TeleportToRandomRoom,
|
||||
TeleportToExit,
|
||||
AbsorbHPFromAllEnemies,
|
||||
SwapHPAndVT,
|
||||
TurnAllEnemiesIntoHealingItems,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user