Added counter script to count ducks (and other things)

pull/12/head
kziolkowski 6 months ago
parent 480d149ede
commit c7d56301fc

@ -1,3 +1,3 @@
join vesna left
join vesna center
Thats the last one. I should get back to Yeli.
[end_timeline]

@ -1,4 +1,4 @@
[gd_scene load_steps=98 format=3 uid="uid://gigb28qk8t12"]
[gd_scene load_steps=101 format=3 uid="uid://gigb28qk8t12"]
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="1_7wfwe"]
[ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"]
@ -60,6 +60,9 @@
[ext_resource type="Texture2D" uid="uid://lvhbicmwqab5" path="res://art/farm/tilable grounds/böden/fruchtbarer wilder trockender boden.png" id="47_loeum"]
[ext_resource type="AudioStream" uid="uid://c43a6x43jkikl" path="res://audio/sfx/Farming/SFX_GettingWater_Well_01_Reverb.wav" id="49_d77e7"]
[ext_resource type="Texture2D" uid="uid://blb3agipyxnal" path="res://art/farm/farming/farmobjekte/zaun/fence_door.png" id="49_i36hd"]
[ext_resource type="Script" uid="uid://l6iq8rpym5io" path="res://scripts/CSharp/Common/Util/Counter.cs" id="49_uxa2m"]
[ext_resource type="Script" uid="uid://dnipeibppjirs" path="res://scripts/CSharp/Common/NPC/DialogicOverlayStarter.cs" id="51_uxa2m"]
[ext_resource type="Script" uid="uid://d2486x6upmwqq" path="res://scripts/GdScript/dialogic_starter.gd" id="52_lwk6t"]
[ext_resource type="PackedScene" uid="uid://muuxxgvx33fp" path="res://prefabs/farm/duck.tscn" id="62_i36hd"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wtdui"]
@ -1003,7 +1006,7 @@ y_sort_enabled = true
[node name="Yeli" parent="YSorted" instance=ExtResource("24_wtdui")]
position = Vector2(6403, 3362)
_timelinesToPlay = PackedStringArray("quest1_ducks_start", "quest1_ducks_end", "quest2_tomatoes_start", "quest2_tomatoes_interim", "quest2_tomatoes_end")
_timelinesToPlay = PackedStringArray("quest1_ducks_start", "quest2_tomatoes_start", "quest2_tomatoes_interim", "quest2_tomatoes_end")
[node name="Vesna" parent="YSorted" node_paths=PackedStringArray("_fieldParent") instance=ExtResource("1_7wfwe")]
z_index = 1
@ -2119,6 +2122,8 @@ position = Vector2(-106.663, 182.891)
shape = SubResource("RectangleShape2D_ycj14")
[node name="ducks" type="Node2D" parent="YSorted"]
script = ExtResource("49_uxa2m")
_goal = 6
[node name="Duck2" parent="YSorted/ducks" node_paths=PackedStringArray("_penTarget") instance=ExtResource("62_i36hd")]
position = Vector2(4374, 2652)
@ -2150,6 +2155,14 @@ rotation = 3.14159
scale = Vector2(1, -1)
_penTarget = NodePath("../../pen/penSlot6")
[node name="DialogicToggle" type="Node2D" parent="YSorted/ducks"]
script = ExtResource("51_uxa2m")
_timelinesToPlay = PackedStringArray("quest1_ducks_end")
_startOnReady = false
[node name="dialogic starter" type="Node2D" parent="YSorted/ducks"]
script = ExtResource("52_lwk6t")
[node name="pen" type="Node2D" parent="YSorted"]
[node name="penSlot1" type="Node2D" parent="YSorted/pen"]
@ -2243,6 +2256,14 @@ script = ExtResource("40_w3jkj")
[connection signal="InteractedTool" from="YSorted/Farm visuals/Static/EnterHouseInteraction" to="." method="LoadSceneAtIndex"]
[connection signal="FieldCreated" from="YSorted/Farm visuals/FieldParent" to="Audio/SFX/Farming SFX" method="PlayOneShot"]
[connection signal="input_event" from="YSorted/Farm visuals/FieldParent/Area2D" to="YSorted/Vesna/FarmingControls" method="InputEventPressedOn"]
[connection signal="GoalReached" from="YSorted/ducks" to="YSorted/ducks/DialogicToggle" method="ToggleDialogue"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck2" to="YSorted/ducks" method="Increment"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck3" to="YSorted/ducks" method="Increment"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck4" to="YSorted/ducks" method="Increment"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck5" to="YSorted/ducks" method="Increment"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck6" to="YSorted/ducks" method="Increment"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck7" to="YSorted/ducks" method="Increment"]
[connection signal="Dialogue" from="YSorted/ducks/DialogicToggle" to="YSorted/ducks/dialogic starter" method="open"]
[connection signal="finished" from="Audio/Background Music Ramp up" to="Audio/Background Music loop" method="PlayFromOffset"]
[editable path="YSorted/Vesna"]

@ -19,6 +19,7 @@ public partial class DialogicOverlayStarter : Node2D
public void ToggleDialogue()
{
ToggleDialogue(_timelinesToPlay[_timelineIndex]);
GD.Print("Toggling Dialogue");
}
public void ToggleDialogue(int index)

@ -13,6 +13,7 @@ public partial class MVPDuck : Node2D
[Export] private AnimationPlayer _animationPlayer;
[Export] private string _flapAnimationName = "flapFlap";
[Signal] public delegate void DuckCollectedEventHandler();
public void TransferToTargetAfterDelay()
{
@ -29,7 +30,8 @@ public partial class MVPDuck : Node2D
public async void MoveAfterDelay()
{
await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); // 1.0f seconds
Position = _penTarget.GlobalPosition; // Now this works!
Position = _penTarget.GlobalPosition;
EmitSignal(SignalName.DuckCollected);
}

@ -0,0 +1,43 @@
using Godot;
namespace Babushka.scripts.CSharp.Common.Util;
public partial class Counter : Node2D
{
[Export] private int _startFrom = 0;
[Export] private int _goal = 0;
private int _counter;
[Signal] public delegate void CounterChangedEventHandler(int amount);
[Signal] public delegate void GoalReachedEventHandler();
public override void _Ready()
{
_counter = _startFrom;
}
public void Increment()
{
_counter++;
EmitSignal(SignalName.CounterChanged, _counter);
GD.Print(_counter);
if (_counter == _goal)
{
GD.Print("Emitting goal reached signal");
EmitSignal(SignalName.GoalReached);
}
}
public void Decrement()
{
_counter--;
EmitSignal(SignalName.CounterChanged, _counter);
if (_counter == _goal)
{
EmitSignal(SignalName.GoalReached);
}
}
}
Loading…
Cancel
Save