Compare commits

...

10 Commits

6 changed files with 58 additions and 25 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" FightWorldAutoload="*res://prefabs/fight/fight_world_autoload.tscn"
SaveGameManager="*res://scripts/CSharp/Common/Savegame/SaveGameManager.cs" SaveGameManager="*res://scripts/CSharp/Common/Savegame/SaveGameManager.cs"
SettingsSaveController="*res://scripts/CSharp/Common/Savegame/SettingsSaveController.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] [dialogic]
@@ -54,6 +54,7 @@ _minigameController = NodePath("Minigame")
[node name="Minigame" parent="MinigameHandler" instance=ExtResource("8_2b3cf")] [node name="Minigame" parent="MinigameHandler" instance=ExtResource("8_2b3cf")]
process_mode = 4 process_mode = 4
visible = false visible = false
position = Vector2(23, -29)
[node name="SwitchSceneOnFightEnd" type="Node" parent="." node_paths=PackedStringArray("_fightSceneSwitcher")] [node name="SwitchSceneOnFightEnd" type="Node" parent="." node_paths=PackedStringArray("_fightSceneSwitcher")]
script = ExtResource("10_qqd8u") script = ExtResource("10_qqd8u")
@@ -190,6 +191,7 @@ _label = NodePath("Label")
_current = NodePath("Current") _current = NodePath("Current")
[node name="Label" type="Label" parent="StateMachineDebugger"] [node name="Label" type="Label" parent="StateMachineDebugger"]
visible = false
offset_left = -982.0 offset_left = -982.0
offset_top = -497.0 offset_top = -497.0
offset_right = -893.0 offset_right = -893.0
@@ -197,6 +199,7 @@ offset_bottom = -474.0
text = "Hello world" text = "Hello world"
[node name="Current" type="Label" parent="StateMachineDebugger"] [node name="Current" type="Label" parent="StateMachineDebugger"]
visible = false
offset_left = 705.0 offset_left = 705.0
offset_top = -495.0 offset_top = -495.0
offset_right = 794.0 offset_right = 794.0
@@ -19,7 +19,13 @@ public partial class VesnaAnimations : Node
/// </summary> /// </summary>
[Signal] public delegate void LookDirectionEventHandler(Vector2 direction); [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; InventoryManager.Instance.playerInventory.InventoryContentsChanged += HandleNewItemInInventory;
} }
@@ -62,11 +62,6 @@ public partial class PlantBehaviour2D : Node2D
} }
} }
public void IncrementDaysGrowing()
{
DayPlanted++;
}
public string PrefabPath => _prefabPath; public string PrefabPath => _prefabPath;
/// <summary> /// <summary>
@@ -1,36 +1,44 @@
using Godot;
using System;
using System.Collections.Generic; 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.Fight.ActionDetails;
using Babushka.scripts.CSharp.Common.Minigame; 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 public partial class FightMinigameHandler : Node
{ {
#region Shortcuts #region Shortcuts
private FightWorld.FightHappeningData HappeningData => FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException(); private FightWorld.FightHappeningData HappeningData =>
FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
#endregion #endregion
[Export] private MinigameController _minigameController; [Export] private MinigameController _minigameController = null!;
public void OnStateEnter(FightHappening.FightState to) public void OnStateEnter(FightHappening.FightState to)
{ {
if(to!=FightHappening.FightState.InputActionDetail) return; if (to != FightHappening.FightState.InputActionDetail) return;
var currentDetail = HappeningData.actionStaging!.CurrentDetail();
if(currentDetail is not MinigameActionDetail minigameDetail) 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>() _minigameController.Run(new MinigameController.Builder<int>()
.AddRegion(4).RegionWithText("4").RegionWithTheme(MinigameController.RegionTheme.Normal) .AddRegion(region1).RegionWithProportion(R(0.7, 1.3)).RegionWithText(region1.ToString()).RegionWithTheme(Normal)
.AddRegion(0).RegionWithProportion(1.5f).RegionWithText("0").RegionWithTheme(MinigameController.RegionTheme.Bad) .AddRegion(region2).RegionWithProportion(R(1, 1.8)).RegionWithText(region2.ToString()).RegionWithTheme(Bad)
.AddRegion(8).RegionWithProportion(0.5f).RegionWithText("8").RegionWithTheme(MinigameController.RegionTheme.VeryGood) .AddRegion(region3).RegionWithProportion(R(0.3, 1)).RegionWithText(region3.ToString()).RegionWithTheme(VeryGood)
.AddRegion(0).RegionWithProportion(1.5f).RegionWithText("0").RegionWithTheme(MinigameController.RegionTheme.Bad) .AddRegion(region4).RegionWithProportion(R(1, 1.8)).RegionWithText(region4.ToString()).RegionWithTheme(Bad)
.AddRegion(3).RegionWithText("3").RegionWithTheme(MinigameController.RegionTheme.NormalAlt1) .AddRegion(region5).RegionWithProportion(R(0.7, 1.3)).RegionWithText(region5.ToString()).RegionWithTheme(NormalAlt1)
.AddRegion(5).RegionWithText("5").RegionWithTheme(MinigameController.RegionTheme.NormalAlt2) .AddRegion(region6).RegionWithProportion(R(0.7, 1.3)).RegionWithText(region6.ToString()).RegionWithTheme(NormalAlt2)
.WithHitCount(3) .WithHitCount(3)
).ContinueWith(task => ).ContinueWith(task =>
{ {
@@ -40,4 +48,25 @@ public partial class FightMinigameHandler : Node
FightHappening.Instance.CallDeferred("DetailFilled"); 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
}