mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:25:35 +00:00
60 lines
No EOL
1.8 KiB
C#
60 lines
No EOL
1.8 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;
|
|
|
|
public override IPatternMachine MakeMachine(Node2D parent)
|
|
{
|
|
return new TargetedPatternMachine(this, parent);
|
|
}
|
|
|
|
public class TargetedPatternMachine(TargetedPattern pattern, Node2D parent) : IPatternMachine
|
|
{
|
|
public Node2D Parent => parent;
|
|
|
|
private double timer;
|
|
private double burstTimer;
|
|
private BulletSpawner spawner;
|
|
//private Node2D player;
|
|
|
|
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 && GameManager.Instance.PlayerPosition.HasValue)
|
|
{
|
|
spawner.SpawnTargetedBullet(Parent.GlobalPosition, GameManager.Instance.PlayerPosition.Value, pattern.bulletSpeed, pattern.owner, pattern.BulletScene, pattern.bulletsPerShot, pattern.spread, pattern.modifier);
|
|
burstTimer = 0;
|
|
}
|
|
}
|
|
|
|
public bool IsComplete()
|
|
{
|
|
return timer >= pattern.duration;
|
|
}
|
|
}
|
|
} |