mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
3D Boss scripts implementation
This commit is contained in:
parent
b0d0161ab0
commit
dbf7f1a963
29 changed files with 1805 additions and 1188 deletions
61
Scripts/Resources/BulletScripts/SimpleMovementPattern3D.cs
Normal file
61
Scripts/Resources/BulletScripts/SimpleMovementPattern3D.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using Cirno.Scripts.AttackPatterns;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources.BulletScripts;
|
||||
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class SimpleMovementPattern3D : 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;
|
||||
|
||||
public override IPatternMachine MakeMachine(Node parent)
|
||||
{
|
||||
return new SimpleMovementPatternMachine(this, parent);
|
||||
}
|
||||
|
||||
public class SimpleMovementPatternMachine(SimpleMovementPattern3D pattern, Node parent) : IPatternMachine
|
||||
{
|
||||
public Node Parent => parent;
|
||||
|
||||
private Tween tween;
|
||||
private bool isComplete = false;
|
||||
|
||||
protected IScriptHost3D Boss;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (parent is not IScriptHost3D boss)
|
||||
return;
|
||||
|
||||
Boss = boss;
|
||||
tween = Parent.CreateTween();
|
||||
isComplete = false;
|
||||
|
||||
Vector2 targetPosition = (Boss?.HomePosition.ToVector2() ?? boss.ParentObject.GlobalPosition.ToVector2()) + pattern.relativeTargetPosition;
|
||||
|
||||
var targetPosition3D = targetPosition.ToVector3(boss.ParentObject.GlobalPosition.Y);
|
||||
|
||||
boss.ChangeSpriteDirection(-(boss.ParentObject.GlobalPosition.ToVector2() - targetPosition));
|
||||
tween.TweenProperty(boss.ParentObject, "global_position", targetPosition3D, pattern.moveDuration)
|
||||
.SetTrans(pattern.transitionType)
|
||||
.SetEase(pattern.easeType)
|
||||
.Finished += () =>
|
||||
{
|
||||
isComplete = true;
|
||||
boss.ChangeSpriteDirection(Vector2.Zero);
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta) { }
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return isComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue