From 0bfafac6fe9af68547b92e48321e54dd0221f469 Mon Sep 17 00:00:00 2001
From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com>
Date: Tue, 13 Jun 2023 16:13:08 +0200
Subject: [PATCH] modernised rockers pass turn
---
Assets/Scripts/Games/Rockers/Rockers.cs | 95 +++++++++++++++++--------
1 file changed, 66 insertions(+), 29 deletions(-)
diff --git a/Assets/Scripts/Games/Rockers/Rockers.cs b/Assets/Scripts/Games/Rockers/Rockers.cs
index 5b0dbacd..d7ebccd3 100644
--- a/Assets/Scripts/Games/Rockers/Rockers.cs
+++ b/Assets/Scripts/Games/Rockers/Rockers.cs
@@ -113,12 +113,12 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("passTurn", "Pass Turn")
{
- function = delegate { var e = eventCaller.currentEntity; Rockers.instance.PassTurn(e.beat, e["moveCamera"]); },
- resizable = true,
+ preFunction = delegate { var e = eventCaller.currentEntity; Rockers.PrePassTurn(e.beat, e["moveCamera"]); },
parameters = new List
{
new Param("moveCamera", true, "Move Camera", "Should the camera move?")
- }
+ },
+ preFunctionLength = 1
},
new GameAction("cmon", "C'mon!")
{
@@ -322,6 +322,7 @@ namespace HeavenStudio.Games
using Scripts_Rockers;
using Starpelly;
using System;
+ using UnityEngine.UIElements;
public class Rockers : Minigame
{
@@ -529,6 +530,14 @@ namespace HeavenStudio.Games
return tempEvents;
}
+ struct QueuedPassTurn
+ {
+ public double beat;
+ public bool moveCamera;
+ }
+
+ private static List passedTurns = new List();
+
private void Start()
{
if (PlayerInput.Pressing())
@@ -593,6 +602,15 @@ namespace HeavenStudio.Games
queuedPreInterval.Clear();
}
+ if (passedTurns.Count > 0)
+ {
+ foreach (var turn in passedTurns)
+ {
+ PassTurn(turn.beat, turn.moveCamera);
+ }
+ passedTurns.Clear();
+ }
+
float normalizedBeat = cond.GetPositionFromBeat(cameraMoveBeat, 1f);
if (normalizedBeat >= 0f && normalizedBeat <= 1f)
@@ -972,32 +990,51 @@ 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)
{
- List crEvents = crHandlerInstance.queuedEvents;
-
- foreach (var crEvent in crEvents)
- {
- if (crEvent.tag == "riff")
- {
- 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,
- (PremadeSamples)crEvent["sample"], crEvent["sampleTones"]);
- ScheduleInput(beat, 1 + crEvent.relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty);
- }
- else if (crEvent.tag == "bend")
- {
- RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform);
- bendComp.Init(crEvent["Pitch"], beat, 1 + crEvent.relativeBeat);
- ScheduleInput(beat, 1 + crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty);
- }
- }
- crHandlerInstance.queuedEvents.Clear();
BeatAction.New(instance.gameObject, new List()
{
- new BeatAction.Action(beat + 1, delegate
+ new BeatAction.Action(beat -1, delegate
+ {
+ List crEvents = crHandlerInstance.queuedEvents;
+
+ foreach (var crEvent in crEvents)
+ {
+ if (crEvent.tag == "riff")
+ {
+ 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, crEvent.relativeBeat,
+ (PremadeSamples)crEvent["sample"], crEvent["sampleTones"]);
+ ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty);
+ }
+ else if (crEvent.tag == "bend")
+ {
+ RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform);
+ bendComp.Init(crEvent["Pitch"], beat, crEvent.relativeBeat);
+ ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty);
+ }
+ }
+ crHandlerInstance.queuedEvents.Clear();
+ }),
+ new BeatAction.Action(beat, delegate
{
JJ.UnHold();
if (crHandlerInstance.queuedEvents.Count > 0)
@@ -1009,15 +1046,15 @@ namespace HeavenStudio.Games
if (crEvent.tag == "riff")
{
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"]);
- 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")
{
RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform);
- bendComp.Init(crEvent["Pitch"], beat, 1 + crEvent.relativeBeat);
- ScheduleInput(beat, 1 + crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty);
+ bendComp.Init(crEvent["Pitch"], beat, crEvent.relativeBeat);
+ ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty);
}
}
crHandlerInstance.queuedEvents.Clear();
@@ -1028,7 +1065,7 @@ namespace HeavenStudio.Games
{
lastTargetCameraX = GameCamera.additionalPosition.x;
targetCameraX = Soshi.transform.localPosition.x;
- cameraMoveBeat = beat;
+ cameraMoveBeat = beat - 1;
}
}
}