You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/Common/Fight/FlyingIndicator.cs

28 lines
909 B

using System;
using Godot;
namespace Babushka.scripts.CSharp.Common.Fight;
public partial class FlyingIndicator : Node2D
{
[Export] private Label _label = null!;
[Export] private TextureRect _sprite = null!;
public void Initialize(string? text = null, Texture2D? icon = null)
{
_label.Visible = text != null;
_sprite.Visible = icon != null;
if (text != null) _label.Text = text;
if (icon != null) _sprite.Texture = icon;
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));
}
}