Spinach
This commit is contained in:
parent
805226d9eb
commit
87f841e8e1
24 changed files with 203 additions and 57 deletions
36
scripts/entities/plants/behaviours/SnipachBehaviour.cs
Normal file
36
scripts/entities/plants/behaviours/SnipachBehaviour.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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 = (attackBox.GetGlobalMousePosition() / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://csgksiyma0h4t
|
||||
Loading…
Add table
Add a link
Reference in a new issue