mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
|
|
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;
|
|||
|
|
}
|
|||
|
|
}
|