|
|
|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
if (to != FightHappening.FightState.InputActionDetail) return;
|
|
|
|
|
|
|
|
|
|
var currentDetail = HappeningData.actionStaging!.CurrentDetail();
|
|
|
|
|
if(currentDetail is not MinigameActionDetail minigameDetail) return;
|
|
|
|
|
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
|
|
|
|
|
}
|