cirnogodot/Scripts/Resources/SimpleMovementPattern.cs

49 lines
1.4 KiB
C#
Raw Normal View History

2025-02-05 19:41:49 +01:00
using Cirno.Scripts.Actors;
2025-03-15 11:44:30 +01:00
using Cirno.Scripts.AttackPatterns;
2025-02-05 19:41:49 +01:00
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;
2025-03-15 11:44:30 +01:00
protected IScriptHost Boss;
public override void Start(Node2D parent)
2025-02-05 19:41:49 +01:00
{
2025-03-15 11:44:30 +01:00
Parent = parent;
if (parent is not IScriptHost boss)
return;
2025-02-05 19:41:49 +01:00
Boss = boss;
2025-03-15 11:44:30 +01:00
tween = Parent.CreateTween();
2025-02-05 19:41:49 +01:00
isComplete = false;
2025-03-15 11:44:30 +01:00
Vector2 targetPosition = (Boss?.HomePosition ?? Parent.GlobalPosition) + relativeTargetPosition;
2025-03-06 22:09:11 +01:00
2025-03-15 11:44:30 +01:00
boss.ChangeSpriteDirection(-(Parent.GlobalPosition - targetPosition));
tween.TweenProperty(Parent, "global_position", targetPosition, moveDuration)
2025-02-05 19:41:49 +01:00
.SetTrans(transitionType)
.SetEase(easeType)
2025-03-06 22:09:11 +01:00
.Finished += () =>
{
isComplete = true;
boss.ChangeSpriteDirection(Vector2.Zero);
};
2025-02-05 19:41:49 +01:00
}
public override void UpdatePattern(double delta) { }
public override bool IsComplete()
{
return isComplete;
}
}