mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 08:55:55 +00:00
Grazing sounds
This commit is contained in:
parent
8b28805cbd
commit
6f92162d5a
5 changed files with 48 additions and 2 deletions
|
|
@ -32,6 +32,15 @@ public partial class Bullet : Area2D
|
|||
|
||||
[Signal] public delegate void OnDestroyEventHandler();
|
||||
|
||||
private AudioStreamPlayer2D _grazeSound;
|
||||
private GpuParticles2D _grazeParticles;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_grazeSound = GetNodeOrNull<AudioStreamPlayer2D>("AudioStreamPlayer2D");
|
||||
_grazeParticles = GetNodeOrNull<GpuParticles2D>("GrazeParticles");
|
||||
}
|
||||
|
||||
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
||||
{
|
||||
_bulletInfo = bulletInfo;
|
||||
|
|
@ -51,6 +60,16 @@ public partial class Bullet : Area2D
|
|||
_modifiers = _bulletInfo.TimeModifiers.Select(x => x.Wrap()).ToList();
|
||||
}
|
||||
|
||||
public void Graze()
|
||||
{
|
||||
_grazeSound?.Play();
|
||||
if (_grazeParticles is not null)
|
||||
{
|
||||
_grazeParticles.Emitting = true;
|
||||
}
|
||||
IsGrazed = true;
|
||||
}
|
||||
|
||||
private void ApplyTimeModifiers(double delta)
|
||||
{
|
||||
foreach (var modifier in _modifiers)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ public partial class PlayerGrazingModule : PlayerArea2DModule
|
|||
|
||||
GD.Print("Grazed");
|
||||
|
||||
bullet.IsGrazed = true;
|
||||
bullet.Graze();
|
||||
//bullet.IsGrazed = true;
|
||||
Shield.CurrentResource += bullet.BulletInfo.GrazeValue;
|
||||
// check if it's grazed
|
||||
// check if it's grazeable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue