mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:45:33 +00:00
69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Cirno.Scripts.Actors;
|
|
using Cirno.Scripts.Components;
|
|
using Cirno.Scripts.Resources;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.AttackPatterns;
|
|
|
|
[GlobalClass]
|
|
public partial class SpiralPattern : AttackPattern
|
|
{
|
|
[Export] public PackedScene BulletScene;
|
|
[Export] private float bulletSpeed = 5f;
|
|
[Export] private int bulletCount = 16;
|
|
[Export] private float rotationSpeed = 0f;
|
|
[Export] private float _rotationOffset = 0f;
|
|
[Export] private float duration = 5f;
|
|
[Export] private float burstInterval = 0.5f;
|
|
[Export] private float spread = 360f;
|
|
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
|
[Export] private Resource _modifier;
|
|
[Export] private Array<Resource> _timeModifiers;
|
|
|
|
private double timer;
|
|
private double burstTimer;
|
|
private BulletSpawner spawner;
|
|
|
|
public override void Start(Boss boss)
|
|
{
|
|
Boss = boss;
|
|
timer = 0;
|
|
burstTimer = burstInterval; // start immediately
|
|
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
|
|
}
|
|
|
|
public override void UpdatePattern(double delta)
|
|
{
|
|
timer += delta;
|
|
burstTimer += delta;
|
|
if (timer < duration && burstTimer >= burstInterval)
|
|
{
|
|
float angleOffset = (float)(rotationSpeed * timer);
|
|
|
|
spawner.SpawnBullet(new BulletInfo()
|
|
{
|
|
Position = Boss.GlobalPosition,
|
|
Direction = Vector2.Right,
|
|
Speed = bulletSpeed,
|
|
Owner = owner,
|
|
BulletCount = bulletCount,
|
|
Spread = spread,
|
|
BulletScene = BulletScene,
|
|
RotationOffset = _rotationOffset,
|
|
Modifier = _modifier as IBulletModifier,
|
|
TimeModifiers = _timeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ?? new List<TimeModifier>()
|
|
});
|
|
|
|
// spawner.SpawnSpiralPattern(Boss.GlobalPosition, bulletSpeed, owner, bulletCount, rotationSpeed, timer, spread, BulletScene);
|
|
burstTimer = 0;
|
|
}
|
|
}
|
|
|
|
public override bool IsComplete()
|
|
{
|
|
return timer >= duration;
|
|
}
|
|
}
|