Files
peggle-roguelike/Pegs/Actions/ThrustSpear.cs
T

44 lines
1.1 KiB
C#

using Godot;
using System;
public partial class ThrustSpear : PegAction
{
public override void _Ready()
{
base._Ready();
_category = "attack";
_priority = 1;
_cost = 1;
_range = 1;
_usesMax = 1;
_usesRemaining = _usesMax;
}
public override Tween CreateAnimation(Peg PEG)
{
MapCell target = Target(PEG);
if (target == PEG._cell)
{
return null;
}
Tween subtween = CreateTween();
subtween.TweenProperty(_image, "visible", true, 0.0f);
subtween.TweenProperty(_image, "rotation", PEG.GetAngleTo(target.GlobalPosition), 0.0f);
subtween.TweenProperty(_image, "global_position", target.GlobalPosition, 0.5f);
subtween.TweenCallback(Callable.From(() =>
{
((Peg)target?._occupant)?.ChangeHealth(-1);
_image.Position = Vector2.Zero;
_image.Visible = false;
}));
return subtween;
}
public override MapCell Target(Peg PEG)
{
return PEG.Goal();
}
}