36 lines
761 B
C#
36 lines
761 B
C#
using Godot;
|
|
|
|
namespace Newlon.Components.Plants;
|
|
|
|
public partial class SnipachBehaviour : BaseBehaviour
|
|
{
|
|
[Export] public AreaAttack attackBox;
|
|
[Export] public Timer timer;
|
|
[Export] public Timer guardTimer;
|
|
private bool dragging = false;
|
|
|
|
public void OnDragBegin()
|
|
{
|
|
if (timer.TimeLeft > 0 || guardTimer.TimeLeft > 0) return;
|
|
dragging = true;
|
|
attackBox.Visible = dragging;
|
|
}
|
|
|
|
public void OnDragEnd()
|
|
{
|
|
if (dragging == false) return;
|
|
attackBox.Attack();
|
|
dragging = false;
|
|
attackBox.Visible = dragging;
|
|
timer.Start();
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
if (dragging)
|
|
{
|
|
attackBox.GlobalPosition = (Cursor.GetCursorPosition() / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14);
|
|
}
|
|
}
|
|
|
|
}
|