port karate man, fix NaN bug
goin to bed now!
This commit is contained in:
parent
8dca64d523
commit
d1eb6661b9
|
|
@ -567,15 +567,17 @@ namespace HeavenStudio.Games
|
||||||
static double wordClearTime = double.MinValue;
|
static double wordClearTime = double.MinValue;
|
||||||
|
|
||||||
[Header("Backgrounds")]
|
[Header("Backgrounds")]
|
||||||
// 0 = bg color, 1 = shadow color, 2 = filter color
|
// // 0 = bg color, 1 = shadow color, 2 = filter color
|
||||||
private double[] colorStartBeats = new double[3] {
|
// private double[] colorStartBeats = new double[3] {
|
||||||
-1,
|
// -1,
|
||||||
-1,
|
// -1,
|
||||||
-1
|
// -1
|
||||||
};
|
// };
|
||||||
private float[] colorLengths = new float[3];
|
// private float[] colorLengths = new float[3];
|
||||||
private Color[] colorStarts, colorEnds = new Color[3];
|
// private Color[] colorStarts, colorEnds = new Color[3];
|
||||||
private Util.EasingFunction.Ease[] colorEases = new Util.EasingFunction.Ease[3];
|
// private Util.EasingFunction.Ease[] colorEases = new Util.EasingFunction.Ease[3];
|
||||||
|
|
||||||
|
private ColorEase[] colorEases = new ColorEase[3];
|
||||||
|
|
||||||
public int currentBgEffect = (int)BackgroundFXType.None;
|
public int currentBgEffect = (int)BackgroundFXType.None;
|
||||||
|
|
||||||
|
|
@ -704,11 +706,10 @@ namespace HeavenStudio.Games
|
||||||
bgEffectAnimator = BGEffect.GetComponent<Animator>();
|
bgEffectAnimator = BGEffect.GetComponent<Animator>();
|
||||||
bgEffectSpriteRenderer = BGEffect.GetComponent<SpriteRenderer>();
|
bgEffectSpriteRenderer = BGEffect.GetComponent<SpriteRenderer>();
|
||||||
|
|
||||||
colorEnds =
|
colorEases = new ColorEase[] {
|
||||||
colorStarts = new Color[] {
|
new(BackgroundColors[0]),
|
||||||
BackgroundColors[0],
|
new(TintColor(BackgroundColors[0])),
|
||||||
TintColor(BackgroundColors[0]),
|
new(new Color()),
|
||||||
new Color(),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -769,11 +770,6 @@ namespace HeavenStudio.Games
|
||||||
bg["textureType"], bg["autoColor"], bg["startTexture"], bg["endTexture"]
|
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)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
|
|
@ -1108,28 +1104,15 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
currentBgEffect = fxType;
|
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 preset = presetBG != (int)BackgroundType.Custom;
|
||||||
bool tinted = shadowType == (int)ShadowType.Tinted;
|
bool tinted = shadowType == (int)ShadowType.Tinted;
|
||||||
|
|
||||||
Color bgColorStart = preset ? BGPlane.color : colorStart;
|
Color bgColorStart = preset ? BGPlane.color : colorStart;
|
||||||
colorStarts = new Color[] {
|
|
||||||
bgColorStart,
|
|
||||||
tinted ? TintColor(bgColorStart) : shadowStart,
|
|
||||||
autoColor ? TintColor(bgColorStart): filterStart,
|
|
||||||
};
|
|
||||||
|
|
||||||
Color bgColorEnd = preset ? BackgroundColors[presetBG] : colorEnd;
|
Color bgColorEnd = preset ? BackgroundColors[presetBG] : colorEnd;
|
||||||
colorEnds = new Color[] {
|
colorEases = new ColorEase[] {
|
||||||
bgColorEnd,
|
new(beat, length, bgColorStart, bgColorEnd, colorEaseSet),
|
||||||
tinted ? TintColor(bgColorEnd) : shadowEnd,
|
new(beat, length, (tinted ? TintColor(bgColorStart) : shadowStart), (tinted ? TintColor(bgColorEnd) : shadowEnd), colorEaseSet),
|
||||||
autoColor ? TintColor(bgColorEnd) : filterEnd,
|
new(beat, length, (autoColor ? TintColor(bgColorStart): filterStart), (autoColor ? TintColor(bgColorEnd) : filterEnd), colorEaseSet),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < BGTextures.Length; i++)
|
for (int i = 0; i < BGTextures.Length; i++)
|
||||||
|
|
@ -1150,18 +1133,8 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
for (int i = 0; i < spriteRenderers.Length; i++)
|
for (int i = 0; i < spriteRenderers.Length; i++)
|
||||||
{
|
{
|
||||||
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(colorStartBeats[i], colorLengths[i]));
|
foreach (var renderer in spriteRenderers[i]) {
|
||||||
if (double.IsNaN(normalizedBeat)) normalizedBeat = 0; // happens if the game is stopped onto the first beat
|
renderer.color = GetNewColor(colorEases[i]);
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -456,6 +456,7 @@ namespace HeavenStudio.Games
|
||||||
public Color GetNewColor(double beat, float length, Color start, Color end, Util.EasingFunction.Function func)
|
public Color GetNewColor(double beat, float length, Color start, Color end, Util.EasingFunction.Function func)
|
||||||
{
|
{
|
||||||
float normalizedBeat = Mathf.Clamp01(Conductor.instance.GetPositionFromBeat(beat, length));
|
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 newR = func(start.r, end.r, normalizedBeat);
|
||||||
float newG = func(start.g, end.g, normalizedBeat);
|
float newG = func(start.g, end.g, normalizedBeat);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue