mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
41 lines
No EOL
988 B
C#
41 lines
No EOL
988 B
C#
using System.Linq;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Resources;
|
|
|
|
[GlobalClass]
|
|
public partial class BulletScript : Resource
|
|
{
|
|
[Export]
|
|
public Array<AttackPattern> Patterns { get; private set; }
|
|
|
|
private Node2D _parent;
|
|
|
|
private int _currentPatternIndex = 0;
|
|
private double _patternTimer;
|
|
|
|
private AttackPattern CurrentPattern => Patterns[_currentPatternIndex];
|
|
|
|
public void Start(Node2D parent)
|
|
{
|
|
_parent = parent;
|
|
if (Patterns.Count == 0) return;
|
|
_currentPatternIndex = 0;
|
|
|
|
CurrentPattern.Start(parent);
|
|
}
|
|
|
|
public void UpdatePhase(double delta)
|
|
{
|
|
_patternTimer += delta;
|
|
|
|
CurrentPattern.UpdatePattern(delta);
|
|
|
|
if (!CurrentPattern.WaitForCompletion || CurrentPattern.IsComplete())
|
|
{
|
|
_currentPatternIndex = (_currentPatternIndex + 1) % Patterns.Count;
|
|
CurrentPattern.Start(_parent);
|
|
}
|
|
}
|
|
} |