diff --git a/prefabs/characters/Player2D.tscn b/prefabs/characters/Player2D.tscn index fa34a44..bf5dc12 100644 --- a/prefabs/characters/Player2D.tscn +++ b/prefabs/characters/Player2D.tscn @@ -2071,13 +2071,14 @@ script = ExtResource("1_yd5ep") _farmingControls = NodePath("FarmingControls") _player2d = NodePath("CharacterBody2D") -[node name="CharacterBody2D" type="CharacterBody2D" parent="." node_paths=PackedStringArray("_sprite") groups=["PlantGrowing"]] +[node name="CharacterBody2D" type="CharacterBody2D" parent="." node_paths=PackedStringArray("_sprite", "_wateringParticles") groups=["PlantGrowing"]] position = Vector2(0, 374) collision_layer = 4 collision_mask = 3 script = ExtResource("2_1vqmv") _speed = 1500.0 _sprite = NodePath("visuals/Animated Sprites") +_wateringParticles = NodePath("../pouring water vfx") [node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"] z_index = 1 @@ -2166,16 +2167,37 @@ visible = false position = Vector2(3, 12) texture = ExtResource("473_g32y8") -[node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer", "_camera")] +[node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer", "_camera", "_wateringParticles")] script = ExtResource("817_6nrw3") _fieldPrefab = ExtResource("818_16w6h") _movingPlayer = NodePath("../CharacterBody2D") _camera = NodePath("../CharacterBody2D/Camera2D") +_wateringParticles = NodePath("../pouring water vfx") +_wateringCanParticlesVerticalOffset = -100.0 [node name="dialogic toggle" type="Node2D" parent="."] position = Vector2(0, 374) script = ExtResource("819_4na52") +[node name="pouring water vfx" type="CPUParticles2D" parent="."] +position = Vector2(-652, -599) +rotation = -0.333807 +emitting = false +amount = 20 +texture = ExtResource("473_g32y8") +lifetime = 0.5 +randomness = 1.0 +local_coords = true +draw_order = 1 +emission_shape = 2 +emission_sphere_radius = 128.0 +linear_accel_min = 44.07 +linear_accel_max = 78.81 +scale_amount_min = 0.4 +scale_amount_max = 0.8 +color = Color(0.400601, 0.62444, 0.791217, 1) +hue_variation_max = 0.4 + [connection signal="FilledWateringCan" from="." to="CharacterBody2D/WateringCanUI" method="Refill"] [connection signal="InventorySelectionChanged" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"] [connection signal="PickedUpTool" from="." to="CharacterBody2D" method="ActivateTool"] diff --git a/prefabs/interactions/generic_item_on_ground_2d.tscn b/prefabs/interactions/generic_item_on_ground_2d.tscn index 249441c..2579b11 100644 --- a/prefabs/interactions/generic_item_on_ground_2d.tscn +++ b/prefabs/interactions/generic_item_on_ground_2d.tscn @@ -49,7 +49,6 @@ autowrap_mode = 3 shape = SubResource("CircleShape2D_tlhp6") [node name="Label" parent="InteractionArea2" index="1"] -visible = true z_index = 5 offset_left = -68.0 offset_top = -111.0 diff --git a/scenes/Babushka_scene_farm_outside_2d.tscn b/scenes/Babushka_scene_farm_outside_2d.tscn index 9441655..cd30102 100644 --- a/scenes/Babushka_scene_farm_outside_2d.tscn +++ b/scenes/Babushka_scene_farm_outside_2d.tscn @@ -127,7 +127,7 @@ size = Vector2(1041, 368) [sub_resource type="CircleShape2D" id="CircleShape2D_p6n74"] resource_local_to_scene = true -radius = 600.0 +radius = 371.058 [sub_resource type="CircleShape2D" id="CircleShape2D_2nee2"] resource_local_to_scene = true @@ -352,7 +352,7 @@ texture = ExtResource("11_vbdb2") [node name="background layer 4" type="ParallaxLayer" parent="ParallaxBackground"] position = Vector2(0, -82) motion_scale = Vector2(0.5, 0.5) -motion_mirroring = Vector2(10500, 0) +motion_mirroring = Vector2(10480, 0) [node name="Kenney Assets" type="Node2D" parent="ParallaxBackground/background layer 4"] visible = false @@ -475,7 +475,7 @@ texture = ExtResource("13_0qu0h") [node name="JelenaMockupBg03" type="Sprite2D" parent="ParallaxBackground/background layer 4"] material = SubResource("ShaderMaterial_wtdui") -position = Vector2(7965, 728) +position = Vector2(7923, 727) scale = Vector2(2.75, 2.75) texture = ExtResource("13_0qu0h") @@ -869,7 +869,7 @@ shape = SubResource("RectangleShape2D_0sfl7") _id = 1 [node name="CollisionShape3D" parent="YSorted/BrĂ¼nnen/InteractionArea/Area2D" index="0"] -position = Vector2(80, -368) +position = Vector2(146, -130) shape = SubResource("CircleShape2D_p6n74") [node name="HoeGenericPickup" parent="YSorted" instance=ExtResource("25_hukxv")] @@ -888,6 +888,9 @@ position = Vector2(8192, 3507) [node name="SpawnWithItem" parent="YSorted/CanGenericPickup" index="0"] _blueprint = ExtResource("28_ipqaa") +[node name="InteractionArea2" parent="YSorted/CanGenericPickup" index="3"] +position = Vector2(0, -159) + [node name="CollisionShape3D" parent="YSorted/CanGenericPickup/InteractionArea2/Area2D" index="0"] shape = SubResource("CircleShape2D_ipqaa") diff --git a/scripts/CSharp/Common/CharacterControls/Player2D.cs b/scripts/CSharp/Common/CharacterControls/Player2D.cs index f92ef76..0cb236e 100644 --- a/scripts/CSharp/Common/CharacterControls/Player2D.cs +++ b/scripts/CSharp/Common/CharacterControls/Player2D.cs @@ -10,6 +10,7 @@ public partial class Player2D : CharacterBody2D [Export] private float _speed = 100f; [Export] private AnimatedSprite2D _sprite; [Export] private SceneTree.GroupCallFlags _fieldFlags; + [Export] private CpuParticles2D _wateringParticles; // -1 means no tool. private int _toolID = -1; @@ -156,6 +157,7 @@ public partial class Player2D : CharacterBody2D _sprite.Animation = "diagonal wateringcan"; _sprite.Play(); _canHandleInput = false; + _wateringParticles.Emitting = true; Task.Run(DelayedInputHandlerReset); } } @@ -163,6 +165,7 @@ public partial class Player2D : CharacterBody2D private async Task DelayedInputHandlerReset() { await Task.Delay(1000); + _wateringParticles.Emitting = false; _canHandleInput = true; } diff --git a/scripts/CSharp/Common/Farming/FarmingControls2D.cs b/scripts/CSharp/Common/Farming/FarmingControls2D.cs index 5c05cff..aaa4bce 100644 --- a/scripts/CSharp/Common/Farming/FarmingControls2D.cs +++ b/scripts/CSharp/Common/Farming/FarmingControls2D.cs @@ -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 } \ No newline at end of file diff --git a/scripts/CSharp/Common/Farming/WateringCanState.cs b/scripts/CSharp/Common/Farming/WateringCanState.cs index 64dd048..8e4e89c 100644 --- a/scripts/CSharp/Common/Farming/WateringCanState.cs +++ b/scripts/CSharp/Common/Farming/WateringCanState.cs @@ -1,29 +1,70 @@ namespace Babushka.scripts.CSharp.Common.Farming; +/// +/// Holds Information about the current state of the watering can. +/// Since there is only one watering can, we can track this in one central static class. +/// public static class WateringCanState { private static int _fillstate = 0; - + + /// + /// How many fields can be watered with one filling of the watering can. + /// public const int MAX_FILLSTATE = 6; + + /// + /// The Tool ID of the watering can. Used to identify it amongst other pickup items (and things that can be held by Vesna). + /// + public const int WATERING_CAN_ID = 1; + + /// + /// Whether or not the watering can is currently active, i.e. held in hand by Vesna. + /// Triggers animations and ui. + /// + public static bool Active = false; + + /// + /// Resets the fillstate to the max amount. + /// public static void Fill() { _fillstate = MAX_FILLSTATE; } + /// + /// Called when watering a field. Reduces the current fillstate. + /// public static void Water() { if(_fillstate > 0) _fillstate--; } + /// + /// Resets the watering can. Equivalent to "Empty" state. + /// public static void Reset() { _fillstate = 0; } + /// + /// Returns the current fill state of the watering can. + /// + /// public static int GetFillState() { return _fillstate; } + + /// + /// Sets the Active state of the watering can, i.e. if it is currently in hand and if the ui should be active. + /// + /// + public static void SetActive(bool active) + { + Active = active; + } } \ No newline at end of file diff --git a/scripts/CSharp/Common/UI/WateringCanUi.cs b/scripts/CSharp/Common/UI/WateringCanUi.cs index c285817..ae62695 100644 --- a/scripts/CSharp/Common/UI/WateringCanUi.cs +++ b/scripts/CSharp/Common/UI/WateringCanUi.cs @@ -37,7 +37,7 @@ public partial class WateringCanUi : Node2D { for (int i = 0; i < _stages.Length; i++) { - _stages[i].Visible = i < WateringCanState.GetFillState(); + _stages[i].Visible = WateringCanState.Active && i < WateringCanState.GetFillState(); } }