Files
Babushka/scripts/CSharp/Common/Fight/FlyingIndicator.cs
T

28 lines
909 B
C#
Raw Normal View History

2025-11-11 15:55:15 +01:00
using System;
using Godot;
namespace Babushka.scripts.CSharp.Common.Fight;
2025-12-16 18:56:18 +01:00
public partial class FlyingIndicator : Node2D
2025-11-11 15:55:15 +01:00
{
2025-12-16 18:56:18 +01:00
[Export] private Label _label = null!;
[Export] private TextureRect _sprite = null!;
public void Initialize(string? text = null, Texture2D? icon = null)
2025-11-11 15:55:15 +01:00
{
2025-12-16 18:56:18 +01:00
_label.Visible = text != null;
_sprite.Visible = icon != null;
if (text != null) _label.Text = text;
if (icon != null) _sprite.Texture = icon;
2025-11-11 15:55:15 +01:00
var tween = CreateTween();
var xMovement = GD.RandRange(-150, 150);
var yMovement = GD.RandRange(-400, -250);
tween.Parallel().TweenProperty(this, "position:x", xMovement, .6);
tween.Parallel().TweenProperty(this, "position:y", yMovement, .6)
.SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Quad);
tween.Chain().TweenCallback(Callable.From(QueueFree));
}
}