mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-13 00:05:55 +00:00
Sound effects
This commit is contained in:
parent
80a13d047d
commit
60ab375572
41 changed files with 504 additions and 15 deletions
|
|
@ -10,7 +10,7 @@ public partial class ForceField : Door
|
|||
|
||||
[Export]
|
||||
public Material ActiveMaterial { get; private set; }
|
||||
|
||||
|
||||
// Disable
|
||||
public override void Open()
|
||||
{
|
||||
|
|
@ -19,7 +19,6 @@ public partial class ForceField : Door
|
|||
|
||||
_animatedSprite.Material = TurnOffMaterial;
|
||||
//((ShaderMaterial)_animatedSprite.Material).Shader = TurnOffShader;
|
||||
|
||||
_ = AnimateShutdownAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ namespace Cirno.Scripts;
|
|||
|
||||
public partial class AlarmManager : Node2D
|
||||
{
|
||||
[Export]
|
||||
public AudioStream AlarmSound { get; private set; }
|
||||
|
||||
public static AlarmManager Instance { get; private set; }
|
||||
|
||||
public bool IsAlarmOn { get; private set; } = false;
|
||||
|
|
@ -16,9 +19,20 @@ public partial class AlarmManager : Node2D
|
|||
[Signal]
|
||||
public delegate void AlarmDisabledEventHandler();
|
||||
|
||||
private AudioStreamPlayer2D _player;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
if (AlarmSound is not null)
|
||||
{
|
||||
var player = new AudioStreamPlayer2D();
|
||||
player.Stream = AlarmSound;
|
||||
this.CallDeferred("add_child", player);
|
||||
|
||||
_player = player;
|
||||
}
|
||||
}
|
||||
|
||||
public void SoundAlarm(Vector2 location)
|
||||
|
|
@ -29,11 +43,13 @@ public partial class AlarmManager : Node2D
|
|||
EmitSignal(nameof(AlarmEnabled), location);
|
||||
|
||||
GD.Print($"Alarm sounded at {location}");
|
||||
_player?.Play();
|
||||
}
|
||||
|
||||
public void DisableAlarm()
|
||||
{
|
||||
IsAlarmOn = false;
|
||||
EmitSignal(nameof(AlarmDisabled));
|
||||
_player?.Stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,9 @@ public partial class Door : Activable
|
|||
protected AnimatedSprite2D _animatedSprite;
|
||||
protected CollisionShape2D _collisionShape;
|
||||
protected CollisionShape2D _solidShape;
|
||||
|
||||
protected AudioStreamPlayer2D _activationSound;
|
||||
protected AudioStreamPlayer2D _deactivationSound;
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
|
||||
[Export]
|
||||
|
|
@ -25,6 +28,9 @@ public partial class Door : Activable
|
|||
_collisionShape = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
_solidShape = GetNode<CollisionShape2D>("RigidBody2D/CollisionShape2D");
|
||||
|
||||
_activationSound = GetNodeOrNull<AudioStreamPlayer2D>("ActivationSound");
|
||||
_deactivationSound = GetNodeOrNull<AudioStreamPlayer2D>("DeactivationSound");
|
||||
|
||||
SetState(State);
|
||||
}
|
||||
|
||||
|
|
@ -38,6 +44,7 @@ public partial class Door : Activable
|
|||
_animatedSprite.Play("Opening");
|
||||
State = DoorState.Open;
|
||||
CallDeferred(MethodName.DeferredDisableCollision, true);
|
||||
_deactivationSound?.Play();
|
||||
//_collisionShape.Disabled = true;
|
||||
//_solidShape.Disabled = true;
|
||||
}
|
||||
|
|
@ -47,6 +54,7 @@ public partial class Door : Activable
|
|||
_animatedSprite.Play("Closing");
|
||||
State = DoorState.Closed;
|
||||
CallDeferred(MethodName.DeferredDisableCollision, false);
|
||||
_activationSound?.Play();
|
||||
//_collisionShape.Disabled = false;
|
||||
//_solidShape.Disabled = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,19 @@ public partial class Switch : Interactable
|
|||
[Export] public Array<Node2D> Targets { get; private set; } = new Array<Node2D>();
|
||||
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
|
||||
|
||||
private AudioStreamPlayer2D _activationSound;
|
||||
|
||||
private readonly string _activationSoundName = "ActivationSound";
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_activationSound = GetNodeOrNull<AudioStreamPlayer2D>(_activationSoundName);
|
||||
}
|
||||
|
||||
public override bool Activate()
|
||||
{
|
||||
if (!MeetsRequirements()) return false;
|
||||
_activationSound?.Play();
|
||||
// Compatibility for old single system
|
||||
bool success = ActivateTarget(Target);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue