mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
55 lines
No EOL
1.6 KiB
C#
55 lines
No EOL
1.6 KiB
C#
using Cirno.Scripts.Actors;
|
|
using Cirno.Scripts.Components;
|
|
using Cirno.Scripts.Resources;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.AttackPatterns;
|
|
|
|
[GlobalClass]
|
|
public partial class PatternTest : AttackPattern
|
|
{
|
|
[Export] public PackedScene BulletScene;
|
|
[Export] public float bulletSpeed = 5f;
|
|
[Export] public int bulletCount = 12;
|
|
[Export] public float duration = 3f;
|
|
[Export] public float burstInterval = 0.5f;
|
|
[Export] public BulletOwner owner = BulletOwner.Enemy;
|
|
|
|
public override IPatternMachine MakeMachine(Node2D parent)
|
|
{
|
|
return new PatternTestMachine(this, parent);
|
|
}
|
|
|
|
public class PatternTestMachine(PatternTest pattern, Node2D parent) : IPatternMachine
|
|
{
|
|
public Node2D Parent => parent;
|
|
private double timer;
|
|
private double burstTimer;
|
|
private BulletSpawner spawner;
|
|
|
|
public void Start()
|
|
{
|
|
timer = 0;
|
|
burstTimer = 0;
|
|
spawner = Parent.GetNode<BulletSpawner>("BulletSpawner");
|
|
}
|
|
|
|
public void UpdatePattern(double delta)
|
|
{
|
|
timer += delta;
|
|
burstTimer += delta;
|
|
if (timer < pattern.duration && burstTimer >= pattern.burstInterval)
|
|
{
|
|
spawner.SpawnBullet(Parent.GlobalPosition, Vector2.Right, pattern.bulletSpeed, pattern.owner, pattern.bulletCount, bulletScene: pattern.BulletScene);
|
|
burstTimer = 0;
|
|
}
|
|
}
|
|
|
|
public bool IsComplete()
|
|
{
|
|
return timer >= pattern.duration;
|
|
}
|
|
}
|
|
|
|
|
|
} |