Merge pull request #737 from RHeavenStudio/cherry-pick-release_1_patches-98666636148341ee25e6a0db2b290cb6c9ed8423

ColorEase Class
This commit is contained in:
minenice55 2024-03-04 03:51:58 +00:00 committed by GitHub
commit eb1ea48202
15 changed files with 229 additions and 500 deletions

View File

@ -59,12 +59,6 @@ namespace HeavenStudio.Games.Loaders
new Param("valA", new EntityTypes.Integer(3, 8, 3), "Lions", "Set how many lions there will be. The player is always the rightmost lion.")
}
},
// This is still here for backwards-compatibility but is hidden in the editor
new GameAction("prepare_alt", "")
{
function = delegate { ClappyTrio.instance.Prepare(3); },
hidden = true
},
},
new List<string>() {"agb", "normal"},
"agbclap", "en",

View File

@ -76,27 +76,10 @@ namespace HeavenStudio.Games
public static CoinToss instance { get; set; }
private static Color _defaultBgColor;
public static Color defaultBgColor
{
get
{
ColorUtility.TryParseHtmlString("#F7F742", out _defaultBgColor);
return _defaultBgColor;
}
}
public static Color defaultBgColor = new Color(0.97f, 0.97f, 0.26f);
public static Color defaultFgColor = new Color(1f, 1f, 0.51f);
private static Color _defaultFgColor;
public static Color defaultFgColor
{
get
{
ColorUtility.TryParseHtmlString("#FFFF83", out _defaultFgColor);
return _defaultFgColor;
}
}
[Header("Backgrounds")]
public SpriteRenderer fg;
public SpriteRenderer bg;
@ -123,10 +106,6 @@ namespace HeavenStudio.Games
coin = null;
colorStart = defaultBgColor;
colorEnd = defaultBgColor;
colorStartF = defaultBgColor;
colorEndF = defaultBgColor;
BackgroundColorUpdate();
}
@ -142,6 +121,9 @@ namespace HeavenStudio.Games
}
}
public override void OnPlay(double beat) => PersistColor(beat);
public override void OnGameSwitch(double beat) => PersistColor(beat);
public void TossCoin(double beat, int type, bool audienceReacting)
{
if (coin != null) return;
@ -176,21 +158,6 @@ namespace HeavenStudio.Games
//coin.perfectOnly = true;
}
public void TossCoin(double beat)
{
if (coin != null) return;
//Play sound and animations
SoundByte.PlayOneShotGame("coinToss/throw");
handAnimator.Play("Throw", 0, 0);
//Game state says the hand is throwing the coin
isThrowing = true;
this.audienceReacting = false;
coin = ScheduleInput(beat, 6f, InputAction_BasicPress, CatchSuccess, CatchMiss, CatchEmpty);
//coin.perfectOnly = true;
}
public void CatchSuccess(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("coinToss/catch");
@ -217,43 +184,20 @@ namespace HeavenStudio.Games
coin.CanHit(false);
}
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
private ColorEase bgColorEase = new(defaultBgColor);
private ColorEase bgFColorEase = new(defaultBgColor);
//call this in update
// call this in update
private void BackgroundColorUpdate()
{
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);
bg.color = bgColorEase.GetColor();
fg.color = bgFColorEase.GetColor();
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetF, Color colorEndSetF, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorStartF = colorStartSetF;
colorEndF = colorEndSetF;
colorEase = (Util.EasingFunction.Ease)ease;
bgColorEase = new ColorEase(beat, length, colorStartSet, colorEndSet, ease);
bgFColorEase = new ColorEase(beat, length, colorStartSetF, colorEndSetF, ease);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
@ -268,14 +212,5 @@ namespace HeavenStudio.Games
}
}
public override void OnPlay(double beat)
{
PersistColor(beat);
}
public override void OnGameSwitch(double beat)
{
PersistColor(beat);
}
}
}

View File

@ -67,10 +67,10 @@ namespace HeavenStudio.Games.Loaders
resizable = true,
parameters = new List<Param>()
{
new Param("colorAStart", new Color(43/255f, 207/255f, 51/255f), "Color A Start", "Set the top-most color of the background gradient at the start of the event."),
new Param("colorA", new Color(43/255f, 207/255f, 51/255f), "Color A End", "Set the top-most color of the background gradient at the end of the event."),
new Param("colorBStart", new Color(1, 1, 1), "Color B Start", "Set the bottom-most color of the background gradient at the start of the event."),
new Param("colorB", new Color(1, 1, 1), "Color B End", "Set the bottom-most color of the background gradient at the end of the event."),
new Param("colorAStart", new Color(43/255f, 207/255f, 51/255f), "Top Color Start", "Set the top-most color of the background gradient at the start of the event."),
new Param("colorA", new Color(43/255f, 207/255f, 51/255f), "Top Color End", "Set the top-most color of the background gradient at the end of the event."),
new Param("colorBStart", new Color(1, 1, 1), "Bottom Color Start", "Set the bottom-most color of the background gradient at the start of the event."),
new Param("colorB", new Color(1, 1, 1), "Bottom Color End", "Set the bottom-most color of the background gradient at the end of the event."),
new Param("colorC", new Color(1, 247/255f, 0), "Streak Color", "Set the color of the streaks that appear upon a successful hit."),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
}
@ -280,46 +280,22 @@ namespace HeavenStudio.Games
SetFaces(0);
}
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
private ColorEase tColorEase = new(new Color(43 / 255f, 207 / 255f, 51 / 255f)); // top gradient color
private ColorEase bColorEase = new(Color.white); // bottom gradient color
//call this in update
private void BackgroundColorUpdate()
{
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);
backgroundGradient.color = tColorEase.GetColor();
background.color = bColorEase.GetColor();
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetB, Color colorEndSetB, Color setStreak, int ease)
public void BackgroundColor(double beat, float length, Color colorStartSetT, Color colorEndSetT, 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;
tColorEase = new ColorEase(beat, length, colorStartSetT, colorEndSetT, ease);
bColorEase = new ColorEase(beat, length, colorStartSetB, colorEndSetB, ease);
foreach (SpriteRenderer streak in streaks)
{
foreach (SpriteRenderer streak in streaks) {
streak.color = new Color(setStreak.r, setStreak.g, setStreak.b, streak.color.a);
}
}

View File

@ -178,61 +178,48 @@ namespace HeavenStudio.Games
fo.SetActive(true);
}
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
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
private ColorEase bgColorEase = new();
private ColorEase gradColorEase = new();
//call this in update
private void BackgroundColorUpdate()
{
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength));
bg.color =
viewerCircle.color =
handShadow.color = bgColorEase.GetColor();
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 = funcGrad(colorStartGrad.r, colorEndGrad.r, normalizedBeatGrad);
float newGGrad = funcGrad(colorStartGrad.g, colorEndGrad.g, normalizedBeatGrad);
float newBGrad = funcGrad(colorStartGrad.b, colorEndGrad.b, normalizedBeatGrad);
bgGradient.color = new Color(newRGrad, newGGrad, newBGrad);
playerShadow.color = new Color(newRGrad, newGGrad, newBGrad);
bgGradient.color =
playerShadow.color = gradColorEase.GetColor();
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
bgColorEase = new ColorEase(beat, length, startColor, endColor, ease);
}
public void BackgroundColorGrad(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
public void BackgroundColorGrad(double beat, float length, Color startColor, Color endColor, int ease)
{
colorStartBeatGrad = beat;
colorLengthGrad = length;
colorStartGrad = colorStartSet;
colorEndGrad = colorEndSet;
colorEaseGrad = (Util.EasingFunction.Ease)ease;
gradColorEase = new ColorEase(beat, length, startColor, endColor, 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"]);
}
}
}
}

View File

@ -117,7 +117,6 @@ namespace HeavenStudio.Games.Loaders
},
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
KarateMan.CreateItemSFX(e.beat, e["type"], e["mute"]);
},
defaultLength = 2,
@ -137,7 +136,6 @@ namespace HeavenStudio.Games.Loaders
},
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
if (!e["mute"]) KarateMan.CreateBulbSFX(e.beat, e["type"], e["sfx"], e["throwSfx"]);
},
defaultLength = 2,
@ -167,7 +165,6 @@ namespace HeavenStudio.Games.Loaders
},
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
KarateMan.KickSFX();
},
defaultLength = 4f,
@ -196,7 +193,6 @@ namespace HeavenStudio.Games.Loaders
},
inactiveFunction = delegate {
var e = eventCaller.currentEntity;
KarateMan.QueueCue(e);
KarateMan.ComboSFX();
},
defaultLength = 4,
@ -526,7 +522,7 @@ namespace HeavenStudio.Games
}
#endregion
static List<RiqEntity> queuedCues = new();
// static List<RiqEntity> queuedCues = new();
public static bool IsComboEnable = true; //only stops Out combo inputs, this basically makes combo contextual
// public static bool IsKickEnable = true; //same as above, except with kick inputs
public bool IsNoriActive { get { return Nori.MaxNori > 0; } }
@ -567,15 +563,7 @@ namespace HeavenStudio.Games
static double wordClearTime = double.MinValue;
[Header("Backgrounds")]
// 0 = bg color, 1 = shadow color, 2 = filter color
private double[] colorStartBeats = new double[3] {
-1,
-1,
-1
};
private float[] colorLengths = new float[3];
private Color[] colorStarts, colorEnds = new Color[3];
private Util.EasingFunction.Ease[] colorEases = new Util.EasingFunction.Ease[3];
private ColorEase[] colorEases = new ColorEase[3];
public int currentBgEffect = (int)BackgroundFXType.None;
@ -704,11 +692,10 @@ namespace HeavenStudio.Games
bgEffectAnimator = BGEffect.GetComponent<Animator>();
bgEffectSpriteRenderer = BGEffect.GetComponent<SpriteRenderer>();
colorEnds =
colorStarts = new Color[] {
BackgroundColors[0],
TintColor(BackgroundColors[0]),
new Color(),
colorEases = new ColorEase[] {
new(BackgroundColors[0]),
new(TintColor(BackgroundColors[0])),
new(new Color()),
};
}
@ -717,38 +704,31 @@ namespace HeavenStudio.Games
Update();
}
public override void OnPlay(double beat) => OnGameSwitch(beat);
public override void OnGameSwitch(double beat)
{
EntityPreCheck(beat);
var entities = gameManager.Beatmap.Entities.FindAll(e => (e.datamodel is "karateman/hit" or "karateman/bulb" or "karateman/kick" or "karateman/combo") && e.beat < beat && e.beat + 1 > beat);
// queued objects
if (queuedCues.Count > 0)
foreach (var e in entities)
{
foreach (var e in queuedCues)
{
switch (e.datamodel)
{
case "karateman/hit": CreateItem(e.beat, e["type"], e["type2"]); break;
case "karateman/bulb": CreateBulbSpecial(e.beat, e["type"], e["colorA"], e["type2"], e["sfx"], e["hitSfx"]); break;
case "karateman/kick": Kick(e.beat, e["toggle"], e["shouldGlow"], e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"], e["woodColor"], e["hoopColor"]); break;
case "karateman/combo": Combo(e.beat, e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"]); break;
default: Debug.LogError($"Karate Man has failed to cue an object with datamodel {e.datamodel} at beat {e.beat}"); break;
}
switch (e.datamodel) {
case "karateman/hit": CreateItem(e.beat, e["type"], e["type2"]); break;
case "karateman/bulb": CreateBulbSpecial(e.beat, e["type"], e["colorA"], e["type2"], e["sfx"], e["hitSfx"]); break;
case "karateman/kick": Kick(e.beat, e["toggle"], e["shouldGlow"], e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"], e["woodColor"], e["hoopColor"]); break;
case "karateman/combo": Combo(e.beat, e["type"], e["pitchVoice"], e["forcePitch"], e["cutOut"], e["disableVoice"]); break;
default: Debug.LogError($"Karate Man has failed to cue an object with datamodel {e.datamodel} at beat {e.beat}"); break;
}
queuedCues.Clear();
}
EntityPreCheck(beat);
}
public override void OnPlay(double beat)
{
queuedCues.Clear();
EntityPreCheck(beat);
}
public override void OnStop(double beat) => EntityPreCheck(beat);
void EntityPreCheck(double beat)
{
if (gameManager == null) return;
List<RiqEntity> prevEntities = GameManager.instance.Beatmap.Entities.FindAll(c => c.datamodel.Split(0) == "karateman");
List<RiqEntity> prevEntities = gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split(0) == "karateman");
RiqEntity voice = prevEntities.FindLast(c => c.beat < beat && c.datamodel == "karateman/warnings");
if (wordClearTime > beat && wordStartTime < beat && voice != null)
@ -769,11 +749,6 @@ namespace HeavenStudio.Games
bg["textureType"], bg["autoColor"], bg["startTexture"], bg["endTexture"]
);
}
else
{
var c = new Color();
BackgroundColor(0, 0, 0, 0, c, c, (int)Util.EasingFunction.Ease.Instant, 0, c, c, 0, true, c, c);
}
if (obj != null)
{
@ -806,10 +781,10 @@ namespace HeavenStudio.Games
{
var songPos = conductor.songPositionInBeatsAsDouble;
if (conductor != null && !conductor.isPlaying)
{
EntityPreCheck(songPos);
}
// if (conductor != null && !conductor.isPlaying)
// {
// EntityPreCheck(songPos);
// }
switch (currentBgEffect)
{
@ -875,7 +850,6 @@ namespace HeavenStudio.Games
}
if (!Conductor.instance.NotStopped())
{
if (queuedCues.Count > 0) queuedCues.Clear();
startCamSpecial = double.MinValue;
wantsReturn = double.MinValue;
cameraReturnLength = 0f;
@ -931,11 +905,6 @@ namespace HeavenStudio.Games
return $"Word0{(type < (int)HitThree.HitThreeAlt ? type : type - 1)}";
}
public static void QueueCue(RiqEntity entity)
{
queuedCues.Add(entity);
}
public static void CreateItemSFX(double beat, int type, bool muteSound = false)
{
if (!muteSound) SoundByte.PlayOneShotGame($"karateman/{(beat % 1.0 == 0.5 ? $"offbeatObject" : "object")}Out", forcePlay: true);
@ -1108,28 +1077,15 @@ namespace HeavenStudio.Games
{
currentBgEffect = fxType;
for (int i = 0; i < colorStarts.Length; i++)
{
colorStartBeats[i] = beat;
colorLengths[i] = length;
colorEases[i] = (Util.EasingFunction.Ease)colorEaseSet;
}
bool preset = presetBG != (int)BackgroundType.Custom;
bool tinted = shadowType == (int)ShadowType.Tinted;
Color bgColorStart = preset ? BGPlane.color : colorStart;
colorStarts = new Color[] {
bgColorStart,
tinted ? TintColor(bgColorStart) : shadowStart,
autoColor ? TintColor(bgColorStart): filterStart,
};
Color bgColorEnd = preset ? BackgroundColors[presetBG] : colorEnd;
colorEnds = new Color[] {
bgColorEnd,
tinted ? TintColor(bgColorEnd) : shadowEnd,
autoColor ? TintColor(bgColorEnd) : filterEnd,
colorEases = new ColorEase[] {
new(beat, length, bgColorStart, bgColorEnd, colorEaseSet),
new(beat, length, (tinted ? TintColor(bgColorStart) : shadowStart), (tinted ? TintColor(bgColorEnd) : shadowEnd), colorEaseSet),
new(beat, length, (autoColor ? TintColor(bgColorStart): filterStart), (autoColor ? TintColor(bgColorEnd) : filterEnd), colorEaseSet),
};
for (int i = 0; i < BGTextures.Length; i++)
@ -1150,18 +1106,8 @@ namespace HeavenStudio.Games
for (int i = 0; i < spriteRenderers.Length; i++)
{
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeats[i], colorLengths[i]));
if (double.IsNaN(normalizedBeat)) normalizedBeat = 0; // happens if the game is stopped onto the first beat
var func = Util.EasingFunction.GetEasingFunction(colorEases[i]);
float[] color = new float[3] {
func(colorStarts[i].r, colorEnds[i].r, normalizedBeat),
func(colorStarts[i].g, colorEnds[i].g, normalizedBeat),
func(colorStarts[i].b, colorEnds[i].b, normalizedBeat),
};
foreach (var renderer in spriteRenderers[i])
{
renderer.color = new Color(color[0], color[1], color[2]);
foreach (var renderer in spriteRenderers[i]) {
renderer.color = colorEases[i].GetColor();
}
}
}

View File

@ -479,33 +479,17 @@ namespace HeavenStudio.Games
player.canClap = true;
}
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
private ColorEase bgColorEase = new(Color.white);
//call this in update
private void BackgroundColorUpdate()
{
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);
background.color = bgColorEase.GetColor();
}
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;
bgColorEase = new ColorEase(beat, length, colorStartSet, colorEndSet, ease);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)

View File

@ -428,6 +428,67 @@ namespace HeavenStudio.Games
#endregion
#region Color
// truly a moment in history. documentation in heaven studio :)
public class ColorEase
{
/// <summary>
/// Gets the eased color from the variables inside a <c>ColorEase</c>. <br/>
/// Use this in <c>Update()</c>.
/// </summary>
/// <returns>A new color, based on <c>startColor</c> and <c>endColor</c>.</returns>
public Color GetColor() => MakeNewColor(startBeat, length, startColor, endColor, easeFunc);
public static Color MakeNewColor(double beat, float length, Color start, Color end, Util.EasingFunction.Function func)
{
if (length != 0) {
float normalizedBeat = length == 0 ? 1 : Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(beat, length));
float newR = func(start.r, end.r, normalizedBeat);
float newG = func(start.g, end.g, normalizedBeat);
float newB = func(start.b, end.b, normalizedBeat);
return new Color(newR, newG, newB);
} else {
return end;
}
}
public double startBeat = 0;
public float length = 0;
public Color startColor, endColor = Color.white;
public Util.EasingFunction.Ease ease = Util.EasingFunction.Ease.Instant;
public readonly Util.EasingFunction.Function easeFunc;
/// <summary>
/// The constructor to use when constructing a ColorEase from a block.
/// </summary>
/// <param name="startBeat">The start beat of the ease.</param>
/// <param name="length">The length of the ease.</param>
/// <param name="startColor">The beginning color of the ease.</param>
/// <param name="endColor">The end color of the ease.</param>
/// <param name="ease">
/// The ease to use to transition between <paramref name="startColor"/> and <paramref name="endColor"/>.<br/>
/// Should be derived from <c>Util.EasingFunction.Ease</c>,
/// </param>
public ColorEase(double startBeat, float length, Color startColor, Color endColor, int ease) {
this.startBeat = startBeat;
this.length = length;
(this.startColor, this.endColor) = (startColor, endColor);
this.ease = (Util.EasingFunction.Ease)ease;
this.easeFunc = Util.EasingFunction.GetEasingFunction(this.ease);
}
/// <summary>
/// The constructor to use when initializing the ColorEase variable.
/// </summary>
/// <param name="defaultColor">The default color to initialize with.</param>
public ColorEase(Color? defaultColor = null) {
startColor = endColor = defaultColor ?? Color.white;
easeFunc = Util.EasingFunction.Instant;
}
}
#endregion
private void OnDestroy()
{
foreach (var evt in scheduledInputs)

View File

@ -3,6 +3,7 @@ using UnityEngine;
using DG.Tweening;
using HeavenStudio.Util;
using Jukebox;
namespace HeavenStudio.Games.Loaders
{
@ -10,6 +11,18 @@ namespace HeavenStudio.Games.Loaders
public static class AgbUpbeatLoader
{
public static Minigame AddGame(EventCaller eventCaller) {
RiqEntity BackgroundUpdater(string datamodel, RiqEntity e)
{
if (datamodel == "mrUpbeat/changeBG" && e.dynamicData.ContainsKey("toggle"))
{
e.dynamicData.Add("ease", (int)(e["toggle"] ? Util.EasingFunction.Ease.Instant : Util.EasingFunction.Ease.Linear));
e.dynamicData.Remove("toggle");
return e;
}
return null;
}
RiqBeatmap.OnUpdateEntity += BackgroundUpdater;
return new Minigame("mrUpbeat", "Mr. Upbeat", "E0E0E0", false, false, new List<GameAction>()
{
new GameAction("prepare", "Prepare")
@ -49,14 +62,14 @@ namespace HeavenStudio.Games.Loaders
{
function = delegate {
var e = eventCaller.currentEntity;
MrUpbeat.instance.FadeBackgroundColor(e["start"], e["end"], e.length, e["toggle"]);
MrUpbeat.instance.BackgroundColor(e.beat, e.length, e["start"], e["end"], e["ease"]);
},
resizable = true,
parameters = new List<Param>()
{
new Param("start", new Color(0.878f, 0.878f, 0.878f), "Start Color", "Set the color at the start of the event."),
new Param("end", new Color(0.878f, 0.878f, 0.878f), "End Color", "Set the color at the start of the event."),
new Param("toggle", false, "Instant", "Toggle if the background should jump to it's end state.")
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the background.")
}
},
new GameAction("upbeatColors", "Upbeat Colors")
@ -151,13 +164,14 @@ namespace HeavenStudio.Games
[SerializeField] SpriteRenderer[] shadowSr;
[Header("Properties")]
private Tween bgColorTween;
public int stepIterate = 0;
private static double startSteppingBeat = double.MaxValue;
private static double startBlippingBeat = double.MaxValue;
private bool stopStepping;
public bool stopBlipping;
private ColorEase bgColorEase = new(new Color(0.878f, 0.878f, 0.878f));
public static MrUpbeat instance;
private void Awake()
@ -209,9 +223,9 @@ namespace HeavenStudio.Games
public void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused) {
var songPos = cond.songPositionInBeatsAsDouble;
bg.color = bgColorEase.GetColor();
if (conductor.isPlaying && !conductor.isPaused) {
var songPos = conductor.songPositionInBeatsAsDouble;
if (songPos >= startSteppingBeat - 2) {
man.canStep = true;
@ -273,7 +287,6 @@ namespace HeavenStudio.Games
private void RecursiveStepping(double beat)
{
if (stopStepping) {
stopStepping = false;
return;
}
@ -327,25 +340,9 @@ namespace HeavenStudio.Games
man.Fall();
}
public void ChangeBackgroundColor(Color color1, Color color2, float beats)
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
{
var seconds = Conductor.instance.secPerBeat * beats;
if (bgColorTween != null)
bgColorTween.Kill(true);
if (seconds == 0) {
bg.color = color2;
} else {
bg.color = color1;
bgColorTween = bg.DOColor(color2, seconds);
}
}
public void FadeBackgroundColor(Color start, Color end, float beats, bool instant)
{
ChangeBackgroundColor(start, end, 0f);
if (!instant) ChangeBackgroundColor(start, end, beats);
bgColorEase = new(beat, length, startColor, endColor, ease);
}
public void UpbeatColors(Color blipColor, bool setShadow, Color shadowColor)

View File

@ -184,15 +184,7 @@ namespace HeavenStudio.Games
}
}
private static Color _defaultBgColor;
public static Color defaultBgColor
{
get
{
ColorUtility.TryParseHtmlString("#A14FA1", out _defaultBgColor);
return _defaultBgColor;
}
}
public static Color defaultBgColor = new(0.631f, 0.31f, 0.631f);
public static RhythmTweezers instance { get; set; }
private static CallAndResponseHandler crHandlerInstance;
@ -241,8 +233,6 @@ 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)
@ -537,45 +527,22 @@ namespace HeavenStudio.Games
VegetableDupe.color = newColor;
}
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
private ColorEase bgColorEase = new(defaultBgColor);
//call this in update
private void BackgroundColorUpdate()
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
{
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);
}
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;
bgColorEase = new(beat, length, startColor, endColor, ease);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistBlocks(double beat)
{
var allEventsBeforeBeat = GameManager.instance.Beatmap.Entities.FindAll(x => x.datamodel.Split('/')[0] == "rhythmTweezers" && x.beat < beat);
var allColorEventsBeforeBeat = allEventsBeforeBeat.FindAll(x => x.datamodel == "rhythmTweezers/fade background color");
if (allColorEventsBeforeBeat.Count > 0)
var lastColorEvent = allEventsBeforeBeat.FindLast(x => x.datamodel == "rhythmTweezers/fade background color");
if (lastColorEvent != null)
{
allColorEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
var lastEvent = allColorEventsBeforeBeat[^1];
BackgroundColor(lastEvent.beat, lastEvent.length, lastEvent["colorA"], lastEvent["colorB"], lastEvent["ease"]);
var e = lastColorEvent;
BackgroundColor(e.beat, e.length, e["colorA"], e["colorB"], e["ease"]);
}
var allAltFaceEventsBeforeBeat = allEventsBeforeBeat.FindAll(x => x.datamodel == "rhythmTweezers/altSmile");
VegetableAnimator.SetBool("UseAltSmile", allAltFaceEventsBeforeBeat.Count % 2 == 1);
@ -627,7 +594,7 @@ namespace HeavenStudio.Games
}
}
BackgroundColorUpdate();
bg.color = bgColorEase.GetColor();
}
public override void OnGameSwitch(double beat)

View File

@ -42,7 +42,7 @@ namespace HeavenStudio.Games.Loaders
new Param("5JJ", new EntityTypes.Integer(-1, 24, 0), "B3 String (JJ)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("6JJ", new EntityTypes.Integer(-1, 24, 0), "E4 String (JJ)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("sampleJJ", Rockers.PremadeSamples.None, "Premade Sample (JJ)", "Set if this riff should use a premade sample."),
new Param("pitchSampleJJ", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pitchSampleJJ", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("gcJJ", false, "Glee Club Guitar (JJ)", "Toggle if JJ should use the same guitar as in the Glee Club guitar lessons in DS."),
new Param("1S", new EntityTypes.Integer(-1, 24, 0), "E2 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("2S", new EntityTypes.Integer(-1, 24, 0), "A2 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
@ -51,7 +51,7 @@ namespace HeavenStudio.Games.Loaders
new Param("5S", new EntityTypes.Integer(-1, 24, 0), "B3 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("6S", new EntityTypes.Integer(-1, 24, 0), "E4 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("sampleS", Rockers.PremadeSamples.None, "Premade Sample (Soshi)", "Set if this riff should use a premade sample."),
new Param("pitchSampleS", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pitchSampleS", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("gcS", false, "Glee Club Guitar (Soshi)", "Toggle if Soshi should use the same guitar as in the Glee Club guitar lessons in DS.")
},
},
@ -126,21 +126,21 @@ namespace HeavenStudio.Games.Loaders
{
new Param("moveCamera", true, "Move Camera", "Toggle if the camera should move to the middle."),
new Param("JJ1", Rockers.PremadeSamples.ChordG5, "Premade Sample 1 (JJ)", "Set the sample to use for the 1st riff."),
new Param("pJJ1", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 1 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pJJ1", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 1 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("JJ2", Rockers.PremadeSamples.ChordG5, "Premade Sample 2 (JJ)", "Set the sample to use for the 2nd riff."),
new Param("pJJ2", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 2 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pJJ2", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 2 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("JJ3", Rockers.PremadeSamples.ChordG5, "Premade Sample 3 (JJ)", "Set the sample to use for the 3rd riff."),
new Param("pJJ3", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 3 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pJJ3", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 3 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("JJ4", Rockers.PremadeSamples.ChordA, "Premade Sample 4 (JJ)", "Set the sample to use for the final riff."),
new Param("pJJ4", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 4 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pJJ4", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 4 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("S1", Rockers.PremadeSamples.ChordG, "Premade Sample 1 (Soshi)", "Set the sample to use for the 1st riff."),
new Param("pS1", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 1 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pS1", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 1 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("S2", Rockers.PremadeSamples.ChordG, "Premade Sample 2 (Soshi)", "Set the sample to use for the 2nd riff."),
new Param("pS2", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 2 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pS2", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 2 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("S3", Rockers.PremadeSamples.ChordG, "Premade Sample 3 (Soshi)", "Set the sample to use for the 3rd riff."),
new Param("pS3", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 3 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pS3", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 3 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("S4", Rockers.PremadeSamples.ChordA, "Premade Sample 4 (Soshi)", "Set the sample to use for the final riff."),
new Param("pS4", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 4 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pS4", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 4 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
}
},
new GameAction("lastOne", "Last One!")
@ -172,17 +172,17 @@ namespace HeavenStudio.Games.Loaders
{
new Param("moveCamera", true, "Move Camera", "Toggle if the camera should move to the middle."),
new Param("JJ1", Rockers.PremadeSamples.ChordAsus4, "Premade Sample 1 (JJ)", "Set the sample to use for the 1st riff."),
new Param("pJJ1", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 1 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pJJ1", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 1 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("JJ2", Rockers.PremadeSamples.ChordAsus4, "Premade Sample 2 (JJ)", "Set the sample to use for the 2nd riff."),
new Param("pJJ2", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 2 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pJJ2", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 2 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("JJ3", Rockers.PremadeSamples.ChordAsus4, "Premade Sample 3 (JJ)", "Set the sample to use for the final riff."),
new Param("pJJ3", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 3 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pJJ3", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 3 (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("S1", Rockers.PremadeSamples.ChordDmaj9, "Premade Sample 1 (Soshi)", "Set the sample to use for the 1st riff."),
new Param("pS1", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 1 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pS1", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 1 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("S2", Rockers.PremadeSamples.ChordDmaj9, "Premade Sample 2 (Soshi)", "Set the sample to use for the 2nd riff."),
new Param("pS2", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 2 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pS2", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 2 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("S3", Rockers.PremadeSamples.ChordDmaj9, "Premade Sample 3 (Soshi)", "Set the sample to use for the final riff."),
new Param("pS3", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones 3 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pS3", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones 3 (Soshi)", "Set how many semitones the premade sample should be pitched up."),
}
},
new GameAction("count", "Count")
@ -247,7 +247,7 @@ namespace HeavenStudio.Games.Loaders
new Param("5JJ", new EntityTypes.Integer(-1, 24, 0), "B3 String (JJ)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("6JJ", new EntityTypes.Integer(-1, 24, 0), "E4 String (JJ)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("sampleJJ", Rockers.PremadeSamples.None, "Premade Sample (JJ)", "Set if this riff should use a premade sample."),
new Param("pitchSampleJJ", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pitchSampleJJ", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("gcJJ", false, "Glee Club Guitar (JJ)", "Toggle if JJ should use the same guitar as in the Glee Club guitar lessons in DS."),
new Param("1S", new EntityTypes.Integer(-1, 24, 0), "E2 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("2S", new EntityTypes.Integer(-1, 24, 0), "A2 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
@ -256,7 +256,7 @@ namespace HeavenStudio.Games.Loaders
new Param("5S", new EntityTypes.Integer(-1, 24, 0), "B3 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("6S", new EntityTypes.Integer(-1, 24, 0), "E4 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("sampleS", Rockers.PremadeSamples.None, "Premade Sample (Soshi)", "Set if this riff should use a premade sample."),
new Param("pitchSampleS", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pitchSampleS", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("gcS", false, "Glee Club Guitar (Soshi)", "Toggle if Soshi should use the same guitar as in the Glee Club guitar lessons in DS.")
}
},
@ -272,7 +272,7 @@ namespace HeavenStudio.Games.Loaders
new Param("5JJ", new EntityTypes.Integer(-1, 24, 0), "B3 String (JJ)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("6JJ", new EntityTypes.Integer(-1, 24, 0), "E4 String (JJ)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("sampleJJ", Rockers.PremadeSamples.None, "Premade Sample (JJ)", "Set if this riff should use a premade sample."),
new Param("pitchSampleJJ", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("pitchSampleJJ", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones (JJ)", "Set how many semitones the premade sample should be pitched up."),
new Param("gcJJ", false, "Glee Club Guitar (JJ)", "Toggle if JJ should use the same guitar as in the Glee Club guitar lessons in DS."),
new Param("1S", new EntityTypes.Integer(-1, 24, 0), "E2 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("2S", new EntityTypes.Integer(-1, 24, 0), "A2 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
@ -281,7 +281,7 @@ namespace HeavenStudio.Games.Loaders
new Param("5S", new EntityTypes.Integer(-1, 24, 0), "B3 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("6S", new EntityTypes.Integer(-1, 24, 0), "E4 String (Soshi)", "Set how many semitones up the current string will be pitched. If this is left at -1, this string will not play."),
new Param("sampleS", Rockers.PremadeSamples.None, "Premade Sample (Soshi)", "Set if this riff should use a premade sample."),
new Param("pitchSampleS", new EntityTypes.Integer(-24, 24, 0), "Sample Semtiones (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("pitchSampleS", new EntityTypes.Integer(-24, 24, 0), "Sample Semitones (Soshi)", "Set how many semitones the premade sample should be pitched up."),
new Param("gcS", false, "Glee Club Guitar (Soshi)", "Toggle if Soshi should use the same guitar as in the Glee Club guitar lessons in DS.")
}
},

View File

@ -114,15 +114,7 @@ namespace HeavenStudio.Games
// using Scripts_SpaceDance;
public class SpaceDance : Minigame
{
private static Color _defaultBGColor;
public static Color defaultBGColor
{
get
{
ColorUtility.TryParseHtmlString("#0029D6", out _defaultBGColor);
return _defaultBGColor;
}
}
public static Color defaultBGColor = new(0f, 0.161f, 0.839f);
public enum WhoSpeaks
{
Dancers = 0,
@ -223,8 +215,6 @@ namespace HeavenStudio.Games
void Awake()
{
instance = this;
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
SetupBopRegion("spaceDance", "bop", "auto");
}
@ -244,7 +234,7 @@ namespace HeavenStudio.Games
void Update()
{
var cond = Conductor.instance;
BackgroundColorUpdate();
bg.color = bgColorEase.GetColor();
if (cond.isPlaying && !cond.isPaused)
{
scroll.NormalizedX -= xBaseSpeed * xScrollMultiplier * Time.deltaTime;
@ -690,33 +680,11 @@ namespace HeavenStudio.Games
Gramps.DoScaledAnimationAsync("GrampsBop", 0.5f);
}
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
private ColorEase bgColorEase = new();
//call this in update
private void BackgroundColorUpdate()
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
{
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);
}
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;
bgColorEase = new(beat, length, startColor, endColor, ease);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)

View File

@ -190,15 +190,8 @@ namespace HeavenStudio.Games
Enter = 0,
Exit = 1
}
private static Color _defaultBGColor;
public static Color defaultBGColor
{
get
{
ColorUtility.TryParseHtmlString("#FF7D27", out _defaultBGColor);
return _defaultBGColor;
}
}
public static Color defaultBGColor = new(1f, 0.49f, 0.153f);
[Header("Components")]
[SerializeField] private GameObject kickerPrefab;
[SerializeField] private GameObject ballRef;
@ -239,8 +232,6 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
var allHighKickToeEvents = EventCaller.GetAllInGameManagerList("spaceSoccer", new string[] { "high kick-toe!" });
foreach (var e in allHighKickToeEvents)
{
@ -262,12 +253,12 @@ namespace HeavenStudio.Games
private void Update()
{
var cond = Conductor.instance;
BackgroundColorUpdate();
bg.color = bgColorEase.GetColor();
bgImage.color = dotColorEase.GetColor();
backgroundSprite.NormalizedX -= xBaseSpeed * xScrollMultiplier * Time.deltaTime;
backgroundSprite.NormalizedY += yBaseSpeed * yScrollMultiplier * Time.deltaTime;
float normalizedEaseBeat = cond.GetPositionFromBeat(easeBeat, easeLength);
float normalizedEaseBeat = conductor.GetPositionFromBeat(easeBeat, easeLength);
if (normalizedEaseBeat <= 1 && normalizedEaseBeat > 0)
{
EasingFunction.Function func = EasingFunction.GetEasingFunction(lastEase);
@ -277,7 +268,7 @@ namespace HeavenStudio.Games
UpdateKickersPositions(newPosX, newPosY, newPosZ);
}
float normalizedPBeat = cond.GetPositionFromBeat(easeBeatP, easeLengthP);
float normalizedPBeat = conductor.GetPositionFromBeat(easeBeatP, easeLengthP);
if (normalizedPBeat <= 1 && normalizedPBeat > 0)
{
EasingFunction.Function func = EasingFunction.GetEasingFunction(lastEaseP);
@ -567,43 +558,18 @@ namespace HeavenStudio.Games
}
}
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
private ColorEase bgColorEase = new(defaultBGColor);
private ColorEase dotColorEase = new(Color.white);
//call this in update
private void BackgroundColorUpdate()
{
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);
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartDotSet, Color colorEndDotSet, int ease)
public void BackgroundColor(double beat, float length, Color startColorBG, Color endColorBG, Color startColorDot, Color endColorDot, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorStartDot = colorStartDotSet;
colorEndDot = colorEndDotSet;
colorEase = (Util.EasingFunction.Ease)ease;
bgColorEase = new(beat, length, startColorBG, endColorBG, ease);
dotColorEase = new(beat, length, startColorDot, endColorDot, ease);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)

View File

@ -83,15 +83,7 @@ namespace HeavenStudio.Games
{
public class Tambourine : Minigame
{
private static Color _defaultBGColor;
public static Color defaultBGColor
{
get
{
ColorUtility.TryParseHtmlString("#388cd0", out _defaultBGColor);
return _defaultBGColor;
}
}
public static Color defaultBGColor = new Color(0.22f, 0.55f, 0.82f);
[Header("Components")]
[SerializeField] Animator handsAnimator;
@ -155,8 +147,6 @@ namespace HeavenStudio.Games
frogAnimator.Play("FrogExited", 0, 0);
handsAnimator.Play("Idle", 0, 0);
monkeyAnimator.Play("MonkeyIdle", 0, 0);
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
}
void Update()
@ -475,33 +465,17 @@ namespace HeavenStudio.Games
}
}
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
private ColorEase bgColorEase = new();
//call this in update
private void BackgroundColorUpdate()
{
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);
bg.color = bgColorEase.GetColor();
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
bgColorEase = new(beat, length, startColor, endColor, ease);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)

View File

@ -114,15 +114,7 @@ namespace HeavenStudio.Games
public class TossBoys : Minigame
{
private static Color _defaultBGColor;
public static Color defaultBGColor
{
get
{
ColorUtility.TryParseHtmlString("#62FDBB", out _defaultBGColor);
return _defaultBGColor;
}
}
public static Color defaultBGColor = new Color(0.38f, 0.99f, 0.73f);
public enum KidChoice
{
Akachan = 0,
@ -235,8 +227,6 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
colorStart = defaultBGColor;
colorEnd = defaultBGColor;
SetupBopRegion("tossBoys", "bop", "auto");
SetPassBallEvents();
}
@ -294,33 +284,17 @@ namespace HeavenStudio.Games
}
}
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
private ColorEase bgColorEase = new(defaultBGColor);
//call this in update
private void BackgroundColorUpdate()
{
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);
bg.color = bgColorEase.GetColor();
}
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
{
colorStartBeat = beat;
colorLength = length;
colorStart = colorStartSet;
colorEnd = colorEndSet;
colorEase = (Util.EasingFunction.Ease)ease;
bgColorEase = new(beat, length, startColor, endColor, ease);
}
//call this in OnPlay(double beat) and OnGameSwitch(double beat)

View File

@ -35,14 +35,14 @@ namespace HeavenStudio.Util
}
}
public static MultiSound Play(Sound[] snds, bool game = true, bool forcePlay = false)
public static MultiSound Play(Sound[] sounds, bool game = true, bool forcePlay = false)
{
return Play(snds.ToList(), game, forcePlay);
return Play(sounds.ToList(), game, forcePlay);
}
public static MultiSound Play(List<Sound> sounds, bool game = true, bool forcePlay = false)
{
if (Conductor.instance == null || sounds.Count <= 0) return null;
if (Conductor.instance == null || sounds.Count < 1) return null;
GameObject go = new GameObject("MultiSound");
MultiSound ms = go.AddComponent<MultiSound>();