Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aad6c44567 |
@@ -190,7 +190,6 @@ _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
|
||||||
@@ -198,7 +197,6 @@ 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
|
||||||
|
|||||||
@@ -307,11 +307,6 @@ public partial class FightHappening : Node
|
|||||||
HappeningData.enemyFighterFormation.SetFighterAtPosition(emptySlotIndex, fighter);
|
HappeningData.enemyFighterFormation.SetFighterAtPosition(emptySlotIndex, fighter);
|
||||||
HappeningData.fighterTurn.AddAsLast(fighter);
|
HappeningData.fighterTurn.AddAsLast(fighter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GD.RandRange(0, 2) != 0) // 2/3 chance for vesna to start
|
|
||||||
{
|
|
||||||
HappeningData.fighterTurn.SpinBack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteNextFighter()
|
private void ExecuteNextFighter()
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -99,23 +99,6 @@ public class FighterTurn : IEnumerable<FightWorld.Fighter>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the current one back
|
|
||||||
/// This is an expensive operation, because the entire data structure needs to be circled
|
|
||||||
/// </summary>
|
|
||||||
public void SpinBack()
|
|
||||||
{
|
|
||||||
if (_currentNode == null) return;
|
|
||||||
|
|
||||||
var node = _currentNode;
|
|
||||||
while (node.next != _currentNode)
|
|
||||||
{
|
|
||||||
node = node.next;
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentNode = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator<FightWorld.Fighter> GetEnumerator()
|
public IEnumerator<FightWorld.Fighter> GetEnumerator()
|
||||||
{
|
{
|
||||||
if (_currentNode == null) return Enumerable.Empty<FightWorld.Fighter>().GetEnumerator();
|
if (_currentNode == null) return Enumerable.Empty<FightWorld.Fighter>().GetEnumerator();
|
||||||
|
|||||||
Reference in New Issue
Block a user