Sound effects

This commit is contained in:
MaddoScientisto 2025-03-01 23:46:25 +01:00
commit 60ab375572
41 changed files with 504 additions and 15 deletions

View file

@ -35,6 +35,9 @@ public partial class Teleporter : Activable
protected GpuParticles2D _particles;
private AudioStreamPlayer2D _teleportStartSound;
private AudioStreamPlayer2D _teleportEndSound;
public override void _Ready()
{
_particles = GetNode<GpuParticles2D>("./Particles");
@ -54,6 +57,9 @@ public partial class Teleporter : Activable
{
_animatedSprite.Play("Default");
}
_teleportStartSound = GetNodeOrNull<AudioStreamPlayer2D>("TeleportStart");
_teleportEndSound = GetNodeOrNull<AudioStreamPlayer2D>("TeleportEnd");
}
public override void _Process(double delta)
@ -133,6 +139,8 @@ public partial class Teleporter : Activable
await TweenPlayer(player);
PlayTeleportStartSound();
//_particles.Emitting = true;
FireParticles();
@ -142,12 +150,22 @@ public partial class Teleporter : Activable
Target.PrepareForReceiving();
player.GlobalPosition = Target.GlobalPosition + TeleportOffset;
Target.PlayTeleportEndSound();
await player.UnTeleport();
player.RequestMovementDisable(false);
}
public void PlayTeleportStartSound()
{
_teleportStartSound?.Play();
}
public void PlayTeleportEndSound()
{
_teleportEndSound?.Play();
}
protected async Task TweenPlayer(PlayerMovement player)
{
await player.TweenGlobalPosition(GlobalPosition + new Vector2(0, -4f), TeleportAnimationLength).PlayAsync(CancellationToken.None);