mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-06 17:45:55 +00:00
Danmaku system
This commit is contained in:
parent
9c8ec486fc
commit
fdec052c16
38 changed files with 924 additions and 9 deletions
54
Scripts/AttackPatterns/MovementPattern.cs
Normal file
54
Scripts/AttackPatterns/MovementPattern.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.AttackPatterns;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class MovementPattern : 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;
|
||||
[Export] private AttackPattern shootingPattern;
|
||||
|
||||
|
||||
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) + this.relativeTargetPosition;
|
||||
|
||||
|
||||
tween.TweenProperty(Boss, "position", targetPosition, moveDuration)
|
||||
.SetTrans(transitionType)
|
||||
.SetEase(easeType)
|
||||
.Finished += () => isComplete = true;
|
||||
|
||||
if (shootingPattern != null && !WaitForCompletion)
|
||||
{
|
||||
shootingPattern.Start(boss);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta)
|
||||
{
|
||||
if (shootingPattern != null && !WaitForCompletion)
|
||||
{
|
||||
shootingPattern.UpdatePattern(delta);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsComplete()
|
||||
{
|
||||
if (WaitForCompletion && shootingPattern != null)
|
||||
return isComplete && shootingPattern.IsComplete();
|
||||
return isComplete;
|
||||
}
|
||||
}
|
||||
45
Scripts/AttackPatterns/PatternTest.cs
Normal file
45
Scripts/AttackPatterns/PatternTest.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.AttackPatterns;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PatternTest : AttackPattern
|
||||
{
|
||||
[Export] public PackedScene BulletScene;
|
||||
[Export] private float bulletSpeed = 5f;
|
||||
[Export] private int bulletCount = 12;
|
||||
[Export] private float duration = 3f;
|
||||
[Export] private float burstInterval = 0.5f;
|
||||
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
||||
|
||||
private double timer;
|
||||
private double burstTimer;
|
||||
private BulletSpawner spawner;
|
||||
|
||||
public override void Start(Boss boss)
|
||||
{
|
||||
Boss = boss;
|
||||
timer = 0;
|
||||
burstTimer = 0;
|
||||
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta)
|
||||
{
|
||||
timer += delta;
|
||||
burstTimer += delta;
|
||||
if (timer < duration && burstTimer >= burstInterval)
|
||||
{
|
||||
spawner.SpawnBullet(Boss.GlobalPosition, Vector2.Right, bulletSpeed, owner, bulletCount, bulletScene: BulletScene);
|
||||
burstTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsComplete()
|
||||
{
|
||||
return timer >= duration;
|
||||
}
|
||||
}
|
||||
47
Scripts/AttackPatterns/SpiralPattern.cs
Normal file
47
Scripts/AttackPatterns/SpiralPattern.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
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 = 90f;
|
||||
[Export] private float duration = 5f;
|
||||
[Export] private float burstInterval = 0.5f;
|
||||
[Export] private float spread = 360f;
|
||||
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
||||
|
||||
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)
|
||||
{
|
||||
spawner.SpawnSpiralPattern(Boss.GlobalPosition, bulletSpeed, owner, bulletCount, rotationSpeed, timer, spread, BulletScene);
|
||||
burstTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsComplete()
|
||||
{
|
||||
return timer >= duration;
|
||||
}
|
||||
}
|
||||
54
Scripts/AttackPatterns/TargetedPattern.cs
Normal file
54
Scripts/AttackPatterns/TargetedPattern.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
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 Resource modifier;
|
||||
|
||||
private double timer;
|
||||
private double burstTimer;
|
||||
private BulletSpawner spawner;
|
||||
//private Node2D player;
|
||||
private GameManager _gameManager;
|
||||
|
||||
public override void Start(Boss boss)
|
||||
{
|
||||
_gameManager = boss.GetNode<GameManager>("/root/GameScene");
|
||||
|
||||
Boss = boss;
|
||||
timer = 0;
|
||||
burstTimer = 0;
|
||||
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
|
||||
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta)
|
||||
{
|
||||
timer += delta;
|
||||
burstTimer += delta;
|
||||
if (timer < duration && burstTimer >= burstInterval && _gameManager.PlayerPosition.HasValue)
|
||||
{
|
||||
spawner.SpawnTargetedBullet(Boss.GlobalPosition, _gameManager.PlayerPosition.Value, bulletSpeed, owner, BulletScene, bulletsPerShot, spread, modifier as IBulletModifier);
|
||||
burstTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsComplete()
|
||||
{
|
||||
return timer >= duration;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue