mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 15:55:54 +00:00
Danmaku system
This commit is contained in:
parent
9c8ec486fc
commit
fdec052c16
38 changed files with 924 additions and 9 deletions
13
Scripts/Resources/AttackPattern.cs
Normal file
13
Scripts/Resources/AttackPattern.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
public abstract partial class AttackPattern : Resource
|
||||
{
|
||||
public Boss Boss;
|
||||
[Export] public bool WaitForCompletion = true;
|
||||
public abstract void Start(Boss boss);
|
||||
public abstract void UpdatePattern(double delta);
|
||||
public abstract bool IsComplete();
|
||||
}
|
||||
35
Scripts/Resources/BossPhase.cs
Normal file
35
Scripts/Resources/BossPhase.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class BossPhase : Resource
|
||||
{
|
||||
[Export] public int Threshold;
|
||||
[Export] public Array<AttackPattern> Patterns;
|
||||
|
||||
private int currentPatternIndex = 0;
|
||||
private double patternTimer;
|
||||
|
||||
public void Start(Boss boss)
|
||||
{
|
||||
currentPatternIndex = 0;
|
||||
Patterns[currentPatternIndex].Start(boss);
|
||||
}
|
||||
|
||||
public void UpdatePhase(double delta)
|
||||
{
|
||||
patternTimer += delta;
|
||||
var currentPattern = Patterns[currentPatternIndex];
|
||||
|
||||
currentPattern.UpdatePattern(delta);
|
||||
|
||||
if (!currentPattern.WaitForCompletion || currentPattern.IsComplete())
|
||||
{
|
||||
currentPatternIndex = (currentPatternIndex + 1) % Patterns.Count;
|
||||
Patterns[currentPatternIndex].Start(currentPattern.Boss);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Scripts/Resources/DecreasingSpeedModifier.cs
Normal file
14
Scripts/Resources/DecreasingSpeedModifier.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DecreasingSpeedModifier : Resource, IBulletModifier
|
||||
{
|
||||
[Export] private float decreaseRate = 0.1f;
|
||||
|
||||
public float ModifySpeed(float baseSpeed, int bulletIndex)
|
||||
{
|
||||
return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex));
|
||||
}
|
||||
}
|
||||
6
Scripts/Resources/IBulletModifier.cs
Normal file
6
Scripts/Resources/IBulletModifier.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
public interface IBulletModifier
|
||||
{
|
||||
float ModifySpeed(float baseSpeed, int bulletIndex);
|
||||
}
|
||||
42
Scripts/Resources/PatternGroup.cs
Normal file
42
Scripts/Resources/PatternGroup.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using Cirno.Scripts.Actors;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PatternGroup : AttackPattern
|
||||
{
|
||||
[Export] private Array<AttackPattern> patterns;
|
||||
private int currentPatternIndex = 0;
|
||||
|
||||
public override void Start(Boss boss)
|
||||
{
|
||||
Boss = boss;
|
||||
currentPatternIndex = 0;
|
||||
patterns[currentPatternIndex].Start(boss);
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta)
|
||||
{
|
||||
if (currentPatternIndex < patterns.Count)
|
||||
{
|
||||
patterns[currentPatternIndex].UpdatePattern(delta);
|
||||
|
||||
if (!patterns[currentPatternIndex].WaitForCompletion || patterns[currentPatternIndex].IsComplete())
|
||||
{
|
||||
currentPatternIndex++;
|
||||
if (currentPatternIndex < patterns.Count)
|
||||
{
|
||||
patterns[currentPatternIndex].Start(Boss);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsComplete()
|
||||
{
|
||||
return currentPatternIndex >= patterns.Count;
|
||||
}
|
||||
}
|
||||
37
Scripts/Resources/SimpleMovementPattern.cs
Normal file
37
Scripts/Resources/SimpleMovementPattern.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SimpleMovementPattern : AttackPattern
|
||||
{
|
||||
[Export] private Vector2 relativeTargetPosition;
|
||||
[Export] private float moveDuration = 2f;
|
||||
[Export] private Tween.TransitionType transitionType = Tween.TransitionType.Linear;
|
||||
[Export] private Tween.EaseType easeType = Tween.EaseType.InOut;
|
||||
|
||||
private Tween tween;
|
||||
private bool isComplete = false;
|
||||
|
||||
public override void Start(Boss boss)
|
||||
{
|
||||
Boss = boss;
|
||||
tween = boss.CreateTween();
|
||||
isComplete = false;
|
||||
|
||||
Vector2 targetPosition = (Boss?.HomePosition ?? boss.GlobalPosition) + relativeTargetPosition;
|
||||
|
||||
tween.TweenProperty(Boss, "position", targetPosition, moveDuration)
|
||||
.SetTrans(transitionType)
|
||||
.SetEase(easeType)
|
||||
.Finished += () => isComplete = true;
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta) { }
|
||||
|
||||
public override bool IsComplete()
|
||||
{
|
||||
return isComplete;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue