mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Scriptable bullet emitter
This commit is contained in:
parent
d62538a382
commit
4261009c33
17 changed files with 251 additions and 74 deletions
41
Scripts/Resources/BulletScript.cs
Normal file
41
Scripts/Resources/BulletScript.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue