Background Color Change Parity (#530)

* coin toss to see saw

* all done

* more stuffs
This commit is contained in:
Rapandrasmus 2023-08-12 05:30:03 +02:00 committed by GitHub
parent cd94ee3761
commit 74359d3e1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 655 additions and 318 deletions

View file

@ -203,6 +203,27 @@ namespace HeavenStudio.Games
UpdateColors();
}
private void PersistColors(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("builtToScaleDS", new string[] { "color" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat));
var lastEvent = allEventsBeforeBeat[^1];
UpdateMappingColors(lastEvent["object"], lastEvent["shooter"], lastEvent["bg"]);
}
}
public override void OnGameSwitch(double beat)
{
PersistColors(beat);
}
public override void OnPlay(double beat)
{
PersistColors(beat);
}
private void UpdateColors()
{
objectMaterial.SetColor("_Color", currentObjectColor);

View file

@ -1,5 +1,3 @@
using DG.Tweening;
using NaughtyBezierCurves;
using HeavenStudio.Util;
using System;
using System.Collections.Generic;
@ -24,51 +22,31 @@ namespace HeavenStudio.Games.Loaders
new Param("toggle", false, "Audience Reaction", "Enable Audience Reaction"),
}
},
new GameAction("fade background color", "Background Color")
{
function = delegate { var e = eventCaller.currentEntity;
CoinToss.instance.BackgroundColor(e.beat, e.length, e["colorStart"], e["colorEnd"], e["colorStartF"], e["colorEndF"], e["ease"]); },
resizable = true,
defaultLength = 4f,
parameters = new List<Param>()
{
new Param("colorStart", CoinToss.defaultBgColor, "BG Start Color", "The starting color in the fade"),
new Param("colorEnd", CoinToss.defaultBgColor, "BG End Color", "The ending color in the fade"),
new Param("colorStartF", CoinToss.defaultBgColor, "FG Start Color", "The starting color in the fade"),
new Param("colorEndF", CoinToss.defaultBgColor, "FG End Color", "The ending color in the fade"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
},
//left in for backwards-compatibility, but cannot be placed
new GameAction("set background color", "Set Background Color")
{
function = delegate { var e = eventCaller.currentEntity; CoinToss.instance.ChangeBackgroundColor(e["colorA"], 0f); CoinToss.instance.ChangeBackgroundColor(e["colorB"], 0f, true); },
function = delegate { var e = eventCaller.currentEntity; CoinToss.instance.BackgroundColor(e.beat, e.length, e["colorA"], e["colorA"], e["colorB"], e["colorB"], (int)Util.EasingFunction.Ease.Instant); },
defaultLength = 0.5f,
parameters = new List<Param>()
{
new Param("colorA", CoinToss.defaultBgColor, "Background Color", "The background color to change to"),
new Param("colorB", CoinToss.defaultFgColor, "Foreground Color", "The foreground color to change to")
}
},
new GameAction("fade background color", "Fade Background Color")
{
function = delegate { var e = eventCaller.currentEntity; CoinToss.instance.FadeBackgroundColor(e["colorA"], e["colorB"], e.length); CoinToss.instance.FadeBackgroundColor(e["colorC"], e["colorD"], e.length, true); },
resizable = true,
parameters = new List<Param>()
{
new Param("colorA", Color.white, "BG Start Color", "The starting color in the fade"),
new Param("colorB", CoinToss.defaultBgColor, "BG End Color", "The ending color in the fade"),
new Param("colorC", Color.white, "FG Start Color", "The starting color in the fade"),
new Param("colorD", CoinToss.defaultFgColor, "FG End Color", "The ending color in the fade")
}
},
//left in for backwards-compatibility, but cannot be placed
new GameAction("set foreground color", "")
{
function = delegate { var e = eventCaller.currentEntity; CoinToss.instance.ChangeBackgroundColor(e["colorA"], 0f, true); },
defaultLength = 0.5f,
parameters = new List<Param>
{
new Param("colorA", CoinToss.defaultFgColor, "Foreground Color", "The foreground color to change to")
},
hidden = true
},
new GameAction("fade foreground color", "")
{
function = delegate { var e = eventCaller.currentEntity; CoinToss.instance.FadeBackgroundColor(e["colorA"], e["colorB"], e.length, true); },
resizable = true,
parameters = new List<Param>()
{
new Param("colorA", Color.white, "Start Color", "The starting color in the fade"),
new Param("colorB", CoinToss.defaultFgColor, "End Color", "The ending color in the fade")
},
hidden = true
},
@ -119,9 +97,6 @@ namespace HeavenStudio.Games
public SpriteRenderer fg;
public SpriteRenderer bg;
Tween bgColorTween;
Tween fgColorTween;
[Header("Animators")]
public Animator handAnimator;
@ -143,16 +118,17 @@ namespace HeavenStudio.Games
isThrowing = false;
coin = null;
colorStart = defaultBgColor;
colorEnd = defaultBgColor;
colorStartF = defaultBgColor;
colorEndF = defaultBgColor;
BackgroundColorUpdate();
}
private void Update()
{
//nothing
}
private void LateUpdate()
{
//nothing
BackgroundColorUpdate();
}
public void TossCoin(double beat, int type, bool audienceReacting)
@ -230,37 +206,65 @@ namespace HeavenStudio.Games
coin.CanHit(false);
}
public void ChangeBackgroundColor(Color color, float beats, bool isFg = false)
{
var seconds = Conductor.instance.secPerBeat * beats;
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart; //obviously put to the default color of the game
private Color colorEnd;
private Color colorStartF; //obviously put to the default color of the game
private Color colorEndF;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
if(!isFg)
//call this in update
private void BackgroundColorUpdate()
{
if (bgColorTween != null)
bgColorTween.Kill(true);
} else
{
if (fgColorTween != null)
fgColorTween.Kill(true);
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
float newRF = func(colorStartF.r, colorEndF.r, normalizedBeat);
float newGF = func(colorStartF.g, colorEndF.g, normalizedBeat);
float newBF = func(colorStartF.b, colorEndF.b, normalizedBeat);
fg.color = new Color(newRF, newGF, newBF);
}
if (seconds == 0)
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetF, Color colorEndSetF, int ease)
{
if(!isFg) bg.color = color;
if (isFg) fg.color = color;
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorStartF = colorStartSetF;
colorEndF = colorEndSetF;
colorEase = (Util.EasingFunction.Ease)ease;
}
else
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
if(!isFg) bgColorTween = bg.DOColor(color, seconds);
if(isFg) fgColorTween = fg.DOColor(color, seconds);
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("coinToss", new string[] { "fade 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["colorStart"], lastEvent["colorEnd"], lastEvent["colorStartF"], lastEvent["colorEndF"], lastEvent["ease"]);
}
}
public void FadeBackgroundColor(Color start, Color end, float beats, bool isFg = false)
public override void OnPlay(double beat)
{
ChangeBackgroundColor(start, 0f, isFg);
ChangeBackgroundColor(end, beats, isFg);
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
}
}

View file

@ -56,15 +56,20 @@ namespace HeavenStudio.Games.Loaders
new Param("ease", EasingFunction.Ease.Linear, "Ease", "Which ease should the movement have?")
}
},
new GameAction("set background color", "Set Background Color")
new GameAction("set background color", "Background Color")
{
function = delegate {var e = eventCaller.currentEntity; DrummingPractice.instance.SetBackgroundColor(e["colorA"], e["colorB"], e["colorC"]); },
defaultLength = 0.5f,
function = delegate {var e = eventCaller.currentEntity;
DrummingPractice.instance.BackgroundColor(e.beat, e.length, e["colorAStart"], e["colorA"], e["colorBStart"], e["colorB"], e["colorC"], e["ease"]); },
defaultLength = 4f,
resizable = true,
parameters = new List<Param>()
{
new Param("colorA", new Color(43/255f, 207/255f, 51/255f), "Color A", "The top-most color of the background gradient"),
new Param("colorB", new Color(1, 1, 1), "Color B", "The bottom-most color of the background gradient"),
new Param("colorC", new Color(1, 247/255f, 0), "Streak Color", "The color of streaks that appear on a successful hit")
new Param("colorAStart", new Color(43/255f, 207/255f, 51/255f), "Color A Start", "The top-most color of the background gradient"),
new Param("colorA", new Color(43/255f, 207/255f, 51/255f), "Color A End", "The top-most color of the background gradient"),
new Param("colorBStart", new Color(1, 1, 1), "Color B Start", "The bottom-most color of the background gradient"),
new Param("colorB", new Color(1, 1, 1), "Color B End", "The bottom-most color of the background gradient"),
new Param("colorC", new Color(1, 247/255f, 0), "Streak Color", "The color of streaks that appear on a successful hit"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
}
},
@ -133,6 +138,7 @@ namespace HeavenStudio.Games
{
EventCaller.instance.CallEvent(changeMii, true);
}
PersistColor(beat);
}
private void Update()
@ -162,6 +168,8 @@ namespace HeavenStudio.Games
Color col = streak.color;
streak.color = new Color(col.r, col.g, col.b, Mathf.Lerp(col.a, 0, 3.5f * Time.deltaTime));
}
BackgroundColorUpdate();
}
public void NPCDrummersEnterOrExit(double beat, float length, bool exit, int ease)
@ -271,14 +279,65 @@ namespace HeavenStudio.Games
SetFaces(0);
}
public void SetBackgroundColor(Color col1, Color col2, Color col3)
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = new Color(43 / 255f, 207 / 255f, 51 / 255f); //obviously put to the default color of the game
private Color colorEnd = new Color(43 / 255f, 207 / 255f, 51 / 255f);
private Color colorStartB = Color.white; //obviously put to the default color of the game
private Color colorEndB = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
//call this in update
private void BackgroundColorUpdate()
{
backgroundGradient.color = col1;
background.color = col2;
foreach(SpriteRenderer streak in streaks)
{
streak.color = new Color(col3.r, col3.g, col3.b, streak.color.a);
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
backgroundGradient.color = new Color(newR, newG, newB);
float newRB = func(colorStartB.r, colorEndB.r, normalizedBeat);
float newGB = func(colorStartB.g, colorEndB.g, normalizedBeat);
float newBB = func(colorStartB.b, colorEndB.b, normalizedBeat);
background.color = new Color(newRB, newGB, newBB);
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetB, Color colorEndSetB, Color setStreak, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorStartB = colorStartSetB;
colorEndB = colorEndSetB;
colorEase = (Util.EasingFunction.Ease)ease;
foreach (SpriteRenderer streak in streaks)
{
streak.color = new Color(setStreak.r, setStreak.g, setStreak.b, streak.color.a);
}
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("drummingPractice", new string[] { "set 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["colorAStart"], lastEvent["colorA"], lastEvent["colorBStart"], lastEvent["colorB"], lastEvent["colorC"], lastEvent["ease"]);
}
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
public void Streak()

View file

@ -4,8 +4,6 @@ using UnityEngine;
using HeavenStudio.Util;
using DG.Tweening;
namespace HeavenStudio.Games.Loaders
{
using static Minigames;
@ -39,23 +37,23 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("color", "Background Color")
{
function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.FadeBackgroundColor(e["start"], e["end"], e.length, e["instant"]); },
function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.BackgroundColor(e.beat, e.length, e["start"], e["end"], e["ease"]); },
parameters = new List<Param>()
{
new Param("start", Color.white, "Start Color", "The color to start fading from."),
new Param("end", Color.white, "End Color", "The color to end the fade."),
new Param("instant", false, "Instant", "If checked, the background color will instantly change to the start color.")
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
},
resizable = true
},
new GameAction("colorGrad", "Gradient Color")
{
function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.FadeGradientColor(e["start"], e["end"], e.length, e["instant"]); },
function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.BackgroundColorGrad(e.beat, e.length, e["start"], e["end"], e["ease"]); },
parameters = new List<Param>()
{
new Param("start", Color.white, "Start Color", "The color to start fading from."),
new Param("end", Color.white, "End Color", "The color to end the fade."),
new Param("instant", false, "Instant", "If checked, the gradient color will instantly change to the start color.")
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
},
resizable = true
},
@ -134,11 +132,6 @@ namespace HeavenStudio.Games
[SerializeField] SpriteRenderer viewerCircle;
[SerializeField] SpriteRenderer playerShadow;
[SerializeField] SpriteRenderer handShadow;
Tween bgColorTween;
Tween bgGradientColorTween;
Tween viewerCircleColorTween;
Tween playerShadowColorTween;
Tween handShadowColorTween;
public Sprite[] peaSprites;
public Sprite[] peaHitSprites;
@ -148,10 +141,16 @@ namespace HeavenStudio.Games
instance = this;
}
private void Update()
{
BackgroundColorUpdate();
}
public override void OnGameSwitch(double beat)
{
base.OnGameSwitch(beat);
ForkLifterHand.CheckNextFlick();
PersistColor(beat);
}
@ -180,61 +179,86 @@ namespace HeavenStudio.Games
fo.SetActive(true);
}
public void ChangeBackgroundColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = Color.white; //obviously put to the default color of the game
private Color colorEnd = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
if (bgColorTween != null)
bgColorTween.Kill(true);
if (viewerCircleColorTween != null)
viewerCircleColorTween.Kill(true);
if (handShadowColorTween != null) handShadowColorTween.Kill(true);
private double colorStartBeatGrad = -1;
private float colorLengthGrad = 0f;
private Color colorStartGrad = Color.white; //obviously put to the default color of the game
private Color colorEndGrad = Color.white;
private Util.EasingFunction.Ease colorEaseGrad; //putting Util in case this game is using jukebox
if (seconds == 0)
//call this in update
private void BackgroundColorUpdate()
{
bg.color = color;
viewerCircle.color = color;
handShadow.color = color;
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
viewerCircle.color = new Color(newR, newG, newB);
handShadow.color = new Color(newR, newG, newB);
float normalizedBeatGrad = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeatGrad, colorLengthGrad));
var funcGrad = Util.EasingFunction.GetEasingFunction(colorEaseGrad);
float newRGrad = func(colorStartGrad.r, colorEndGrad.r, normalizedBeatGrad);
float newGGrad = func(colorStartGrad.g, colorEndGrad.g, normalizedBeatGrad);
float newBGrad = func(colorStartGrad.b, colorEndGrad.b, normalizedBeatGrad);
bgGradient.color = new Color(newRGrad, newGGrad, newBGrad);
playerShadow.color = new Color(newRGrad, newGGrad, newBGrad);
}
else
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{
bgColorTween = bg.DOColor(color, seconds);
handShadowColorTween = handShadow.DOColor(color, seconds);
viewerCircleColorTween = viewerCircle.DOColor(color, seconds);
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
}
public void BackgroundColorGrad(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{
colorStartBeatGrad = beat;
colorLengthGrad = length;
colorStartGrad = colorStartSet;
colorEndGrad = colorEndSet;
colorEaseGrad = (Util.EasingFunction.Ease)ease;
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("forkLifter", new string[] { "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["start"], lastEvent["end"], lastEvent["ease"]);
}
var allEventsBeforeBeatGrad = EventCaller.GetAllInGameManagerList("forkLifter", new string[] { "colorGrad" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeatGrad.Count > 0)
{
allEventsBeforeBeatGrad.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEventGrad = allEventsBeforeBeatGrad[^1];
BackgroundColorGrad(lastEventGrad.beat, lastEventGrad.length, lastEventGrad["start"], lastEventGrad["end"], lastEventGrad["ease"]);
}
}
public void FadeBackgroundColor(Color start, Color end, float beats, bool instant)
public override void OnPlay(double beat)
{
ChangeBackgroundColor(start, 0f);
if (!instant) ChangeBackgroundColor(end, beats);
}
public void ChangeGradientColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
if (bgGradientColorTween != null)
bgGradientColorTween.Kill(true);
if (playerShadowColorTween != null) playerShadowColorTween.Kill(true);
if (seconds == 0)
{
bgGradient.color = color;
playerShadow.color = color;
}
else
{
bgGradientColorTween = bgGradient.DOColor(color, seconds);
playerShadowColorTween = playerShadow.DOColor(color, seconds);
PersistColor(beat);
}
}
public void FadeGradientColor(Color start, Color end, float beats, bool instant)
{
ChangeGradientColor(start, 0f);
if (!instant) ChangeGradientColor(end, beats);
}
}
}

View file

@ -62,12 +62,18 @@ namespace HeavenStudio.Games.Loaders
new GameAction("bgcolor", "Background Color")
{
function = delegate {Kitties.instance.BackgroundColor(eventCaller.currentEntity["color"]); },
defaultLength = .5f,
function = delegate
{
var e = eventCaller.currentEntity;
Kitties.instance.BackgroundColor(e.beat, e.length, e["colorStart"], e["colorEnd"], e["ease"]);
},
defaultLength = 4,
resizable = true,
parameters = new List<Param>()
{
new Param("color", Kitties.defaultBGColor, "Change BG Color", "Changes background color"),
new Param("colorStart", Color.white, "Start Color"),
new Param("colorEnd", Color.white, "End Color"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
}
},
@ -94,18 +100,6 @@ namespace HeavenStudio.Games
public Vector3[] positions;
public float[] rotationAngles;
private static Color _defaultBGColor;
public static Color defaultBGColor
{
get
{
ColorUtility.TryParseHtmlString("#FFFFFF", out _defaultBGColor);
return _defaultBGColor;
}
}
public Color currentBGColor;
public enum SpawnType
{
Straight,
@ -124,7 +118,7 @@ namespace HeavenStudio.Games
// Update is called once per frame
void Update()
{
BackgroundColorUpdate();
}
public void Clap(bool isMice, bool isInverse, bool keepSpawned, double beat, int type)
@ -449,10 +443,55 @@ namespace HeavenStudio.Games
player.canClap = true;
}
public void BackgroundColor(Color color)
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = Color.white; //obviously put to the default color of the game
private Color colorEnd = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
//call this in update
private void BackgroundColorUpdate()
{
background.color = color;
currentBGColor = background.color;
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
background.color = new Color(newR, newG, newB);
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("kitties", new string[] { "bgcolor" }).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["colorStart"], lastEvent["colorEnd"], lastEvent["ease"]);
}
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
}
}

View file

@ -231,6 +231,17 @@ namespace HeavenStudio.Games
bachEvents = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "bach" });
}
private void PersistColors(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat));
var lastEvent = allEventsBeforeBeat[^1];
SetBackgroundColours(lastEvent["colorA"], lastEvent["colorB"], lastEvent["objColA"], lastEvent["objColB"], lastEvent["objColC"]);
}
}
private bool BachOnBeat(double beat)
{
return bachEvents.Find(x => beat >= x.beat && beat < x.beat + x.length) != null;
@ -238,11 +249,13 @@ namespace HeavenStudio.Games
public override void OnGameSwitch(double beat)
{
QueueSwitchBGs(beat);
PersistColors(beat);
}
public override void OnPlay(double beat)
{
QueueSwitchBGs(beat);
PersistColors(beat);
}
private void QueueSwitchBGs(double beat)

View file

@ -1,7 +1,6 @@
using HeavenStudio.Util;
using System;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using TMPro;
// using GhostlyGuy's Balls;
@ -122,12 +121,12 @@ namespace HeavenStudio.Games.Loaders
{
function = delegate {
var e = eventCaller.currentEntity;
OctopusMachine.instance.ChangeColor(e["color1"], e["color2"], e["octoColor"], e["squeezedColor"], e.length, e["bgInstant"]);
OctopusMachine.instance.BackgroundColor(e.beat, e.length, e["color1"], e["color2"], e["octoColor"], e["squeezedColor"], e["ease"]);
},
parameters = new List<Param>() {
new Param("color1", new Color(1f, 0.87f, 0.24f), "Background Start Color", "Set the beginning background color"),
new Param("color2", new Color(1f, 0.87f, 0.24f), "Background End Color", "Set the end background color"),
new Param("bgInstant", false, "Instant Background?", "Set the end background color instantly"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease"),
new Param("octoColor", new Color(0.97f, 0.235f, 0.54f), "Octopodes Color", "Set the octopodes' colors"),
new Param("squeezedColor", new Color(1f, 0f, 0f), "Squeezed Color", "Set the octopodes' colors when they're squeezed"),
},
@ -184,7 +183,6 @@ namespace HeavenStudio.Games
[Header("Variables")]
public bool hasMissed;
public int bopStatus = 0;
Tween bgColorTween;
int bopIterate = 0;
bool intervalStarted;
bool autoAction;
@ -218,7 +216,6 @@ namespace HeavenStudio.Games
private void Start()
{
bg.color = backgroundColor;
foreach (var octo in octopodes) octo.AnimationColor(0);
bopStatus = 0;
}
@ -239,6 +236,7 @@ namespace HeavenStudio.Games
private void Update()
{
BackgroundColorUpdate();
if (queuePrepare) {
foreach (var octo in octopodes) octo.queuePrepare = true;
if (Text.text is "Wrong! Try Again!" or "Good!") Text.text = "";
@ -328,27 +326,60 @@ namespace HeavenStudio.Games
}
}
public void FadeBackgroundColor(Color color, float beats)
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = new Color(1, 0.87f, 0.24f); //obviously put to the default color of the game
private Color colorEnd = new Color(1, 0.87f, 0.24f);
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
//call this in update
private void BackgroundColorUpdate()
{
var seconds = Conductor.instance.secPerBeat * beats;
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
if (bgColorTween != null)
bgColorTween.Kill(true);
var func = Util.EasingFunction.GetEasingFunction(colorEase);
if (seconds == 0) bg.color = color;
else bgColorTween = bg.DOColor(color, seconds);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
}
public void ChangeColor(Color bgStart, Color bgEnd, Color octoColor, Color octoSqueezedColor, float beats, bool bgInstant)
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color octoColor, Color octoSqueezeColor, int ease)
{
FadeBackgroundColor(bgStart, 0f);
if (!bgInstant) FadeBackgroundColor(bgEnd, beats);
backgroundColor = bgEnd;
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
octopodesColor = octoColor;
octopodesSqueezedColor = octoSqueezedColor;
octopodesSqueezedColor = octoSqueezeColor;
foreach (var octo in octopodes) octo.AnimationColor(octo.isSqueezed ? 1 : 0);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("octopusMachine", new string[] { "changeColor" }).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["color1"], lastEvent["color2"], lastEvent["octoColor"], lastEvent["squeezedColor"], lastEvent["ease"]);
}
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
public void OctopusModifiers(double beat, float oct1x, float oct2x, float oct3x, float oct1y, float oct2y, float oct3y, bool oct1, bool oct2, bool oct3)
{
octopodes[0].OctopusModifiers(oct1x, oct1y, oct1);

View file

@ -4,7 +4,6 @@ using UnityEngine;
using System;
using Starpelly;
using DG.Tweening;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Loaders
@ -65,26 +64,19 @@ namespace HeavenStudio.Games.Loaders
new Param("type", RhythmTweezers.NoPeekSignType.Full, "Sign Type", "Which sign will be used?")
}
},
new GameAction("fade background color", "Background Fade")
new GameAction("fade background color", "Background Color")
{
function = delegate
{
var e = eventCaller.currentEntity;
if (e["instant"])
{
RhythmTweezers.instance.ChangeBackgroundColor(e["colorA"], 0f);
}
else
{
RhythmTweezers.instance.FadeBackgroundColor(e["colorA"], e["colorB"], e.length);
}
RhythmTweezers.instance.BackgroundColor(e.beat, e.length, e["colorA"], e["colorB"], e["ease"]);
},
resizable = true,
parameters = new List<Param>()
{
new Param("colorA", Color.white, "Start Color", "The starting color in the fade"),
new Param("colorB", RhythmTweezers.defaultBgColor, "End Color", "The ending color in the fade"),
new Param("instant", false, "Instant", "Instantly change color to start color?")
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
},
new GameAction("altSmile", "Use Alt Smile")
@ -108,16 +100,6 @@ namespace HeavenStudio.Games.Loaders
},
hidden = true,
},
new GameAction("set background color", "Background Colour")
{
function = delegate { var e = eventCaller.currentEntity; RhythmTweezers.instance.ChangeBackgroundColor(e["colorA"], 0f); },
defaultLength = 0.5f,
parameters = new List<Param>()
{
new Param("colorA", RhythmTweezers.defaultBgColor, "Background Color", "The background color to change to")
},
hidden = true
},
},
new List<string>() {"agb", "repeat"},
"agbhair", "en",
@ -179,9 +161,7 @@ namespace HeavenStudio.Games
public Sprite onionSprite;
public Sprite potatoSprite;
Tween transitionTween;
bool transitioning = false;
Tween bgColorTween;
private static Color _defaultOnionColor;
public static Color defaultOnionColor
@ -231,6 +211,8 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
colorStart = defaultBgColor;
colorEnd = defaultBgColor;
if (crHandlerInstance != null && crHandlerInstance.queuedEvents.Count > 0)
{
foreach (var crEvent in crHandlerInstance.queuedEvents)
@ -262,6 +244,7 @@ namespace HeavenStudio.Games
public override void OnPlay(double beat)
{
crHandlerInstance = null;
PersistColor(beat);
}
private void OnDestroy()
@ -474,6 +457,8 @@ namespace HeavenStudio.Games
}
}
Tween transitionTween;
const float vegDupeOffset = 16.7f;
public void NextVegetable(double beat, int type, Color onionColor, Color potatoColor)
{
@ -517,27 +502,45 @@ namespace HeavenStudio.Games
VegetableDupe.color = newColor;
}
public void ChangeBackgroundColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = Color.white; //obviously put to the default color of the game
private Color colorEnd = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
if (bgColorTween != null)
bgColorTween.Kill(true);
//call this in update
private void BackgroundColorUpdate()
{
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
if (seconds == 0)
{
bg.color = color;
}
else
{
bgColorTween = bg.DOColor(color, seconds);
}
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
}
public void FadeBackgroundColor(Color start, Color end, float beats)
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{
ChangeBackgroundColor(start, 0f);
ChangeBackgroundColor(end, beats);
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("rhythmTweezers", new string[] { "fade 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["colorA"], lastEvent["colorB"], lastEvent["ease"]);
}
}
public static void PreNoPeeking(double beat, float length, int type)
@ -585,6 +588,8 @@ namespace HeavenStudio.Games
queuedPeeks.Clear();
}
}
BackgroundColorUpdate();
}
public override void OnGameSwitch(double beat)
@ -600,6 +605,7 @@ namespace HeavenStudio.Games
queuedIntervals.Clear();
}
}
PersistColor(beat);
}
private void ResetVegetable()

View file

@ -171,8 +171,8 @@ namespace HeavenStudio.Games
[NonSerialized] public bool sawShouldBop;
[NonSerialized] public bool seeShouldBop;
GameEvent bop = new GameEvent();
double bgColorStartBeat;
float bgColorLength;
double bgColorStartBeat = -1;
float bgColorLength = 0;
Util.EasingFunction.Ease lastEase;
Color colorFrom;
Color colorTo;
@ -195,13 +195,39 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
if (allJumpEvents.Count > 0) return;
GrabJumpEvents(Conductor.instance.songPositionInBeatsAsDouble);
colorFrom = defaultBGColor;
colorTo = defaultBGColor;
colorFrom2 = defaultBGColorBottom;
colorTo2 = defaultBGColorBottom;
}
public override void OnPlay(double beat)
{
GrabJumpEvents(beat);
PersistColor(beat);
PersistColors(beat);
}
public override void OnGameSwitch(double beat)
{
GrabJumpEvents(beat);
PersistColor(beat);
PersistColors(beat);
}
private void PersistColors(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("seeSaw", new string[] { "recolor" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat));
var e = allEventsBeforeBeat[^1];
ChangeMappingColor(e["fill"], e["outline"]);
}
else
{
ChangeMappingColor(Color.white, defaultOtherColor);
}
}
private void Start()
@ -271,14 +297,20 @@ namespace HeavenStudio.Games
}
}
private void Update()
private void PersistColor(double beat)
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("seeSaw", new string[] { "changeBgColor" }).FindAll(x => x.beat < beat);
if (allEventsBeforeBeat.Count > 0)
{
float normalizedBeat = cond.GetPositionFromBeat(bgColorStartBeat, bgColorLength);
if (normalizedBeat > 0 && normalizedBeat <= 1)
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allEventsBeforeBeat[^1];
ChangeColor(lastEvent.beat, lastEvent.length, lastEvent["colorFrom"], lastEvent["colorTo"], lastEvent["colorFrom2"], lastEvent["colorTo2"], lastEvent["ease"]);
}
}
private void BackgroundColorUpdate(Conductor cond)
{
float normalizedBeat = Mathf.Clamp01(cond.GetPositionFromBeat(bgColorStartBeat, bgColorLength));
Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction(lastEase);
float newColorR = func(colorFrom.r, colorTo.r, normalizedBeat);
float newColorG = func(colorFrom.g, colorTo.g, normalizedBeat);
@ -290,6 +322,13 @@ namespace HeavenStudio.Games
newColorB = func(colorFrom2.b, colorTo2.b, normalizedBeat);
bgLow.color = new Color(newColorR, newColorG, newColorB);
}
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
BackgroundColorUpdate(cond);
if (allJumpEvents.Count > 0 && !(see.dead || saw.dead))
{
if (currentJumpIndex < allJumpEvents.Count && currentJumpIndex >= 0)

View file

@ -2,7 +2,6 @@ using HeavenStudio.Util;
using System;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using HeavenStudio.Common;
namespace HeavenStudio.Games.Loaders
@ -58,14 +57,14 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("changeBG", "Change Background Color")
{
function = delegate {var e = eventCaller.currentEntity; SpaceDance.instance.FadeBackgroundColor(e["start"], e["end"], e.length, e["toggle"]); },
function = delegate {var e = eventCaller.currentEntity; SpaceDance.instance.BackgroundColor(e.beat, e.length, e["start"], e["end"], e["ease"]); },
defaultLength = 1f,
resizable = true,
parameters = new List<Param>()
{
new Param("start", SpaceDance.defaultBGColor, "Start Color", "The start color for the fade or the color that will be switched to if -instant- is ticked on."),
new Param("end", SpaceDance.defaultBGColor, "End Color", "The end color for the fade."),
new Param("toggle", false, "Instant", "Should the background instantly change color?")
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
},
new GameAction("bop", "Bop")
@ -135,7 +134,6 @@ namespace HeavenStudio.Games
Talk = 1,
Sniff = 2
}
Tween bgColorTween;
[SerializeField] SpriteRenderer bg;
[SerializeField] Animator shootingStarAnim;
public Animator DancerP;
@ -170,12 +168,15 @@ namespace HeavenStudio.Games
void Awake()
{
instance = this;
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
}
// Update is called once per frame
void Update()
{
var cond = Conductor.instance;
BackgroundColorUpdate();
if (cond.isPlaying && !cond.isPaused)
{
scroll.NormalizedX -= xBaseSpeed * xScrollMultiplier * Time.deltaTime;
@ -633,27 +634,55 @@ namespace HeavenStudio.Games
Gramps.DoScaledAnimationAsync("GrampsBop", 0.5f);
}
public void ChangeBackgroundColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart; //obviously put to the default color of the game
private Color colorEnd;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
if (bgColorTween != null)
bgColorTween.Kill(true);
if (seconds == 0)
//call this in update
private void BackgroundColorUpdate()
{
bg.color = color;
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
}
else
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{
bgColorTween = bg.DOColor(color, seconds);
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("spaceDance", new string[] { "changeBG" }).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["start"], lastEvent["end"], lastEvent["ease"]);
}
}
public void FadeBackgroundColor(Color start, Color end, float beats, bool instant)
public override void OnPlay(double beat)
{
ChangeBackgroundColor(start, 0f);
if (!instant) ChangeBackgroundColor(end, beats);
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
public void JustRight(PlayerActionEvent caller, float state)

View file

@ -1,7 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Loaders
@ -81,7 +80,7 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("changeBG", "Change Background Color")
{
function = delegate {var e = eventCaller.currentEntity; SpaceSoccer.instance.FadeBackgroundColor(e["start"], e["end"], e["startDots"], e["endDots"], e.length, e["toggle"]); },
function = delegate {var e = eventCaller.currentEntity; SpaceSoccer.instance.BackgroundColor(e.beat, e.length, e["start"], e["end"], e["startDots"], e["endDots"], e["ease"]); },
defaultLength = 1f,
resizable = true,
parameters = new List<Param>()
@ -90,7 +89,7 @@ namespace HeavenStudio.Games.Loaders
new Param("end", SpaceSoccer.defaultBGColor, "End Color", "The end color for the fade."),
new Param("startDots", Color.white, "Start Color (Dots)", "The start color for the fade or the color that will be switched to if -instant- is ticked on."),
new Param("endDots", Color.white, "End Color (Dots)", "The end color for the fade."),
new Param("toggle", false, "Instant", "Should the background instantly change color?")
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
},
new GameAction("scroll", "Scrolling Background")
@ -206,8 +205,6 @@ namespace HeavenStudio.Games
float yScrollMultiplier = 0.3f;
[SerializeField] private float xBaseSpeed = 1;
[SerializeField] private float yBaseSpeed = 1;
Tween bgColorTween;
Tween dotColorTween;
#region Space Kicker Position Easing
float easeBeat;
float easeLength;
@ -226,6 +223,8 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
}
new void OnDrawGizmos()
@ -243,6 +242,7 @@ namespace HeavenStudio.Games
private void Update()
{
var cond = Conductor.instance;
BackgroundColorUpdate();
backgroundSprite.NormalizedX -= xBaseSpeed * xScrollMultiplier * Time.deltaTime;
backgroundSprite.NormalizedY += yBaseSpeed * yScrollMultiplier * Time.deltaTime;
@ -324,6 +324,8 @@ namespace HeavenStudio.Games
Dispense(entity.beat, isOnGameSwitchBeat && !entity["toggle"], false, isOnGameSwitchBeat && entity["down"]);
break;
}
PersistColor(beat);
}
public SuperCurveObject.Path GetPath(string name)
@ -485,32 +487,60 @@ namespace HeavenStudio.Games
}, forcePlay:true);
}
public void ChangeBackgroundColor(Color color, Color dotColor, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart; //obviously put to the default color of the game
private Color colorEnd;
private Color colorStartDot = Color.white; //obviously put to the default color of the game
private Color colorEndDot = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
if (bgColorTween != null)
bgColorTween.Kill(true);
if (dotColorTween != null)
dotColorTween.Kill(true);
if (seconds == 0)
//call this in update
private void BackgroundColorUpdate()
{
bg.color = color;
bgImage.color = dotColor;
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
float newRDot = func(colorStartDot.r, colorEndDot.r, normalizedBeat);
float newGDot = func(colorStartDot.g, colorEndDot.g, normalizedBeat);
float newBDot = func(colorStartDot.b, colorEndDot.b, normalizedBeat);
bgImage.color = new Color(newRDot, newGDot, newBDot);
}
else
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartDotSet, Color colorEndDotSet, int ease)
{
bgColorTween = bg.DOColor(color, seconds);
dotColorTween = bgImage.DOColor(dotColor, seconds);
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorStartDot = colorEndDotSet;
colorEndDot = colorEndDotSet;
colorEase = (Util.EasingFunction.Ease)ease;
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("kitties", new string[] { "bgcolor" }).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["start"], lastEvent["end"], lastEvent["startDots"], lastEvent["endDots"], lastEvent["ease"]);
}
}
public void FadeBackgroundColor(Color start, Color end, Color startDot, Color endDot, float beats, bool instant)
public override void OnPlay(double beat)
{
ChangeBackgroundColor(start, startDot, 0f);
if (!instant) ChangeBackgroundColor(end, endDot, beats);
PersistColor(beat);
}
}
}

View file

@ -2,7 +2,6 @@ using HeavenStudio.Util;
using System;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using Jukebox;
namespace HeavenStudio.Games.Loaders
@ -60,27 +59,16 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("fade background", "Background Color")
{
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.FadeBackgroundColor(e["colorA"], e["colorB"], e.length, e["instant"]); },
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.BackgroundColor(e.beat, e.length, e["colorStart"], e["colorEnd"], e["ease"]); },
defaultLength = 4f,
resizable = true,
parameters = new List<Param>()
{
new Param("colorA", Color.white, "Start Color", "The starting color of the fade."),
new Param("colorB", Tambourine.defaultBGColor, "End Color", "The ending color of the fade."),
new Param("instant", false, "Instant", "Instantly set the color of the background to the start color?")
new Param("colorStart", Color.white, "Start Color", "The starting color of the fade."),
new Param("colorEnd", Tambourine.defaultBGColor, "End Color", "The ending color of the fade."),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
},
//backwards-compatibility
new GameAction("set background color", "Background Color")
{
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.ChangeBackgroundColor(e["colorA"], 0f); },
defaultLength = 0.5f,
parameters = new List<Param>()
{
new Param("colorA", Tambourine.defaultBGColor, "Background Color", "The background color to change to.")
},
hidden = true
},
},
new List<string>() {"rvl", "repeat"},
"rvldrum", "en",
@ -119,8 +107,6 @@ namespace HeavenStudio.Games
bool frogPresent;
bool monkeyGoBop;
bool handsGoBop;
Tween bgColorTween;
public GameEvent bop = new GameEvent();
public enum WhoBops
@ -140,10 +126,13 @@ namespace HeavenStudio.Games
frogAnimator.Play("FrogExited", 0, 0);
handsAnimator.Play("Idle", 0, 0);
monkeyAnimator.Play("MonkeyIdle", 0, 0);
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
}
void Update()
{
BackgroundColorUpdate();
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
{
if (monkeyGoBop)
@ -228,6 +217,7 @@ namespace HeavenStudio.Games
}
queuedIntervals.Clear();
}
PersistColor(beat);
}
private struct QueuedInterval
@ -454,27 +444,50 @@ namespace HeavenStudio.Games
}
}
public void ChangeBackgroundColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = Color.white; //obviously put to the default color of the game
private Color colorEnd = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
if (bgColorTween != null)
bgColorTween.Kill(true);
if (seconds == 0)
//call this in update
private void BackgroundColorUpdate()
{
bg.color = color;
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
}
else
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{
bgColorTween = bg.DOColor(color, seconds);
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("tambourine", new string[] { "fade background" }).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["colorStart"], lastEvent["colorEnd"], lastEvent["ease"]);
}
}
public void FadeBackgroundColor(Color start, Color end, float beats, bool instant)
public override void OnPlay(double beat)
{
ChangeBackgroundColor(start, 0f);
if (!instant) ChangeBackgroundColor(end, beats);
PersistColor(beat);
}
public void SummonFrog()

View file

@ -2,7 +2,6 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using DG.Tweening;
using Jukebox;
namespace HeavenStudio.Games.Loaders
@ -81,14 +80,14 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("changeBG", "Change Background Color")
{
function = delegate {var e = eventCaller.currentEntity; TossBoys.instance.FadeBackgroundColor(e["start"], e["end"], e.length, e["toggle"]); },
function = delegate {var e = eventCaller.currentEntity; TossBoys.instance.BackgroundColor(e.beat, e.length, e["start"], e["end"], e["ease"]); },
defaultLength = 1f,
resizable = true,
parameters = new List<Param>()
{
new Param("start", TossBoys.defaultBGColor, "Start Color", "The start color for the fade or the color that will be switched to if -instant- is ticked on."),
new Param("end", TossBoys.defaultBGColor, "End Color", "The end color for the fade."),
new Param("toggle", false, "Instant", "Should the background instantly change color?")
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
},
},
@ -140,7 +139,6 @@ namespace HeavenStudio.Games
[SerializeField] SpriteRenderer bg;
[Header("Properties")]
Tween bgColorTween;
[SerializeField] SuperCurveObject.Path[] ballPaths;
WhichTossKid lastReceiver = WhichTossKid.None;
WhichTossKid currentReceiver = WhichTossKid.None;
@ -155,6 +153,8 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
}
new void OnDrawGizmos()
@ -184,6 +184,7 @@ namespace HeavenStudio.Games
private void Update()
{
var cond = Conductor.instance;
BackgroundColorUpdate();
if (cond.isPlaying && !cond.isPaused)
{
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
@ -208,27 +209,55 @@ namespace HeavenStudio.Games
}
}
public void ChangeBackgroundColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
private double colorStartBeat = -1;
private float colorLength = 0f;
private Color colorStart = Color.white; //obviously put to the default color of the game
private Color colorEnd = Color.white;
private Util.EasingFunction.Ease colorEase; //putting Util in case this game is using jukebox
if (bgColorTween != null)
bgColorTween.Kill(true);
if (seconds == 0)
//call this in update
private void BackgroundColorUpdate()
{
bg.color = color;
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
var func = Util.EasingFunction.GetEasingFunction(colorEase);
float newR = func(colorStart.r, colorEnd.r, normalizedBeat);
float newG = func(colorStart.g, colorEnd.g, normalizedBeat);
float newB = func(colorStart.b, colorEnd.b, normalizedBeat);
bg.color = new Color(newR, newG, newB);
}
else
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
{
bgColorTween = bg.DOColor(color, seconds);
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistColor(double beat)
{
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("tossBoys", new string[] { "changeBG" }).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["start"], lastEvent["end"], lastEvent["ease"]);
}
}
public void FadeBackgroundColor(Color start, Color end, float beats, bool instant)
public override void OnPlay(double beat)
{
ChangeBackgroundColor(start, 0f);
if (!instant) ChangeBackgroundColor(end, beats);
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
#region Bop