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

42 lines
1.1 KiB
C#

using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class SwingShortsword : PegAction
{
public override void _Ready()
{
base._Ready();
_category = "attack";
_priority = 1;
_cost = 2;
_range = 1;
_usesMax = 1;
_usesRemaining = _usesMax;
}
public override Tween CreateAnimation(Peg PEG)
{
MapCell target = Target(PEG);
// GD.Print(target);
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)._pegController._playerController.ChangeHealth(-2, this);
_image.Position = Vector2.Zero;
_image.Visible = false;
}));
return subtween;
}
public override MapCell Target(Peg PEG)
{
return PEG.Goal();
}
}