Now boss FSM Actor movement

This commit is contained in:
Marco 2025-05-16 17:38:02 +02:00
commit c37278075d
19 changed files with 215 additions and 28 deletions

View file

@ -1,5 +1,9 @@
using Cirno.Scripts.Resources;
using Godot;
using GTweens.Builders;
using GTweens.Easings;
using GTweens.Tweens;
using GTweensGodot.Extensions;
namespace Cirno.Scripts.AttackPatterns;
@ -8,8 +12,8 @@ public partial class NodeMovementPattern : 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 Tween.TransitionType transitionType = Tween.TransitionType.Linear;
[Export] public GTweens.Easings.Easing EaseType { get; private set; } = Easing.Linear;
public override IPatternMachine MakeMachine(Node2D parent)
{
@ -20,7 +24,7 @@ public partial class NodeMovementPattern : AttackPattern
{
public Node2D Parent => parent;
private Tween tween;
private GTween _tween;
private bool isComplete = false;
public void Start()
@ -32,18 +36,30 @@ public partial class NodeMovementPattern : AttackPattern
return;
}
tween = Parent.CreateTween();
_tween?.Complete();
isComplete = false;
Vector2 targetPosition = (scriptHost?.HomePosition ?? Parent.GlobalPosition) + pattern.relativeTargetPosition;
_tween = GTweenSequenceBuilder.New()
.Append(scriptHost.ParentObject.TweenGlobalPosition(targetPosition, pattern.moveDuration))
.AppendCallback(() =>
{
isComplete = true;
})
.Build();
_tween.SetEasing(pattern.EaseType);
tween.TweenProperty(Parent, "global_position", targetPosition, pattern.moveDuration)
.SetTrans(pattern.transitionType)
.SetEase(pattern.easeType)
.Finished += () =>
{
isComplete = true;
};
_tween.Play();
// tween.TweenProperty(Parent, "global_position", targetPosition, pattern.moveDuration)
// .SetTrans(pattern.transitionType)
// .SetEase(pattern.easeType)
// .Finished += () =>
// {
// isComplete = true;
// };
}
public void UpdatePattern(double delta) { }