Scriptable bullet emitter

This commit is contained in:
MaddoScientisto 2025-03-15 11:44:30 +01:00
commit 4261009c33
17 changed files with 251 additions and 74 deletions

View file

@ -23,16 +23,14 @@ public partial class TargetedPattern : AttackPattern
private double burstTimer;
private BulletSpawner spawner;
//private Node2D player;
private GameManager _gameManager;
public override void Start(Boss boss)
public override void Start(Node2D parent)
{
_gameManager = boss.GetNode<GameManager>("/root/GameScene");
Boss = boss;
Parent = parent;
timer = 0;
burstTimer = 0;
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
spawner = Parent.GetNode<BulletSpawner>("BulletSpawner");
}
@ -40,9 +38,9 @@ public partial class TargetedPattern : AttackPattern
{
timer += delta;
burstTimer += delta;
if (timer < duration && burstTimer >= burstInterval && _gameManager.PlayerPosition.HasValue)
if (timer < duration && burstTimer >= burstInterval && GameManager.Instance.PlayerPosition.HasValue)
{
spawner.SpawnTargetedBullet(Boss.GlobalPosition, _gameManager.PlayerPosition.Value, bulletSpeed, owner, BulletScene, bulletsPerShot, spread, modifier);
spawner.SpawnTargetedBullet(Parent.GlobalPosition, GameManager.Instance.PlayerPosition.Value, bulletSpeed, owner, BulletScene, bulletsPerShot, spread, modifier);
burstTimer = 0;
}
}