mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 21:25:54 +00:00
Boss Animation
This commit is contained in:
parent
2e01cd19e2
commit
08cc298a81
9 changed files with 139 additions and 13 deletions
|
|
@ -37,6 +37,8 @@ public partial class Boss : Enemy, IActivable
|
|||
|
||||
private BossHud _bossHud;
|
||||
|
||||
[Signal] public delegate void ActorSpriteChangeEventHandler(Vector2 direction);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
|
@ -181,4 +183,9 @@ public partial class Boss : Enemy, IActivable
|
|||
|
||||
_animationTextureRect.Visible = false;
|
||||
}
|
||||
|
||||
public void ChangeSpriteDirection(Vector2 direction)
|
||||
{
|
||||
EmitSignal(SignalName.ActorSpriteChange, direction);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,8 +24,7 @@ public partial class MovementPattern : AttackPattern
|
|||
isComplete = false;
|
||||
|
||||
Vector2 targetPosition = (Boss?.HomePosition ?? boss.GlobalPosition) + this.relativeTargetPosition;
|
||||
|
||||
|
||||
|
||||
tween.TweenProperty(Boss, "position", targetPosition, moveDuration)
|
||||
.SetTrans(transitionType)
|
||||
.SetEase(easeType)
|
||||
|
|
|
|||
42
Scripts/Components/Actors/BossSpriteAnimator.cs
Normal file
42
Scripts/Components/Actors/BossSpriteAnimator.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors;
|
||||
|
||||
public partial class BossSpriteAnimator : Node2D
|
||||
{
|
||||
[Export]
|
||||
public AnimatedSprite2D AnimatedSprite2D { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Boss Enemy { get; private set; }
|
||||
|
||||
[Export] public StringName NeutralAnimationName { get; private set; } = "default";
|
||||
|
||||
[Export]
|
||||
public StringName LeftAnimationName { get; private set; } = "left";
|
||||
|
||||
[Export]
|
||||
public StringName RightAnimationName { get; private set; } = "right";
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Enemy.ActorSpriteChange += EnemyOnActorSpriteChange;
|
||||
}
|
||||
|
||||
private void EnemyOnActorSpriteChange(Vector2 direction)
|
||||
{
|
||||
if (direction == Vector2.Zero)
|
||||
{
|
||||
AnimatedSprite2D.Play(NeutralAnimationName);
|
||||
}
|
||||
else if (direction.X > 0)
|
||||
{
|
||||
AnimatedSprite2D.Play(RightAnimationName);
|
||||
}
|
||||
else if (direction.X < 0)
|
||||
{
|
||||
AnimatedSprite2D.Play(LeftAnimationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/Actors/BossSpriteAnimator.cs.uid
Normal file
1
Scripts/Components/Actors/BossSpriteAnimator.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dtg2vhquyrib3
|
||||
|
|
@ -21,11 +21,16 @@ public partial class SimpleMovementPattern : AttackPattern
|
|||
isComplete = false;
|
||||
|
||||
Vector2 targetPosition = (Boss?.HomePosition ?? boss.GlobalPosition) + relativeTargetPosition;
|
||||
|
||||
|
||||
boss.ChangeSpriteDirection(-(boss.GlobalPosition - targetPosition));
|
||||
tween.TweenProperty(Boss, "global_position", targetPosition, moveDuration)
|
||||
.SetTrans(transitionType)
|
||||
.SetEase(easeType)
|
||||
.Finished += () => isComplete = true;
|
||||
.Finished += () =>
|
||||
{
|
||||
isComplete = true;
|
||||
boss.ChangeSpriteDirection(Vector2.Zero);
|
||||
};
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta) { }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue