modernised rockers pass turn

This commit is contained in:
Rapandrasmus 2023-06-13 16:13:08 +02:00
parent 0debf55391
commit 95c9b34695

View file

@ -113,12 +113,12 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("passTurn", "Pass Turn") new GameAction("passTurn", "Pass Turn")
{ {
function = delegate { var e = eventCaller.currentEntity; Rockers.instance.PassTurn(e.beat, e["moveCamera"]); }, preFunction = delegate { var e = eventCaller.currentEntity; Rockers.PrePassTurn(e.beat, e["moveCamera"]); },
resizable = true,
parameters = new List<Param> parameters = new List<Param>
{ {
new Param("moveCamera", true, "Move Camera", "Should the camera move?") new Param("moveCamera", true, "Move Camera", "Should the camera move?")
} },
preFunctionLength = 1
}, },
new GameAction("cmon", "C'mon!") new GameAction("cmon", "C'mon!")
{ {
@ -322,6 +322,7 @@ namespace HeavenStudio.Games
using Scripts_Rockers; using Scripts_Rockers;
using Starpelly; using Starpelly;
using System; using System;
using UnityEngine.UIElements;
public class Rockers : Minigame public class Rockers : Minigame
{ {
@ -529,6 +530,14 @@ namespace HeavenStudio.Games
return tempEvents; return tempEvents;
} }
struct QueuedPassTurn
{
public double beat;
public bool moveCamera;
}
private static List<QueuedPassTurn> passedTurns = new List<QueuedPassTurn>();
private void Start() private void Start()
{ {
if (PlayerInput.Pressing()) if (PlayerInput.Pressing())
@ -593,6 +602,15 @@ namespace HeavenStudio.Games
queuedPreInterval.Clear(); queuedPreInterval.Clear();
} }
if (passedTurns.Count > 0)
{
foreach (var turn in passedTurns)
{
PassTurn(turn.beat, turn.moveCamera);
}
passedTurns.Clear();
}
float normalizedBeat = cond.GetPositionFromBeat(cameraMoveBeat, 1f); float normalizedBeat = cond.GetPositionFromBeat(cameraMoveBeat, 1f);
if (normalizedBeat >= 0f && normalizedBeat <= 1f) if (normalizedBeat >= 0f && normalizedBeat <= 1f)
@ -972,9 +990,29 @@ namespace HeavenStudio.Games
} }
} }
public void PassTurn(double beat, bool moveCamera) public static void PrePassTurn(double beat, bool moveCamera)
{
if (GameManager.instance.currentGame == "rockers")
{
instance.PassTurn(beat, moveCamera);
}
else
{
passedTurns.Add(new QueuedPassTurn
{
beat = beat,
moveCamera = moveCamera
});
}
}
private void PassTurn(double beat, bool moveCamera)
{ {
if (crHandlerInstance.queuedEvents.Count > 0) if (crHandlerInstance.queuedEvents.Count > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat -1, delegate
{ {
List<CallAndResponseHandler.CallAndResponseEvent> crEvents = crHandlerInstance.queuedEvents; List<CallAndResponseHandler.CallAndResponseEvent> crEvents = crHandlerInstance.queuedEvents;
@ -983,21 +1021,20 @@ namespace HeavenStudio.Games
if (crEvent.tag == "riff") if (crEvent.tag == "riff")
{ {
RockersInput riffComp = Instantiate(rockerInputRef, transform); RockersInput riffComp = Instantiate(rockerInputRef, transform);
riffComp.Init(crEvent["gleeClub"], new int[6] { crEvent["1"], crEvent["2"], crEvent["3"], crEvent["4"], crEvent["5"], crEvent["6"] }, beat, 1 + crEvent.relativeBeat, riffComp.Init(crEvent["gleeClub"], new int[6] { crEvent["1"], crEvent["2"], crEvent["3"], crEvent["4"], crEvent["5"], crEvent["6"] }, beat, crEvent.relativeBeat,
(PremadeSamples)crEvent["sample"], crEvent["sampleTones"]); (PremadeSamples)crEvent["sample"], crEvent["sampleTones"]);
ScheduleInput(beat, 1 + crEvent.relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty); ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty);
} }
else if (crEvent.tag == "bend") else if (crEvent.tag == "bend")
{ {
RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform); RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform);
bendComp.Init(crEvent["Pitch"], beat, 1 + crEvent.relativeBeat); bendComp.Init(crEvent["Pitch"], beat, crEvent.relativeBeat);
ScheduleInput(beat, 1 + crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty); ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty);
} }
} }
crHandlerInstance.queuedEvents.Clear(); crHandlerInstance.queuedEvents.Clear();
BeatAction.New(instance.gameObject, new List<BeatAction.Action>() }),
{ new BeatAction.Action(beat, delegate
new BeatAction.Action(beat + 1, delegate
{ {
JJ.UnHold(); JJ.UnHold();
if (crHandlerInstance.queuedEvents.Count > 0) if (crHandlerInstance.queuedEvents.Count > 0)
@ -1009,15 +1046,15 @@ namespace HeavenStudio.Games
if (crEvent.tag == "riff") if (crEvent.tag == "riff")
{ {
RockersInput riffComp = Instantiate(rockerInputRef, transform); RockersInput riffComp = Instantiate(rockerInputRef, transform);
riffComp.Init(crEvent["gleeClub"], new int[6] { crEvent["1"], crEvent["2"], crEvent["3"], crEvent["4"], crEvent["5"], crEvent["6"] }, beat, 1 + crEvent.relativeBeat, riffComp.Init(crEvent["gleeClub"], new int[6] { crEvent["1"], crEvent["2"], crEvent["3"], crEvent["4"], crEvent["5"], crEvent["6"] }, beat, crEvent.relativeBeat,
(PremadeSamples)crEvent["sample"], crEvent["sampleTones"]); (PremadeSamples)crEvent["sample"], crEvent["sampleTones"]);
ScheduleInput(beat, 1 + crEvent.relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty); ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty);
} }
else if (crEvent.tag == "bend") else if (crEvent.tag == "bend")
{ {
RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform); RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform);
bendComp.Init(crEvent["Pitch"], beat, 1 + crEvent.relativeBeat); bendComp.Init(crEvent["Pitch"], beat, crEvent.relativeBeat);
ScheduleInput(beat, 1 + crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty); ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty);
} }
} }
crHandlerInstance.queuedEvents.Clear(); crHandlerInstance.queuedEvents.Clear();
@ -1028,7 +1065,7 @@ namespace HeavenStudio.Games
{ {
lastTargetCameraX = GameCamera.additionalPosition.x; lastTargetCameraX = GameCamera.additionalPosition.x;
targetCameraX = Soshi.transform.localPosition.x; targetCameraX = Soshi.transform.localPosition.x;
cameraMoveBeat = beat; cameraMoveBeat = beat - 1;
} }
} }
} }