planting, growing and watering a little less dependent than before
This commit is contained in:
@@ -39,7 +39,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
|||||||
case FieldState.Tilled:
|
case FieldState.Tilled:
|
||||||
FieldState = FieldState.Tilled;
|
FieldState = FieldState.Tilled;
|
||||||
_fieldSprite.Texture = Tilled;
|
_fieldSprite.Texture = Tilled;
|
||||||
PlantingInteraction.IsActive = false;
|
PlantingInteraction.IsActive = true;
|
||||||
break;
|
break;
|
||||||
case FieldState.Watered:
|
case FieldState.Watered:
|
||||||
FieldState = FieldState.Watered;
|
FieldState = FieldState.Watered;
|
||||||
@@ -68,12 +68,9 @@ public partial class FieldBehaviour2D : Sprite2D
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Farm()
|
public void Farm()
|
||||||
{
|
{
|
||||||
if (FieldState == FieldState.Watered)
|
if (TryPlant())
|
||||||
{
|
{
|
||||||
if (TryPlant())
|
UpdateFieldState(FieldState.Planted);
|
||||||
{
|
|
||||||
UpdateFieldState(FieldState.Planted);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +97,6 @@ public partial class FieldBehaviour2D : Sprite2D
|
|||||||
if (plantBehaviour != null)
|
if (plantBehaviour != null)
|
||||||
{
|
{
|
||||||
plantBehaviour.Field = this;
|
plantBehaviour.Field = this;
|
||||||
plantBehaviour.Grow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
get => _field;
|
get => _field;
|
||||||
set => _field = value;
|
set => _field = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_state = PlantState.Planted;
|
||||||
|
_currentPlantSprite = GetRandomSprite(_seeds);
|
||||||
|
_currentPlantSprite.Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -45,8 +52,6 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
GetTree().CallGroup("PlantGrowing", VesnaAnimations.MethodName.PlayFarmingAnimation);
|
GetTree().CallGroup("PlantGrowing", VesnaAnimations.MethodName.PlayFarmingAnimation);
|
||||||
// todo:
|
|
||||||
// find out why the last plant stage is being skipped the second time around
|
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
case PlantState.None:
|
case PlantState.None:
|
||||||
|
|||||||
Reference in New Issue
Block a user