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