Finalized new watering can mechanic with vfx and ui
This commit is contained in:
@@ -9,6 +9,8 @@ public partial class FarmingControls2D : Node2D
|
||||
[Export] private PackedScene _fieldPrefab;
|
||||
[Export] private Node2D _movingPlayer;
|
||||
[Export] private Camera2D _camera;
|
||||
[Export] private CpuParticles2D _wateringParticles;
|
||||
[Export] private float _wateringCanParticlesVerticalOffset = 50f;
|
||||
|
||||
public FieldService2D FieldService;
|
||||
|
||||
@@ -40,6 +42,9 @@ public partial class FarmingControls2D : Node2D
|
||||
}
|
||||
|
||||
_toolId = activate ? toolId : -1;
|
||||
|
||||
WateringCanState.SetActive(_toolId == WateringCanState.WATERING_CAN_ID);
|
||||
|
||||
return activate;
|
||||
}
|
||||
|
||||
@@ -56,15 +61,18 @@ public partial class FarmingControls2D : Node2D
|
||||
MakeField(adjustedPosition);
|
||||
}
|
||||
|
||||
if (@event.IsActionPressed("click") && _toolId == 1 && _wateringCanFilled)
|
||||
if (@event.IsActionPressed("click")
|
||||
&& _toolId == WateringCanState.WATERING_CAN_ID
|
||||
&& WateringCanState.GetFillState() > 0)
|
||||
{
|
||||
WaterTheField(adjustedPosition);
|
||||
}
|
||||
}
|
||||
|
||||
#region WATERING
|
||||
public void FillWateringCan()
|
||||
{
|
||||
if (_toolId == 1 )
|
||||
if (_toolId == WateringCanState.WATERING_CAN_ID)
|
||||
{
|
||||
WateringCanState.Fill();
|
||||
}
|
||||
@@ -77,10 +85,14 @@ public partial class FarmingControls2D : Node2D
|
||||
return;
|
||||
|
||||
field.Water();
|
||||
_wateringParticles.GlobalPosition = new Vector2(field.GlobalPosition.X, field.GlobalPosition.Y + _wateringCanParticlesVerticalOffset);
|
||||
WateringCanState.Water();
|
||||
EmitSignal(SignalName.WateringField);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FIELD CREATION
|
||||
private void MakeField(Vector2I fieldPosition)
|
||||
{
|
||||
if(FieldService == null || _fieldPrefab == null)
|
||||
@@ -120,4 +132,6 @@ public partial class FarmingControls2D : Node2D
|
||||
{
|
||||
return input.Snapped(step);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user