monkey watch camera refactor
run sourcegen
This commit is contained in:
parent
831b475d3b
commit
483f9353ef
|
|
@ -29,7 +29,7 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN))
|
if (PlayerInput.GetIsAction(MonkeyWatch.InputAction_BasicPress) && !game.IsExpectingInputNow(MonkeyWatch.InputAction_BasicPress))
|
||||||
{
|
{
|
||||||
PlayerClap(false, false, true);
|
PlayerClap(false, false, true);
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +89,7 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
||||||
|
|
||||||
public void PlayerClap(bool big, bool barely, bool whiff)
|
public void PlayerClap(bool big, bool barely, bool whiff)
|
||||||
{
|
{
|
||||||
if (playerMonkeyAnim.IsPlayingAnimationName("PlayerClapBarely") && whiff) return;
|
if (playerMonkeyAnim.IsPlayingAnimationNames("PlayerClapBarely") && whiff) return;
|
||||||
if (whiff)
|
if (whiff)
|
||||||
{
|
{
|
||||||
game.middleMonkey.DoScaledAnimationAsync("MiddleMonkeyMiss", 0.4f);
|
game.middleMonkey.DoScaledAnimationAsync("MiddleMonkeyMiss", 0.4f);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace HeavenStudio.Games.Loaders
|
||||||
defaultLength = 2f,
|
defaultLength = 2f,
|
||||||
parameters = new List<Param>()
|
parameters = new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("min", new EntityTypes.Integer(0, 59, 0), "Set Starting Second", "1 second is equivalent to 1 monkey.")
|
new Param("min", new EntityTypes.Integer(0, 59, 0), "Set Starting Second", "A second is equivalent to one monkey.")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new GameAction("off", "Pink Monkeys")
|
new GameAction("off", "Pink Monkeys")
|
||||||
|
|
@ -99,7 +99,7 @@ namespace HeavenStudio.Games.Loaders
|
||||||
parameters = new List<Param>()
|
parameters = new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("instant", false, "Instant"),
|
new Param("instant", false, "Instant"),
|
||||||
new Param("timeMode", MonkeyWatch.TimeMode.RealTime, "Time Mode", "Will the clock set the time to the current time or a certain time?"),
|
new Param("timeMode", MonkeyWatch.TimeMode.RealTime, "Time Mode", "Set the clock to system time or a certain time"),
|
||||||
new Param("hour", new EntityTypes.Integer(0, 12, 3), "Hour"),
|
new Param("hour", new EntityTypes.Integer(0, 12, 3), "Hour"),
|
||||||
new Param("minute", new EntityTypes.Integer(0, 59, 0), "Minute")
|
new Param("minute", new EntityTypes.Integer(0, 59, 0), "Minute")
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +115,7 @@ namespace HeavenStudio.Games.Loaders
|
||||||
parameters = new List<Param>()
|
parameters = new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("instant", false, "Instant"),
|
new Param("instant", false, "Instant"),
|
||||||
new Param("timeMode", MonkeyWatch.TimeMode.RealTime, "Time Mode", "Will the clock set the time to the current time or a certain time?"),
|
new Param("timeMode", MonkeyWatch.TimeMode.RealTime, "Time Mode", "Set the clock to system time or a certain time"),
|
||||||
new Param("hour", new EntityTypes.Integer(0, 12, 3), "Hour"),
|
new Param("hour", new EntityTypes.Integer(0, 12, 3), "Hour"),
|
||||||
new Param("minute", new EntityTypes.Integer(0, 59, 0), "Minute")
|
new Param("minute", new EntityTypes.Integer(0, 59, 0), "Minute")
|
||||||
}
|
}
|
||||||
|
|
@ -174,13 +174,8 @@ namespace HeavenStudio.Games
|
||||||
[SerializeField] private Util.EasingFunction.Ease zoomInEase;
|
[SerializeField] private Util.EasingFunction.Ease zoomInEase;
|
||||||
private float lastAngle = 0f;
|
private float lastAngle = 0f;
|
||||||
private int cameraIndex = 0;
|
private int cameraIndex = 0;
|
||||||
private struct MonkeyCamera
|
private float cameraWantAngle, cameraAngleDelay;
|
||||||
{
|
private float delayRate = 0.5f, targetDelayRate;
|
||||||
public float degreeTo;
|
|
||||||
public float length;
|
|
||||||
public double beat;
|
|
||||||
}
|
|
||||||
private List<MonkeyCamera> cameraMovements = new();
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
|
@ -189,6 +184,10 @@ namespace HeavenStudio.Games
|
||||||
funcIn = Util.EasingFunction.GetEasingFunction(zoomInEase);
|
funcIn = Util.EasingFunction.GetEasingFunction(zoomInEase);
|
||||||
pinkMonkeys = EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "off", "offStretch" });
|
pinkMonkeys = EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "off", "offStretch" });
|
||||||
pinkMonkeysCustom = EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "offInterval" });
|
pinkMonkeysCustom = EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "offInterval" });
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
CameraUpdate();
|
CameraUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,10 +196,11 @@ namespace HeavenStudio.Games
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
CameraUpdate();
|
CameraUpdate();
|
||||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
|
}
|
||||||
{
|
|
||||||
middleMonkey.DoScaledAnimationAsync("MiddleMonkeyBop", 0.4f);
|
public override void OnBeatPulse(double beat)
|
||||||
}
|
{
|
||||||
|
middleMonkey.DoScaledAnimationAsync("MiddleMonkeyBop", 0.4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayerMonkeyClap(bool big, bool barely)
|
public void PlayerMonkeyClap(bool big, bool barely)
|
||||||
|
|
@ -336,7 +336,6 @@ namespace HeavenStudio.Games
|
||||||
index++;
|
index++;
|
||||||
lastBeat += 2;
|
lastBeat += 2;
|
||||||
}
|
}
|
||||||
Debug.Log(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.Sort((x, y) => x.beat.CompareTo(y.beat));
|
actions.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||||
|
|
@ -410,6 +409,7 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
monkeyHandler.SpawnMonkey(beat, false, beat - 4 < persistBeat);
|
monkeyHandler.SpawnMonkey(beat, false, beat - 4 < persistBeat);
|
||||||
ClapRecursing(beat + 2);
|
ClapRecursing(beat + 2);
|
||||||
|
cameraWantAngle += degreePerMonkey;
|
||||||
}),
|
}),
|
||||||
new BeatAction.Action(beat - 1, delegate
|
new BeatAction.Action(beat - 1, delegate
|
||||||
{
|
{
|
||||||
|
|
@ -436,6 +436,7 @@ namespace HeavenStudio.Games
|
||||||
new BeatAction.Action(beat + i - 4, delegate
|
new BeatAction.Action(beat + i - 4, delegate
|
||||||
{
|
{
|
||||||
monkeyHandler.SpawnMonkey(beat + index, true, beat + index - 4 < persistBeat);
|
monkeyHandler.SpawnMonkey(beat + index, true, beat + index - 4 < persistBeat);
|
||||||
|
cameraWantAngle += degreePerMonkey;
|
||||||
}),
|
}),
|
||||||
new BeatAction.Action(beat + i - 1, delegate
|
new BeatAction.Action(beat + i - 1, delegate
|
||||||
{
|
{
|
||||||
|
|
@ -468,6 +469,7 @@ namespace HeavenStudio.Games
|
||||||
new BeatAction.Action(e.beat - 4, delegate
|
new BeatAction.Action(e.beat - 4, delegate
|
||||||
{
|
{
|
||||||
monkeyHandler.SpawnMonkey(e.beat, true, e.beat - 4 < persistBeat);
|
monkeyHandler.SpawnMonkey(e.beat, true, e.beat - 4 < persistBeat);
|
||||||
|
cameraWantAngle += degreePerMonkey;
|
||||||
}),
|
}),
|
||||||
new BeatAction.Action(e.beat - 1.5, delegate
|
new BeatAction.Action(e.beat - 1.5, delegate
|
||||||
{
|
{
|
||||||
|
|
@ -520,6 +522,8 @@ namespace HeavenStudio.Games
|
||||||
clappingEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
clappingEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||||
startClappingBeat = clappingEvents[0].beat;
|
startClappingBeat = clappingEvents[0].beat;
|
||||||
startAngle = clappingEvents[0]["min"] * degreePerMonkey;
|
startAngle = clappingEvents[0]["min"] * degreePerMonkey;
|
||||||
|
cameraWantAngle = startAngle;
|
||||||
|
cameraAngleDelay = startAngle;
|
||||||
overrideStartBeat = false;
|
overrideStartBeat = false;
|
||||||
}
|
}
|
||||||
lastAngle = startAngle;
|
lastAngle = startAngle;
|
||||||
|
|
@ -555,20 +559,8 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
if (e.beat - lastClappingBeat > 0)
|
if (e.beat - lastClappingBeat > 0)
|
||||||
{
|
{
|
||||||
cameraMovements.Add(new MonkeyCamera()
|
|
||||||
{
|
|
||||||
beat = lastClappingBeat,
|
|
||||||
length = (float)(e.beat - lastClappingBeat),
|
|
||||||
degreeTo = lastAngleToCheck + (float)((e.beat - lastClappingBeat) / 2) * degreePerMonkey + (angleToAdd / 2)
|
|
||||||
});
|
|
||||||
lastAngleToCheck += (float)((e.beat - lastClappingBeat) / 2) * degreePerMonkey;
|
lastAngleToCheck += (float)((e.beat - lastClappingBeat) / 2) * degreePerMonkey;
|
||||||
}
|
}
|
||||||
cameraMovements.Add(new MonkeyCamera()
|
|
||||||
{
|
|
||||||
beat = e.beat,
|
|
||||||
length = e.length,
|
|
||||||
degreeTo = lastAngleToCheck + angleToAdd
|
|
||||||
});
|
|
||||||
|
|
||||||
lastAngleToCheck += angleToAdd;
|
lastAngleToCheck += angleToAdd;
|
||||||
lastClappingBeat = e.beat + e.length;
|
lastClappingBeat = e.beat + e.length;
|
||||||
|
|
@ -576,33 +568,16 @@ namespace HeavenStudio.Games
|
||||||
startClappingBeat = lastClappingBeat;
|
startClappingBeat = lastClappingBeat;
|
||||||
startAngle = lastAngleToCheck;
|
startAngle = lastAngleToCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clappingEvents.Count > 0 || pinkClappingEvents.Count > 0)
|
|
||||||
{
|
|
||||||
cameraMovements.Add(new MonkeyCamera
|
|
||||||
{
|
|
||||||
beat = startClappingBeat,
|
|
||||||
degreeTo = startAngle + degreePerMonkey,
|
|
||||||
length = 2
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Debug.Log("Camera Movements Count: " + cameraMovements.Count);
|
|
||||||
foreach (var cameraMovement in cameraMovements)
|
|
||||||
{
|
|
||||||
Debug.Log("Beat: " + cameraMovement.beat + ", Length: " + cameraMovement.length + " , DegreeTo: " + cameraMovement.degreeTo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateCamera()
|
private void UpdateCamera()
|
||||||
{
|
{
|
||||||
lastAngle = cameraMovements[cameraIndex].degreeTo;
|
// lastAngle = cameraMovements[cameraIndex].degreeTo;
|
||||||
cameraIndex++;
|
// cameraIndex++;
|
||||||
if (cameraIndex + 1 < cameraMovements.Count && Conductor.instance.songPositionInBeats >= cameraMovements[cameraIndex].beat + cameraMovements[cameraIndex].length)
|
// if (cameraIndex + 1 < cameraMovements.Count && conductor.songPositionInBeats >= cameraMovements[cameraIndex].beat + cameraMovements[cameraIndex].length)
|
||||||
{
|
// {
|
||||||
UpdateCamera();
|
// UpdateCamera();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private double zoomOutStartBeat = -2;
|
private double zoomOutStartBeat = -2;
|
||||||
|
|
@ -612,31 +587,21 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
private void CameraUpdate()
|
private void CameraUpdate()
|
||||||
{
|
{
|
||||||
var cond = Conductor.instance;
|
if (conductor.isPlaying && !conductor.isPaused)
|
||||||
if (cond.isPlaying && !cond.isPaused && cameraMovements.Count > 0)
|
|
||||||
{
|
{
|
||||||
if (cameraIndex + 1 < cameraMovements.Count && cond.songPositionInBeats >= cameraMovements[cameraIndex].beat + cameraMovements[cameraIndex].length)
|
float degreesBehind = cameraWantAngle - 2 * degreePerMonkey;
|
||||||
|
float degreesBehindFast = cameraWantAngle - 3f * degreePerMonkey;
|
||||||
|
targetDelayRate = Mathf.Max((cameraAngleDelay - degreesBehindFast) / (degreesBehindFast - cameraWantAngle), 0) + 0.5f;
|
||||||
|
delayRate = Mathf.Lerp(delayRate, targetDelayRate, Time.deltaTime * (1f / conductor.pitchedSecPerBeat) * 0.5f);
|
||||||
|
if (cameraAngleDelay < degreesBehind)
|
||||||
{
|
{
|
||||||
UpdateCamera();
|
cameraAngleDelay += degreePerMonkey * Time.deltaTime * (1f / conductor.pitchedSecPerBeat) * delayRate;
|
||||||
|
cameraAngleDelay = Mathf.Min(cameraAngleDelay, cameraWantAngle);
|
||||||
}
|
}
|
||||||
|
cameraAnchor.localEulerAngles = new Vector3(0, 0, cameraAngleDelay);
|
||||||
float normalizedBeat = cond.GetPositionFromBeat(cameraMovements[cameraIndex].beat, cameraMovements[cameraIndex].length);
|
|
||||||
|
|
||||||
float newAngle;
|
|
||||||
|
|
||||||
if (normalizedBeat < 0)
|
|
||||||
{
|
|
||||||
newAngle = lastAngle;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newAngle = Mathf.LerpUnclamped(lastAngle, cameraMovements[cameraIndex].degreeTo, normalizedBeat);
|
|
||||||
}
|
|
||||||
|
|
||||||
cameraAnchor.localEulerAngles = new Vector3(0, 0, newAngle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float normalizedZoomBeat = cond.GetPositionFromBeat(zoomOutStartBeat, zoomIn ? zoomInBeatLength : zoomOutBeatLength);
|
float normalizedZoomBeat = conductor.GetPositionFromBeat(zoomOutStartBeat, zoomIn ? zoomInBeatLength : zoomOutBeatLength);
|
||||||
float newX = 0f;
|
float newX = 0f;
|
||||||
float newY = 0f;
|
float newY = 0f;
|
||||||
float newZ = 0f;
|
float newZ = 0f;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
||||||
public void Prepare(double prepareBeat, double inputBeat)
|
public void Prepare(double prepareBeat, double inputBeat)
|
||||||
{
|
{
|
||||||
anim.DoScaledAnimationAsync(isPink ? "PinkPrepare" + direction : "Prepare" + direction, 0);
|
anim.DoScaledAnimationAsync(isPink ? "PinkPrepare" + direction : "Prepare" + direction, 0);
|
||||||
inputEvent = game.ScheduleInput(prepareBeat, inputBeat - prepareBeat, InputType.STANDARD_DOWN, Just, Miss, Empty);
|
inputEvent = game.ScheduleInput(prepareBeat, inputBeat - prepareBeat, MonkeyWatch.InputAction_BasicPress, Just, Miss, Empty);
|
||||||
BeatAction.New(this, new List<BeatAction.Action>()
|
BeatAction.New(this, new List<BeatAction.Action>()
|
||||||
{
|
{
|
||||||
new BeatAction.Action(prepareBeat - 0.25, delegate
|
new BeatAction.Action(prepareBeat - 0.25, delegate
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,17 @@ namespace HeavenStudio
|
||||||
Debug.LogWarning("Game loader PcoMeatLoader failed!");
|
Debug.LogWarning("Game loader PcoMeatLoader failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Log("Running game loader RvlMonkeyWatchLoader");
|
||||||
|
game = RvlMonkeyWatchLoader.AddGame(eventCaller);
|
||||||
|
if (game != null)
|
||||||
|
{
|
||||||
|
eventCaller.minigames.Add(game.name, game);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Game loader RvlMonkeyWatchLoader failed!");
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Log("Running game loader AgbUpbeatLoader");
|
Debug.Log("Running game loader AgbUpbeatLoader");
|
||||||
game = AgbUpbeatLoader.AddGame(eventCaller);
|
game = AgbUpbeatLoader.AddGame(eventCaller);
|
||||||
if (game != null)
|
if (game != null)
|
||||||
|
|
|
||||||
|
|
@ -281,5 +281,11 @@ MonoBehaviour:
|
||||||
- Assets/Scripts/Games/Fireworks/Fireworks.cs
|
- Assets/Scripts/Games/Fireworks/Fireworks.cs
|
||||||
- Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs
|
- Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs
|
||||||
- Assets/Scripts/Games/WizardsWaltz/Wizard.cs
|
- Assets/Scripts/Games/WizardsWaltz/Wizard.cs
|
||||||
|
- Assets/Scripts/Games/MonkeyWatch/MonkeyWatch.cs
|
||||||
|
- Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs
|
||||||
|
- Assets/Scripts/Games/MonkeyWatch/WatchBackgroundHandler.cs
|
||||||
|
- Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs
|
||||||
|
- Assets/Scripts/Games/MonkeyWatch/BalloonHandler.cs
|
||||||
|
- Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs
|
||||||
PathsToSkipImportEvent: []
|
PathsToSkipImportEvent: []
|
||||||
PathsToIgnoreOverwriteSettingOnAttribute: []
|
PathsToIgnoreOverwriteSettingOnAttribute: []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue