mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
52 lines
No EOL
1.4 KiB
C#
52 lines
No EOL
1.4 KiB
C#
using Cirno.Scripts.Actors;
|
|
using Cirno.Scripts.Components;
|
|
using Cirno.Scripts.Resources;
|
|
|
|
namespace Cirno.Scripts.AttackPatterns;
|
|
|
|
using Godot;
|
|
|
|
[GlobalClass]
|
|
public partial class TargetedPattern : AttackPattern
|
|
{
|
|
[Export] public PackedScene BulletScene;
|
|
|
|
[Export] private float bulletSpeed = 5f;
|
|
[Export] private float duration = 3f;
|
|
[Export] private float burstInterval = 0.5f;
|
|
[Export] private int bulletsPerShot = 1;
|
|
[Export] private float spread = 0f;
|
|
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
|
[Export] private BulletCreationModifier modifier;
|
|
|
|
private double timer;
|
|
private double burstTimer;
|
|
private BulletSpawner spawner;
|
|
//private Node2D player;
|
|
|
|
public override void Start(Node2D parent)
|
|
{
|
|
|
|
Parent = parent;
|
|
timer = 0;
|
|
burstTimer = 0;
|
|
spawner = Parent.GetNode<BulletSpawner>("BulletSpawner");
|
|
|
|
}
|
|
|
|
public override void UpdatePattern(double delta)
|
|
{
|
|
timer += delta;
|
|
burstTimer += delta;
|
|
if (timer < duration && burstTimer >= burstInterval && GameManager.Instance.PlayerPosition.HasValue)
|
|
{
|
|
spawner.SpawnTargetedBullet(Parent.GlobalPosition, GameManager.Instance.PlayerPosition.Value, bulletSpeed, owner, BulletScene, bulletsPerShot, spread, modifier);
|
|
burstTimer = 0;
|
|
}
|
|
}
|
|
|
|
public override bool IsComplete()
|
|
{
|
|
return timer >= duration;
|
|
}
|
|
} |