finish up the code, document it

just a few more fixes and we're good
This commit is contained in:
AstrlJelly 2024-03-02 03:07:42 -05:00
parent 13bf8b083b
commit 55e5d42fbe
14 changed files with 300 additions and 237 deletions

View file

@ -1,5 +1,89 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &1149529152017899140
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7756588035483065508}
- component: {fileID: 5509506644699650990}
m_Layer: 0
m_Name: ViewerBG
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7756588035483065508
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1149529152017899140}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.121, y: -0.0864, z: 0}
m_LocalScale: {x: 2.1919, y: 2.2835865, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5813499710761815888}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &5509506644699650990
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1149529152017899140}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: -252
m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &2710624465797362219 --- !u!1 &2710624465797362219
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -282,7 +366,9 @@ Transform:
m_LocalPosition: {x: -0.077264786, y: 0.66982126, z: 74.52776} m_LocalPosition: {x: -0.077264786, y: 0.66982126, z: 74.52776}
m_LocalScale: {x: 1.5850028, y: 1.5866843, z: 1.6180401} m_LocalScale: {x: 1.5850028, y: 1.5866843, z: 1.6180401}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children:
- {fileID: 7756588035483065508}
- {fileID: 4441240923074664422}
m_Father: {fileID: 5813499711174113251} m_Father: {fileID: 5813499711174113251}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -806,6 +892,7 @@ MonoBehaviour:
currentEarlyPeasOnFork: 0 currentEarlyPeasOnFork: 0
currentPerfectPeasOnFork: 0 currentPerfectPeasOnFork: 0
currentLatePeasOnFork: 0 currentLatePeasOnFork: 0
eatType: 0
topbun: 0 topbun: 0
middleburger: 0 middleburger: 0
bottombun: 0 bottombun: 0
@ -1023,6 +1110,15 @@ MonoBehaviour:
handAnim: {fileID: 5813499711174113250} handAnim: {fileID: 5813499711174113250}
flickedObject: {fileID: 5813499710694194086} flickedObject: {fileID: 5813499710694194086}
peaPreview: {fileID: 5813499711025093251} peaPreview: {fileID: 5813499711025093251}
bgRecolorables:
- {fileID: 5813499711658895221}
- {fileID: 5813499710761815889}
gradRecolorables:
- {fileID: 5813499711561122392}
- {fileID: 5813499712485673336}
- {fileID: 5509506644699650990}
- {fileID: 1661519934678317608}
- {fileID: 5813499711762093784}
bg: {fileID: 5813499711658895221} bg: {fileID: 5813499711658895221}
bgGradient: {fileID: 5813499711561122392} bgGradient: {fileID: 5813499711561122392}
viewerCircle: {fileID: 5813499710761815889} viewerCircle: {fileID: 5813499710761815889}
@ -1485,7 +1581,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5813499711561122393} m_GameObject: {fileID: 5813499711561122393}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -2.0479, z: 0} m_LocalPosition: {x: 0, y: -2.36, z: 0}
m_LocalScale: {x: 134.83125, y: 2.495626, z: 1} m_LocalScale: {x: 134.83125, y: 2.495626, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@ -2447,6 +2543,90 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!1 &7181315906917902434
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4441240923074664422}
- component: {fileID: 1661519934678317608}
m_Layer: 0
m_Name: ViewerBGExtension
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4441240923074664422
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7181315906917902434}
m_LocalRotation: {x: -0, y: -0, z: 0.96384364, w: -0.2664687}
m_LocalPosition: {x: 0.6536316, y: -1.0729094, z: 0}
m_LocalScale: {x: 0.19709346, y: 0.31798187, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5813499710761815888}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -149.092}
--- !u!212 &1661519934678317608
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7181315906917902434}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: -252
m_Sprite: {fileID: 7482667652216324306, guid: 75f5f34dc1b5347e0b8351032682f224, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &8163793729482436657 --- !u!1 &8163793729482436657
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -348,10 +348,10 @@ TextureImporter:
name: bg name: bg
rect: rect:
serializedVersion: 2 serializedVersion: 2
x: 4976.5967 x: 4977
y: 50.7816 y: 51
width: 152.3448 width: 152
height: 1066.4136 height: 1004
alignment: 0 alignment: 0
pivot: {x: 0.5, y: 0.5} pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
@ -941,7 +941,7 @@ TextureImporter:
width: 990.2412 width: 990.2412
height: 431.64362 height: 431.64362
alignment: 0 alignment: 0
pivot: {x: 0, y: 0} pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
outline: [] outline: []
physicsShape: [] physicsShape: []

View file

@ -76,27 +76,10 @@ namespace HeavenStudio.Games
public static CoinToss instance { get; set; } public static CoinToss instance { get; set; }
private static Color _defaultBgColor; public static Color defaultBgColor = new Color(0.97f, 0.97f, 0.26f);
public static Color defaultBgColor public static Color defaultFgColor = new Color(1f, 1f, 0.51f);
{
get
{
ColorUtility.TryParseHtmlString("#F7F742", out _defaultBgColor);
return _defaultBgColor;
}
}
private static Color _defaultFgColor;
public static Color defaultFgColor
{
get
{
ColorUtility.TryParseHtmlString("#FFFF83", out _defaultFgColor);
return _defaultFgColor;
}
}
[Header("Backgrounds")] [Header("Backgrounds")]
public SpriteRenderer fg; public SpriteRenderer fg;
public SpriteRenderer bg; public SpriteRenderer bg;
@ -207,8 +190,8 @@ namespace HeavenStudio.Games
// call this in update // call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
bg.color = GetNewColor(bgColorEase); bg.color = bgColorEase.GetColor();
fg.color = GetNewColor(bgFColorEase); fg.color = bgFColorEase.GetColor();
} }
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetF, Color colorEndSetF, int ease) public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, Color colorStartSetF, Color colorEndSetF, int ease)

View file

@ -286,8 +286,8 @@ namespace HeavenStudio.Games
//call this in update //call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
backgroundGradient.color = GetNewColor(tColorEase); backgroundGradient.color = tColorEase.GetColor();
background.color = GetNewColor(bColorEase); background.color = bColorEase.GetColor();
} }
public void BackgroundColor(double beat, float length, Color colorStartSetT, Color colorEndSetT, 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)

View file

@ -107,11 +107,8 @@ namespace HeavenStudio.Games
public Animator handAnim; public Animator handAnim;
public GameObject flickedObject; public GameObject flickedObject;
public SpriteRenderer peaPreview; public SpriteRenderer peaPreview;
[SerializeField] SpriteRenderer bg; [SerializeField] SpriteRenderer[] bgRecolorables;
[SerializeField] SpriteRenderer bgGradient; [SerializeField] SpriteRenderer[] gradRecolorables;
[SerializeField] SpriteRenderer viewerCircle;
[SerializeField] SpriteRenderer playerShadow;
[SerializeField] SpriteRenderer handShadow;
public Sprite[] peaSprites; public Sprite[] peaSprites;
public Sprite[] peaHitSprites; public Sprite[] peaHitSprites;
@ -184,12 +181,15 @@ namespace HeavenStudio.Games
//call this in update //call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
bg.color = var bgColor = bgColorEase.GetColor();
viewerCircle.color = foreach (var sr in bgRecolorables) {
handShadow.color = GetNewColor(bgColorEase); sr.color = bgColor;
}
bgGradient.color = var gradColor = gradColorEase.GetColor();
playerShadow.color = GetNewColor(gradColorEase); foreach (var sr in gradRecolorables) {
sr.color = gradColor;
}
} }
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease) public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)

View file

@ -1109,7 +1109,7 @@ namespace HeavenStudio.Games
for (int i = 0; i < spriteRenderers.Length; i++) for (int i = 0; i < spriteRenderers.Length; i++)
{ {
foreach (var renderer in spriteRenderers[i]) { foreach (var renderer in spriteRenderers[i]) {
renderer.color = GetNewColor(colorEases[i]); renderer.color = colorEases[i].GetColor();
} }
} }
} }

View file

@ -484,7 +484,7 @@ namespace HeavenStudio.Games
//call this in update //call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
background.color = GetNewColor(bgColorEase); background.color = bgColorEase.GetColor();
} }
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease) public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)

View file

@ -429,14 +429,47 @@ namespace HeavenStudio.Games
#endregion #endregion
#region Color #region Color
// truly a moment in history. documentation in heaven studio :)
public class ColorEase public class ColorEase
{ {
public double startBeat; /// <summary>
public float length; /// Gets the eased color from the variables inside a <c>ColorEase</c>. <br/>
public Color startColor, endColor; /// Use this in <c>Update()</c>.
public Util.EasingFunction.Ease ease; /// </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; 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) { public ColorEase(double startBeat, float length, Color startColor, Color endColor, int ease) {
this.startBeat = startBeat; this.startBeat = startBeat;
this.length = length; this.length = length;
@ -444,31 +477,16 @@ namespace HeavenStudio.Games
this.ease = (Util.EasingFunction.Ease)ease; this.ease = (Util.EasingFunction.Ease)ease;
this.easeFunc = Util.EasingFunction.GetEasingFunction(this.ease); this.easeFunc = Util.EasingFunction.GetEasingFunction(this.ease);
} }
public ColorEase(Color? tempColor = null) {
startBeat = length = 0; /// <summary>
startColor = endColor = (tempColor ?? Color.white); /// The constructor to use when initializing the ColorEase variable.
ease = Util.EasingFunction.Ease.Instant; /// </summary>
easeFunc = Util.EasingFunction.GetEasingFunction(ease); /// <param name="defaultColor">The default color to initialize with.</param>
public ColorEase(Color? defaultColor = null) {
startColor = endColor = defaultColor ?? Color.white;
easeFunc = Util.EasingFunction.Instant;
} }
} }
public Color GetNewColor(ColorEase ce) => GetNewColor(ce.startBeat, ce.length, ce.startColor, ce.endColor, ce.easeFunc);
public Color GetNewColor(double beat, float length, Color start, Color end, Util.EasingFunction.Function func)
{
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(beat, length));
if (double.IsNaN(normalizedBeat)) normalizedBeat = 0; // happens if the game is stopped onto the first beat
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);
}
// public RiqEntity PersistColor(double beat)
// {
//
// }
#endregion #endregion
private void OnDestroy() private void OnDestroy()

View file

@ -3,6 +3,7 @@ using UnityEngine;
using DG.Tweening; using DG.Tweening;
using HeavenStudio.Util; using HeavenStudio.Util;
using Jukebox;
namespace HeavenStudio.Games.Loaders namespace HeavenStudio.Games.Loaders
{ {
@ -10,6 +11,18 @@ namespace HeavenStudio.Games.Loaders
public static class AgbUpbeatLoader public static class AgbUpbeatLoader
{ {
public static Minigame AddGame(EventCaller eventCaller) { 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>() return new Minigame("mrUpbeat", "Mr. Upbeat", "E0E0E0", false, false, new List<GameAction>()
{ {
new GameAction("prepare", "Prepare") new GameAction("prepare", "Prepare")
@ -49,14 +62,14 @@ namespace HeavenStudio.Games.Loaders
{ {
function = delegate { function = delegate {
var e = eventCaller.currentEntity; 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, resizable = true,
parameters = new List<Param>() 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("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("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") new GameAction("upbeatColors", "Upbeat Colors")
@ -151,13 +164,14 @@ namespace HeavenStudio.Games
[SerializeField] SpriteRenderer[] shadowSr; [SerializeField] SpriteRenderer[] shadowSr;
[Header("Properties")] [Header("Properties")]
private Tween bgColorTween;
public int stepIterate = 0; public int stepIterate = 0;
private static double startSteppingBeat = double.MaxValue; private static double startSteppingBeat = double.MaxValue;
private static double startBlippingBeat = double.MaxValue; private static double startBlippingBeat = double.MaxValue;
private bool stopStepping; private bool stopStepping;
public bool stopBlipping; public bool stopBlipping;
private ColorEase bgColorEase = new(new Color(0.878f, 0.878f, 0.878f));
public static MrUpbeat instance; public static MrUpbeat instance;
private void Awake() private void Awake()
@ -209,9 +223,9 @@ namespace HeavenStudio.Games
public void Update() public void Update()
{ {
var cond = Conductor.instance; bg.color = bgColorEase.GetColor();
if (cond.isPlaying && !cond.isPaused) { if (conductor.isPlaying && !conductor.isPaused) {
var songPos = cond.songPositionInBeatsAsDouble; var songPos = conductor.songPositionInBeatsAsDouble;
if (songPos >= startSteppingBeat - 2) { if (songPos >= startSteppingBeat - 2) {
man.canStep = true; man.canStep = true;
@ -273,7 +287,6 @@ namespace HeavenStudio.Games
private void RecursiveStepping(double beat) private void RecursiveStepping(double beat)
{ {
if (stopStepping) { if (stopStepping) {
stopStepping = false; stopStepping = false;
return; return;
} }
@ -327,25 +340,9 @@ namespace HeavenStudio.Games
man.Fall(); 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; bgColorEase = new(beat, length, startColor, endColor, ease);
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);
} }
public void UpbeatColors(Color blipColor, bool setShadow, Color shadowColor) 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 = new(0.631f, 0.31f, 0.631f);
public static Color defaultBgColor
{
get
{
ColorUtility.TryParseHtmlString("#A14FA1", out _defaultBgColor);
return _defaultBgColor;
}
}
public static RhythmTweezers instance { get; set; } public static RhythmTweezers instance { get; set; }
private static CallAndResponseHandler crHandlerInstance; private static CallAndResponseHandler crHandlerInstance;
@ -241,8 +233,6 @@ namespace HeavenStudio.Games
private void Awake() private void Awake()
{ {
instance = this; instance = this;
colorStart = defaultBgColor;
colorEnd = defaultBgColor;
if (crHandlerInstance != null && crHandlerInstance.queuedEvents.Count > 0) if (crHandlerInstance != null && crHandlerInstance.queuedEvents.Count > 0)
{ {
foreach (var crEvent in crHandlerInstance.queuedEvents) foreach (var crEvent in crHandlerInstance.queuedEvents)
@ -537,45 +527,22 @@ namespace HeavenStudio.Games
VegetableDupe.color = newColor; VegetableDupe.color = newColor;
} }
private double colorStartBeat = -1; private ColorEase bgColorEase = new(defaultBgColor);
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 public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
private void BackgroundColorUpdate()
{ {
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength)); bgColorEase = new(beat, length, startColor, endColor, ease);
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;
} }
//call this in OnPlay(double beat) and OnGameSwitch(double beat) //call this in OnPlay(double beat) and OnGameSwitch(double beat)
private void PersistBlocks(double beat) private void PersistBlocks(double beat)
{ {
var allEventsBeforeBeat = GameManager.instance.Beatmap.Entities.FindAll(x => x.datamodel.Split('/')[0] == "rhythmTweezers" && x.beat < 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"); var lastColorEvent = allEventsBeforeBeat.FindLast(x => x.datamodel == "rhythmTweezers/fade background color");
if (allColorEventsBeforeBeat.Count > 0) if (lastColorEvent != null)
{ {
allColorEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case var e = lastColorEvent;
var lastEvent = allColorEventsBeforeBeat[^1]; BackgroundColor(e.beat, e.length, e["colorA"], e["colorB"], e["ease"]);
BackgroundColor(lastEvent.beat, lastEvent.length, lastEvent["colorA"], lastEvent["colorB"], lastEvent["ease"]);
} }
var allAltFaceEventsBeforeBeat = allEventsBeforeBeat.FindAll(x => x.datamodel == "rhythmTweezers/altSmile"); var allAltFaceEventsBeforeBeat = allEventsBeforeBeat.FindAll(x => x.datamodel == "rhythmTweezers/altSmile");
VegetableAnimator.SetBool("UseAltSmile", allAltFaceEventsBeforeBeat.Count % 2 == 1); 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) public override void OnGameSwitch(double beat)

View file

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

View file

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

View file

@ -484,15 +484,7 @@ namespace HeavenStudio.Games
//call this in update //call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength)); bg.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);
} }
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease) public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)

View file

@ -303,15 +303,7 @@ namespace HeavenStudio.Games
//call this in update //call this in update
private void BackgroundColorUpdate() private void BackgroundColorUpdate()
{ {
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeat, colorLength)); bg.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);
} }
public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease) public void BackgroundColor(double beat, float length, Color colorStartSet, Color colorEndSet, int ease)