From 37ebc3c9af2f315f5a3b7c564b9d04acc86169bc Mon Sep 17 00:00:00 2001 From: wookywok <62037083+wookywok@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:16:16 -0500 Subject: [PATCH] Color Persistence for Nightly Games (#881) Added color persistence between game switches for most of the games in the nightly that needed it: - Basketball Girls - Bouncy Road - Chameleon - Clap Trap - Fillbots - Frog Princess - Sick Beats - Sumo Brothers Slot Monster has none yet, because its color changing is a little different lol --- .../Games/BasketballGirls/BasketballGirls.cs | 22 +++++++++++++ Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs | 14 ++++++++ Assets/Scripts/Games/Chameleon/Chameleon.cs | 20 ++++++++++++ Assets/Scripts/Games/ClapTrap/ClapTrap.cs | 30 +++++++++++++++++ Assets/Scripts/Games/Fillbots/Fillbots.cs | 32 +++++++++++++++++++ .../Games/FrogPrincess/FrogPrincess.cs | 21 ++++++++++++ Assets/Scripts/Games/SickBeats/SickBeats.cs | 12 +++++++ .../Games/SumoBrothers/SumoBrothers.cs | 15 +++++++++ 8 files changed, 166 insertions(+) diff --git a/Assets/Scripts/Games/BasketballGirls/BasketballGirls.cs b/Assets/Scripts/Games/BasketballGirls/BasketballGirls.cs index 07c9da304..4e0d1d768 100644 --- a/Assets/Scripts/Games/BasketballGirls/BasketballGirls.cs +++ b/Assets/Scripts/Games/BasketballGirls/BasketballGirls.cs @@ -241,6 +241,28 @@ namespace HeavenStudio.Games { BGPlane.color = bgColorEase.GetColor(); } + + //call this in OnPlay(double beat) and OnGameSwitch(double beat) + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("basketballGirls", new string[] { "background appearance" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBGStart"], lastEvent["colorBGEnd"], lastEvent["ease"]); + } + } + + public override void OnPlay(double beat) + { + PersistColor(beat); + } + + public override void OnGameSwitch(double beat) + { + PersistColor(beat); + } } } diff --git a/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs b/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs index 0631c6fff..2af35787d 100644 --- a/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs +++ b/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs @@ -190,6 +190,9 @@ namespace HeavenStudio.Games public override void OnGameSwitch(double beat) { + + PersistColor(beat); + double gameStartBeat = beat, gameEndBeat = double.MaxValue; var firstEnd = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame", "end" }).Find(x => x.beat > gameStartBeat); gameEndBeat = firstEnd?.beat ?? gameEndBeat; @@ -371,5 +374,16 @@ namespace HeavenStudio.Games BGHigh.color = colorEases[0].GetColor(); BGLow.color = colorEases[1].GetColor(); } + + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("bouncyRoad", new string[] { "background appearance" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBG1Start"], lastEvent["colorBG1End"], lastEvent["colorBG2Start"], lastEvent["colorBG2End"], lastEvent["ease"]); + } + } } } diff --git a/Assets/Scripts/Games/Chameleon/Chameleon.cs b/Assets/Scripts/Games/Chameleon/Chameleon.cs index c7c4d4a16..b6a28c5ff 100644 --- a/Assets/Scripts/Games/Chameleon/Chameleon.cs +++ b/Assets/Scripts/Games/Chameleon/Chameleon.cs @@ -150,6 +150,8 @@ namespace HeavenStudio.Games public override void OnPlay(double beat) { + PersistColor(beat); + if (queuedFlys.Count > 0) queuedFlys.Clear(); foreach (var evt in scheduledInputs) { @@ -296,5 +298,23 @@ namespace HeavenStudio.Games if (GameManager.instance.currentGame == "chameleon") Chameleon.instance.Crown.SetActive(enableCrown); } + + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("chameleon", new string[] { "background appearance" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBG1Start"], lastEvent["colorBG1End"], lastEvent["colorBG2Start"], lastEvent["colorBG2End"], lastEvent["ease"]); + } + } + + public override void OnGameSwitch(double beat) + { + PersistColor(beat); + } + + } } \ No newline at end of file diff --git a/Assets/Scripts/Games/ClapTrap/ClapTrap.cs b/Assets/Scripts/Games/ClapTrap/ClapTrap.cs index c04405e46..c70a87f7d 100644 --- a/Assets/Scripts/Games/ClapTrap/ClapTrap.cs +++ b/Assets/Scripts/Games/ClapTrap/ClapTrap.cs @@ -380,5 +380,35 @@ namespace HeavenStudio.Games spotlightMaterial.SetColor("_ColorDelta", bottomSpot); } + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("clapTrap", new string[] { "background color" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + BackgroundColor(lastEvent["bgColor"], lastEvent["bgColorEnd"], lastEvent["ease"], lastEvent.length, lastEvent.beat); + } + + var allEventsBeforeBeatHand = EventCaller.GetAllInGameManagerList("clapTrap", new string[] { "hand color" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeatHand.Count > 0) + { + allEventsBeforeBeatHand.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEventHand = allEventsBeforeBeatHand[^1]; + ChangeHandColor(lastEventHand["left"], lastEventHand["right"], lastEventHand["spotlightBottom"], lastEventHand["spotlightTop"], lastEventHand["spotlightGlow"]); + } + } + + public override void OnGameSwitch(double beat) + { + PersistColor(beat); + } + + public override void OnPlay(double beat) + { + PersistColor(beat); + } + + } } \ No newline at end of file diff --git a/Assets/Scripts/Games/Fillbots/Fillbots.cs b/Assets/Scripts/Games/Fillbots/Fillbots.cs index 70ee5fe14..618579ec5 100644 --- a/Assets/Scripts/Games/Fillbots/Fillbots.cs +++ b/Assets/Scripts/Games/Fillbots/Fillbots.cs @@ -238,6 +238,7 @@ namespace HeavenStudio.Games public override void OnPlay(double beat) { + PersistColor(beat); if (queuedBots.Count > 0) queuedBots.Clear(); foreach (var evt in scheduledInputs) { @@ -548,6 +549,37 @@ namespace HeavenStudio.Games metersFuel[i].color = colorEases[i+1].GetColor(); } } + + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("fillbots", new string[] { "background appearance" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBGStart"], lastEvent["colorBGEnd"], lastEvent["colorMetersStart"], + lastEvent["colorMeter1Start"], lastEvent["colorMeter2Start"], + lastEvent["colorMeter3Start"], lastEvent["colorMeter4Start"], + lastEvent["colorMeter5Start"], lastEvent["colorMeter6Start"], + lastEvent["colorMetersEnd"], lastEvent["colorMeter1End"], + lastEvent["colorMeter2End"], lastEvent["colorMeter3End"], + lastEvent["colorMeter4End"], lastEvent["colorMeter5End"], lastEvent["colorMeter6End"], + lastEvent["separate"], lastEvent["ease"]); + } + + var allEventsBeforeBeatObj = EventCaller.GetAllInGameManagerList("fillbots", new string[] { "object appearance" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeatObj.Count > 0) + { + allEventsBeforeBeatObj.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEventObj = allEventsBeforeBeatObj[^1]; + ObjectColorSet(lastEventObj["colorFuel"], lastEventObj["colorLampOff"], lastEventObj["colorLampOn"], lastEventObj["colorImpact"], lastEventObj["colorFiller"], lastEventObj["colorConveyor"]); + } + } + + public override void OnGameSwitch(double beat) + { + PersistColor(beat); + } } } diff --git a/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs b/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs index 73f897052..fcd29e395 100644 --- a/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs +++ b/Assets/Scripts/Games/FrogPrincess/FrogPrincess.cs @@ -379,5 +379,26 @@ namespace HeavenStudio.Games { BGPlane.color = bgColorEase.GetColor(); } + + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("frogPrincess", new string[] { "background appearance" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + BackgroundColorSet(lastEvent.beat, lastEvent.length, lastEvent["colorBGStart"], lastEvent["colorBGEnd"], lastEvent["ease"]); + } + } + + public override void OnPlay(double beat) + { + PersistColor(beat); + } + + public override void OnGameSwitch(double beat) + { + PersistColor(beat); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/SickBeats/SickBeats.cs b/Assets/Scripts/Games/SickBeats/SickBeats.cs index 119812549..3a17f2431 100644 --- a/Assets/Scripts/Games/SickBeats/SickBeats.cs +++ b/Assets/Scripts/Games/SickBeats/SickBeats.cs @@ -237,6 +237,7 @@ namespace HeavenStudio.Games [NonSerialized] public double gameEndBeat = double.MaxValue; public override void OnGameSwitch(double beat) { + PersistColor(beat); var entities = GameManager.instance.Beatmap.Entities; // find out when the next game switch (or remix end) happens RiqEntity firstEnd = entities.Find(c => (c.datamodel.StartsWith("gameManager/switchGame") || c.datamodel.Equals("gameManager/end")) && c.beat > beat); @@ -465,5 +466,16 @@ namespace HeavenStudio.Games return UnityEngine.Random.Range(0, 4); } + + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("sickBeats", new string[] { "virusColor" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + UpdateMaterialColor(lastEvent["colorVirus1"], lastEvent["colorVirus2"], lastEvent["colorVirus3"], lastEvent["colorVirus4"]); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs b/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs index fc0c6cd2d..bf89cee95 100644 --- a/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs +++ b/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs @@ -443,6 +443,8 @@ namespace HeavenStudio.Games public override void OnGameSwitch(double beat) // stole code from manzai { FindNextGameswitchBeat(beat); + PersistColor(beat); + foreach(var entity in GameManager.instance.Beatmap.Entities) { @@ -464,6 +466,8 @@ namespace HeavenStudio.Games { bgTypeNext = BGType.None; FindNextGameswitchBeat(beat); + PersistColor(beat); + } private void FindNextGameswitchBeat(double beat) @@ -1306,6 +1310,17 @@ namespace HeavenStudio.Games } } + private void PersistColor(double beat) + { + var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("sumoBrothers", new string[] { "background color" }).FindAll(x => x.beat < beat); + if (allEventsBeforeBeat.Count > 0) + { + allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case + var lastEvent = allEventsBeforeBeat[^1]; + BackgroundColor(lastEvent.beat, lastEvent.length, lastEvent["colorFrom"], lastEvent["colorTo"], lastEvent["colorFrom2"], lastEvent["colorTo2"], lastEvent["ease"]); + } + } + } }