Compare commits

..

11 Commits

12 changed files with 86 additions and 31 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ Signal_Debugger="*res://addons/SignalVisualizer/Debugger/SignalDebugger.gd"
FightWorldAutoload="*res://prefabs/fight/fight_world_autoload.tscn"
SaveGameManager="*res://scripts/CSharp/Common/Savegame/SaveGameManager.cs"
SettingsSaveController="*res://scripts/CSharp/Common/Savegame/SettingsSaveController.cs"
DayAndNight="*res://prefabs/day and night/day_and_night.tscn"
DayAndNight="*res://prefabs/day_and_night/day_and_night.tscn"
[dialogic]
@@ -1296,6 +1296,7 @@ polygon = PackedVector2Array(247.227, 43.5123, 44.7822, 43.5123, -87.2178, 45.12
[node name="EnterHouseInteraction" parent="YSorted/Farm visuals/Static" instance=ExtResource("27_klb81")]
position = Vector2(5834, 2354)
scale = Vector2(2.425, 2.425)
_id = 0
metadata/SaveID = "5a93071f-c1ab-4b4b-b74e-a6324d44ddf8"
[node name="DoorSprite" type="Sprite2D" parent="YSorted/Farm visuals/Static/EnterHouseInteraction"]
@@ -54,6 +54,7 @@ _minigameController = NodePath("Minigame")
[node name="Minigame" parent="MinigameHandler" instance=ExtResource("8_2b3cf")]
process_mode = 4
visible = false
position = Vector2(23, -29)
[node name="SwitchSceneOnFightEnd" type="Node" parent="." node_paths=PackedStringArray("_fightSceneSwitcher")]
script = ExtResource("10_qqd8u")
@@ -190,6 +191,7 @@ _label = NodePath("Label")
_current = NodePath("Current")
[node name="Label" type="Label" parent="StateMachineDebugger"]
visible = false
offset_left = -982.0
offset_top = -497.0
offset_right = -893.0
@@ -197,6 +199,7 @@ offset_bottom = -474.0
text = "Hello world"
[node name="Current" type="Label" parent="StateMachineDebugger"]
visible = false
offset_left = 705.0
offset_top = -495.0
offset_right = 794.0
@@ -218,7 +218,7 @@ radius = 400.0
z_index = 1
y_sort_enabled = true
script = ExtResource("1_3vr4f")
_sceneNamesToLoad = PackedStringArray("res://scenes/Babushka_scene_indoor_vesnas_room.tscn", "res://scenes/Babushka_scene_farm_outside_2d_ducksCollected.tscn")
_sceneNamesToLoad = PackedStringArray("res://scenes/Babushka_scene_indoor_vesnas_room.tscn", "res://scenes/Babushka_scene_farm_outside_2d.tscn")
[node name="Foreground" type="Node" parent="."]
@@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://ceaa2qj2bmw43"]
[gd_scene load_steps=16 format=3 uid="uid://ceaa2qj2bmw43"]
[ext_resource type="Script" uid="uid://cssdu8viimwm6" path="res://scripts/CSharp/Common/SceneTransition.cs" id="1_c6eln"]
[ext_resource type="Texture2D" uid="uid://cugtxcfuds31r" path="res://art/indoor/Babushka_bg_01.png" id="2_j25a2"]
@@ -6,6 +6,7 @@
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="8_phqdf"]
[ext_resource type="Resource" uid="uid://csj15gnlx1jmx" path="res://resources/quests/demo/8_goto_bed.tres" id="9_heyef"]
[ext_resource type="Script" uid="uid://puw74w6lmcvl" path="res://scripts/CSharp/Common/Fight/NightStarter.cs" id="10_j25a2"]
[ext_resource type="Script" uid="uid://jg4jryfus3bw" path="res://scripts/CSharp/Common/DayAndNight/DayAndNightHelper.cs" id="11_heyef"]
[ext_resource type="Texture2D" uid="uid://cop1vjvhwlsec" path="res://art/indoor/room export/Room_01_shelf.png" id="13_11fdt"]
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Vesna.tscn" id="18_3gevq"]
[ext_resource type="Script" uid="uid://bqomwxclsbhd3" path="res://scripts/CSharp/Common/Camera/CameraController.cs" id="23_408bg"]
@@ -125,8 +126,12 @@ shape = SubResource("CircleShape2D_2spkc")
script = ExtResource("10_j25a2")
_sceneIndexToLoad = 1
[node name="CountDayUp" type="Node" parent="NightStarter"]
script = ExtResource("11_heyef")
[connection signal="Interacted" from="BedInteraction" to="BedInteraction/QuestCompleter" method="Trigger"]
[connection signal="Interacted" from="BedInteraction" to="NightStarter" method="StartNight"]
[connection signal="Interacted" from="BedInteraction" to="NightStarter/CountDayUp" method="IncreaseDayCount"]
[connection signal="Interacted" from="DoorInteraction" to="." method="LoadScene"]
[connection signal="LoadScene" from="NightStarter" to="." method="LoadSceneAtIndex"]
@@ -19,7 +19,13 @@ public partial class VesnaAnimations : Node
/// </summary>
[Signal] public delegate void LookDirectionEventHandler(Vector2 direction);
public override void _Ready()
public override void _EnterTree()
{
// calling with a 1-frame delay to avoid race conditions.
CallDeferred(nameof(SetupSubscriptions));
}
private void SetupSubscriptions()
{
InventoryManager.Instance.playerInventory.InventoryContentsChanged += HandleNewItemInInventory;
}
@@ -31,10 +31,14 @@ public partial class CalendarController : Node
{
if (@event.IsActionPressed("NextDayCheat"))
{
int days = _dayCounter.Payload.AsInt32();
days++;
_dayCounter.Payload = days;
GoToNextDay();
}
}
public void GoToNextDay()
{
int days = _dayCounter.Payload.AsInt32();
days++;
_dayCounter.Payload = days;
}
}
@@ -0,0 +1,11 @@
using Godot;
namespace Babushka.scripts.CSharp.Common.DayAndNight;
public partial class DayAndNightHelper : Node
{
public void IncreaseDayCount()
{
CalendarController.Instance?.GoToNextDay();
}
}
@@ -0,0 +1 @@
uid://jg4jryfus3bw
@@ -62,11 +62,6 @@ public partial class PlantBehaviour2D : Node2D
}
}
public void IncrementDaysGrowing()
{
DayPlanted++;
}
public string PrefabPath => _prefabPath;
/// <summary>
@@ -1,36 +1,44 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Babushka.scripts.CSharp.Common.Fight;
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
using Babushka.scripts.CSharp.Common.Minigame;
using Godot;
using static Babushka.scripts.CSharp.Common.Minigame.MinigameController.RegionTheme;
namespace Babushka.scripts.CSharp.Common.Fight;
public partial class FightMinigameHandler : Node
{
#region Shortcuts
private FightWorld.FightHappeningData HappeningData => FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
private FightWorld.FightHappeningData HappeningData =>
FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
#endregion
[Export] private MinigameController _minigameController;
[Export] private MinigameController _minigameController = null!;
public void OnStateEnter(FightHappening.FightState to)
{
if(to!=FightHappening.FightState.InputActionDetail) return;
var currentDetail = HappeningData.actionStaging!.CurrentDetail();
if(currentDetail is not MinigameActionDetail minigameDetail) return;
if (to != FightHappening.FightState.InputActionDetail) return;
var currentDetail = HappeningData.actionStaging!.CurrentDetail();
if (currentDetail is not MinigameActionDetail minigameDetail) return;
var region1 = R(2, 4);
var region2 = R([0, 1, 1, 2]);
var region3 = R([7, 8, 9, 9]);
var region4 = R([0, 1, 1, 2]);
var region5 = R(2, 4);
var region6 = R(4, 6);
_minigameController.Run(new MinigameController.Builder<int>()
.AddRegion(4).RegionWithText("4").RegionWithTheme(MinigameController.RegionTheme.Normal)
.AddRegion(0).RegionWithProportion(1.5f).RegionWithText("0").RegionWithTheme(MinigameController.RegionTheme.Bad)
.AddRegion(8).RegionWithProportion(0.5f).RegionWithText("8").RegionWithTheme(MinigameController.RegionTheme.VeryGood)
.AddRegion(0).RegionWithProportion(1.5f).RegionWithText("0").RegionWithTheme(MinigameController.RegionTheme.Bad)
.AddRegion(3).RegionWithText("3").RegionWithTheme(MinigameController.RegionTheme.NormalAlt1)
.AddRegion(5).RegionWithText("5").RegionWithTheme(MinigameController.RegionTheme.NormalAlt2)
.AddRegion(region1).RegionWithProportion(R(0.7, 1.3)).RegionWithText(region1.ToString()).RegionWithTheme(Normal)
.AddRegion(region2).RegionWithProportion(R(1, 1.8)).RegionWithText(region2.ToString()).RegionWithTheme(Bad)
.AddRegion(region3).RegionWithProportion(R(0.3, 1)).RegionWithText(region3.ToString()).RegionWithTheme(VeryGood)
.AddRegion(region4).RegionWithProportion(R(1, 1.8)).RegionWithText(region4.ToString()).RegionWithTheme(Bad)
.AddRegion(region5).RegionWithProportion(R(0.7, 1.3)).RegionWithText(region5.ToString()).RegionWithTheme(NormalAlt1)
.AddRegion(region6).RegionWithProportion(R(0.7, 1.3)).RegionWithText(region6.ToString()).RegionWithTheme(NormalAlt2)
.WithHitCount(3)
).ContinueWith(task =>
{
@@ -40,4 +48,25 @@ public partial class FightMinigameHandler : Node
FightHappening.Instance.CallDeferred("DetailFilled");
});
}
}
#region Utils
// this is to make the minigame set up a bit less convoluted
private static int R(int min, int max)
{
return GD.RandRange(min, max);
}
private static float R(double min, double max)
{
return (float)GD.RandRange(min, max);
}
private static int R(List<int> list)
{
return list[GD.RandRange(0, list.Count - 1)];
}
#endregion
}