|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
@ -8,6 +8,7 @@ public partial class Player2D : CharacterBody2D
|
|
|
|
|
{
|
|
|
|
|
[Export] private float _speed = 100f;
|
|
|
|
|
[Export] private AnimatedSprite2D _sprite;
|
|
|
|
|
[Export] private SceneTree.GroupCallFlags _fieldFlags;
|
|
|
|
|
|
|
|
|
|
// -1 means no tool.
|
|
|
|
|
private int _toolID = -1;
|
|
|
|
|
@ -15,13 +16,14 @@ public partial class Player2D : CharacterBody2D
|
|
|
|
|
private bool anyActionPressed;
|
|
|
|
|
private bool _wateringInProgress;
|
|
|
|
|
private bool _pickupAnimationInProgress;
|
|
|
|
|
private bool _farmingAnimationInProgress;
|
|
|
|
|
private Vector2 _lastDirection = Vector2.Zero;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void _Process(double delta)
|
|
|
|
|
{
|
|
|
|
|
anyActionPressed = false;
|
|
|
|
|
|
|
|
|
|
if (_pickupAnimationInProgress || _wateringInProgress)
|
|
|
|
|
if (_pickupAnimationInProgress || _wateringInProgress || _farmingAnimationInProgress)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionPressed("move_right"))
|
|
|
|
|
@ -115,6 +117,9 @@ public partial class Player2D : CharacterBody2D
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called by FarmingControls Signal.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void PlayWateringAnimation()
|
|
|
|
|
{
|
|
|
|
|
if (_toolID == 1 && !_wateringInProgress)
|
|
|
|
|
@ -146,4 +151,18 @@ public partial class Player2D : CharacterBody2D
|
|
|
|
|
_pickupAnimationInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PlayFarmingAnimation()
|
|
|
|
|
{
|
|
|
|
|
_sprite.Animation = "diagonal farming";
|
|
|
|
|
_sprite.Play();
|
|
|
|
|
_farmingAnimationInProgress = true;
|
|
|
|
|
Task.Run(DelayedFarmingReset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task DelayedFarmingReset()
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay(1000);
|
|
|
|
|
_farmingAnimationInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|