33 lines
941 B
C#
33 lines
941 B
C#
using Godot;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
public partial class Shortbow : PegAction
|
|
{
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
_healthChange = -1;
|
|
_cost = 2;
|
|
_range = 1;
|
|
_usesMax = 1;
|
|
_usesRemaining = _usesMax;
|
|
}
|
|
|
|
public override Tween CreateAnimation(Peg PEG)
|
|
{
|
|
Vector2 target = PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
|
|
Tween subtween = CreateTween();
|
|
subtween.TweenProperty(_image, "visible", true, 0.0f);
|
|
subtween.TweenProperty(_image, "global_position", target, 0.5f);
|
|
subtween.TweenCallback(Callable.From(() =>
|
|
{
|
|
PEG._pegController._playerController.ChangeHealth(_healthChange, this);
|
|
Position = Vector2.Zero;
|
|
Visible = false;
|
|
}));
|
|
return subtween;
|
|
}
|
|
|
|
}
|