2025-07-09 22:40:03 +02:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace Babushka.scripts.CSharp.Common.Temp;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Temporary Duck behaviour to make sure we can use them in the first showcase
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class MVPDuck : Node2D
|
|
|
|
|
{
|
|
|
|
|
[Export] private Node2D _penTarget;
|
|
|
|
|
[Export] private int _transferDelayMs;
|
|
|
|
|
[Export] private AnimationPlayer _animationPlayer;
|
|
|
|
|
[Export] private string _flapAnimationName = "flapFlap";
|
2025-09-27 17:38:23 +02:00
|
|
|
|
|
|
|
|
private bool _collected;
|
2025-07-09 22:40:03 +02:00
|
|
|
|
2025-07-10 23:58:33 +02:00
|
|
|
[Signal] public delegate void DuckCollectedEventHandler();
|
2025-07-09 22:40:03 +02:00
|
|
|
|
|
|
|
|
public void TransferToTargetAfterDelay()
|
|
|
|
|
{
|
2025-09-27 17:38:23 +02:00
|
|
|
if (!_collected)
|
|
|
|
|
{
|
|
|
|
|
MoveAfterDelay();
|
|
|
|
|
PlayAnimation();
|
|
|
|
|
_collected = true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-09 22:40:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlayAnimation()
|
|
|
|
|
{
|
|
|
|
|
_animationPlayer.CurrentAnimation = _flapAnimationName;
|
|
|
|
|
_animationPlayer.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async void MoveAfterDelay()
|
|
|
|
|
{
|
2025-07-11 00:17:31 +02:00
|
|
|
await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
|
|
|
|
|
if(!_penTarget.Equals(null))
|
|
|
|
|
Position = _penTarget.GlobalPosition;
|
2025-07-10 23:58:33 +02:00
|
|
|
EmitSignal(SignalName.DuckCollected);
|
2025-07-09 22:40:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|