WIP trying to fix the last plant stage bug on repeated farming rounds
This commit is contained in:
@@ -43,6 +43,9 @@ text = "[E] Grow
|
|||||||
[node name="CollisionShape3D" parent="FieldBehaviour/BasePlant2/ReadyPlantInventoryItem/PickupInteractionArea/Area2D" index="0"]
|
[node name="CollisionShape3D" parent="FieldBehaviour/BasePlant2/ReadyPlantInventoryItem/PickupInteractionArea/Area2D" index="0"]
|
||||||
shape = SubResource("CircleShape2D_l0vvv")
|
shape = SubResource("CircleShape2D_l0vvv")
|
||||||
|
|
||||||
|
[node name="Label" parent="FieldBehaviour/BasePlant2/ReadyPlantInventoryItem/PickupInteractionArea" index="1"]
|
||||||
|
text = "[E] Harvest"
|
||||||
|
|
||||||
[node name="MaskedField" type="Sprite2D" parent="FieldBehaviour"]
|
[node name="MaskedField" type="Sprite2D" parent="FieldBehaviour"]
|
||||||
clip_children = 1
|
clip_children = 1
|
||||||
scale = Vector2(1.5, 1.5)
|
scale = Vector2(1.5, 1.5)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ region_enabled = true
|
|||||||
region_rect = Rect2(228, 600, 85, 92)
|
region_rect = Rect2(228, 600, 85, 92)
|
||||||
|
|
||||||
[node name="BigPlant" type="Node2D" parent="."]
|
[node name="BigPlant" type="Node2D" parent="."]
|
||||||
position = Vector2(0, -400)
|
position = Vector2(0, -300)
|
||||||
|
|
||||||
[node name="01" type="Sprite2D" parent="BigPlant"]
|
[node name="01" type="Sprite2D" parent="BigPlant"]
|
||||||
visible = false
|
visible = false
|
||||||
@@ -156,6 +156,8 @@ _blueprint = ExtResource("7_di4m0")
|
|||||||
|
|
||||||
[node name="ItemLabel" parent="ReadyPlantInventoryItem" index="1"]
|
[node name="ItemLabel" parent="ReadyPlantInventoryItem" index="1"]
|
||||||
visible = false
|
visible = false
|
||||||
|
z_index = 100
|
||||||
|
text = "[E] harvest"
|
||||||
|
|
||||||
[node name="PickupErrorLabel" parent="ReadyPlantInventoryItem" index="2"]
|
[node name="PickupErrorLabel" parent="ReadyPlantInventoryItem" index="2"]
|
||||||
visible = false
|
visible = false
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
if (_field.FieldState != FieldState.Watered || _magicWordSaid != _magicWordNeeded)
|
if (_field.FieldState != FieldState.Watered || _magicWordSaid != _magicWordNeeded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GD.Print("Trying to grow something here.");
|
|
||||||
GetTree().CallGroup("PlantGrowing", Player2D.MethodName.PlayFarmingAnimation);
|
GetTree().CallGroup("PlantGrowing", Player2D.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:
|
||||||
@@ -68,13 +68,14 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
_state = PlantState.Ready;
|
_state = PlantState.Ready;
|
||||||
_currentPlantSprite.Visible = false;
|
_currentPlantSprite.Visible = false;
|
||||||
_currentPlantSprite = GetRandomSprite(_readyPlants);
|
_currentPlantSprite = GetRandomSprite(_readyPlants);
|
||||||
_harvestablePlant.IsActive = true;
|
|
||||||
_currentPlantSprite.Visible = true;
|
_currentPlantSprite.Visible = true;
|
||||||
|
ActivatePickupAfterDelay(true);
|
||||||
break;
|
break;
|
||||||
case PlantState.Ready:
|
case PlantState.Ready:
|
||||||
_state = PlantState.None;
|
_state = PlantState.None;
|
||||||
_currentPlantSprite.Visible = false;
|
_currentPlantSprite.Visible = false;
|
||||||
_currentPlantSprite = null;
|
_currentPlantSprite = null;
|
||||||
|
ActivatePickupAfterDelay(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -89,7 +90,19 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
return sprites[rand.Next(sprites.Length)];
|
return sprites[rand.Next(sprites.Length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void ActivatePickupAfterDelay(bool activate)
|
||||||
|
{
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
|
||||||
|
SetActiveHarvestablePlant(activate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetActiveHarvestablePlant(bool active)
|
||||||
|
{
|
||||||
|
_harvestablePlant.IsActive = active;
|
||||||
|
_harvestablePlant.UpdateVisuals();
|
||||||
|
}
|
||||||
|
|
||||||
public void SayMagicWord(string wordEvent)
|
public void SayMagicWord(string wordEvent)
|
||||||
{
|
{
|
||||||
if (_magicWordDialogicEventName != wordEvent)
|
if (_magicWordDialogicEventName != wordEvent)
|
||||||
|
|||||||
Reference in New Issue
Block a user