You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.9 KiB
44 lines
1.9 KiB
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;
|
|
|
|
public partial class FightMinigameHandler : Node
|
|
{
|
|
#region Shortcuts
|
|
|
|
private FightWorld.FightHappeningData HappeningData => FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
|
|
|
|
#endregion
|
|
|
|
[Export] private MinigameController _minigameController;
|
|
|
|
|
|
public void OnStateEnter(FightHappening.FightState to)
|
|
{
|
|
if(to!=FightHappening.FightState.InputActionDetail) return;
|
|
|
|
var currentDetail = HappeningData.actionStaging!.CurrentDetail();
|
|
if(currentDetail is not MinigameActionDetail minigameDetail) return;
|
|
|
|
_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)
|
|
.WithHitCount(3)
|
|
).ContinueWith(task =>
|
|
{
|
|
minigameDetail.damageHits = task.Result;
|
|
//FightHappening.Instance.DetailFilled();
|
|
// Apparently ContinueWith spawn a new Thread, but methods on a node only want to be called from the main thread
|
|
FightHappening.Instance.CallDeferred("DetailFilled");
|
|
});
|
|
}
|
|
}
|