starting to build out more actions and pegs, first thing to do tho is rework movement / targeting a little bit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public partial class ShootShortbow : 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)
|
||||
{
|
||||
Vector2 target = Target(PEG);
|
||||
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(-1, this);
|
||||
Position = Vector2.Zero;
|
||||
Visible = false;
|
||||
}));
|
||||
return subtween;
|
||||
}
|
||||
|
||||
public override Vector2 Target(Peg PEG)
|
||||
{
|
||||
return PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user