Game Switch Black Flash is now beat-based. (#503)

* Game switch flashes are now 0.25 beats long

* ambient glow now turns black when the game switch flash is on

* you can now set the void color, it doesn't work with game switch flashes

* black
This commit is contained in:
Rapandrasmus 2023-07-17 17:56:57 +02:00 committed by GitHub
parent d85580b14e
commit 1753a25947
4 changed files with 65 additions and 10 deletions

View file

@ -25,6 +25,7 @@ namespace HeavenStudio
private List<RiqEntity> positionEvents = new();
private List<RiqEntity> rotationEvents = new();
private List<RiqEntity> shakeEvents = new();
private List<RiqEntity> colorEvents = new();
/**
default cam position, for quick-resetting
@ -61,6 +62,8 @@ namespace HeavenStudio
[Header("Components")]
public Color baseColor;
public static Color currentColor;
private void Awake()
{
instance = this;
@ -74,6 +77,7 @@ namespace HeavenStudio
ResetTransforms();
ResetAdditionalTransforms();
currentColor = baseColor;
positionLast = defaultPosition;
rotEluerLast = defaultRotEluer;
@ -83,6 +87,7 @@ namespace HeavenStudio
{
ResetTransforms();
ResetAdditionalTransforms();
currentColor = baseColor;
positionLast = defaultPosition;
rotEluerLast = defaultRotEluer;
@ -101,9 +106,14 @@ namespace HeavenStudio
shakeEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "screen shake" });
//color/colour time baybee
colorEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "camera background color" });
UpdateCameraTranslate();
UpdateCameraRotate();
SetShakeIntensity();
UpdateCameraColor();
}
private void Update()
@ -111,6 +121,7 @@ namespace HeavenStudio
UpdateCameraTranslate();
UpdateCameraRotate();
SetShakeIntensity();
UpdateCameraColor();
}
private void LateUpdate()
@ -121,6 +132,29 @@ namespace HeavenStudio
cam.transform.localPosition = userPos + additionalPosition + shakeResult;
cam.transform.eulerAngles = rotEluer + additionalRotEluer;
cam.fieldOfView = additionalFoV;
cam.backgroundColor = currentColor;
if (!StaticCamera.instance.usingMinigameAmbientColor) StaticCamera.instance.SetAmbientGlowColour(currentColor, false, false);
}
private void UpdateCameraColor()
{
foreach (var e in colorEvents)
{
float prog = Conductor.instance.GetPositionFromBeat(e.beat, e.length);
if (prog >= 0f)
{
Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease)e["ease"]);
float newColorR = func(e["color"].r, e["color2"].r, prog);
float newColorG = func(e["color"].g, e["color2"].g, prog);
float newColorB = func(e["color"].b, e["color2"].b, prog);
currentColor = new Color(newColorR, newColorG, newColorB);
}
if (prog > 1f)
{
currentColor = e["color2"];
}
}
}
private void UpdateCameraTranslate()

View file

@ -761,24 +761,25 @@ namespace HeavenStudio
IEnumerator SwitchGameIE(string game, double beat, bool flash)
{
if(flash == true)
if(flash)
{
HeavenStudio.StaticCamera.instance.ToggleCanvasVisibility(false);
}
SetGame(game);
SetGame(game, false);
Minigame miniGame = currentGameO.GetComponent<Minigame>();
if (miniGame != null)
miniGame.OnGameSwitch(beat);
//TODO: wait time in beats instead of seconds
yield return new WaitForSeconds(0.1f);
//before beat-based: yield return new WaitForSeconds(0.1f);
yield return new WaitForSeconds(Conductor.instance.pitchedSecPerBeat / 4);
HeavenStudio.StaticCamera.instance.ToggleCanvasVisibility(true);
SetAmbientGlowToCurrentMinigameColor();
}
private void SetGame(string game)
private void SetGame(string game, bool useMinigameColor = true)
{
Destroy(currentGameO);
@ -786,7 +787,7 @@ namespace HeavenStudio
currentGameO.transform.parent = eventCaller.GamesHolder.transform;
currentGameO.name = game;
SetCurrentGame(game);
SetCurrentGame(game, useMinigameColor);
ResetCamera();
}
@ -833,21 +834,30 @@ namespace HeavenStudio
return EventCaller.instance.minigames.Find(c => c.name == name);
}
public void SetCurrentGame(string game)
public void SetCurrentGame(string game, bool useMinigameColor = true)
{
currentGame = game;
if (GetGameInfo(currentGame) != null)
{
CircleCursor.InnerCircle.GetComponent<SpriteRenderer>().color = Colors.Hex2RGB(GetGameInfo(currentGame).color);
HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(Colors.Hex2RGB(GetGameInfo(currentGame).color));
if (useMinigameColor) HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(Colors.Hex2RGB(GetGameInfo(currentGame).color), true);
//else HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(HeavenStudio.GameCamera.currentColor, false);
else HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(Color.black, false);
}
else
{
CircleCursor.InnerCircle.GetComponent<SpriteRenderer>().color = Color.white;
HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(Color.black);
//HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(HeavenStudio.GameCamera.currentColor, false);
HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(Color.black, false);
}
}
private void SetAmbientGlowToCurrentMinigameColor()
{
if (GetGameInfo(currentGame) != null)
HeavenStudio.StaticCamera.instance.SetAmbientGlowColour(Colors.Hex2RGB(GetGameInfo(currentGame).color), true);
}
private bool SongPosLessThanClipLength(float t)
{
if (Conductor.instance.musicSource.clip != null)

View file

@ -677,6 +677,13 @@ namespace HeavenStudio
new Param("axis", GameCamera.CameraAxis.All, "Axis", "The axis to move the camera on" )
}
),
new GameAction("camera background color", "Camera Background Color", 1, true, new List<Param>()
{
new Param("color", Color.black, "Start Color"),
new Param("color2", Color.black, "End Color"),
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease Type")
}
),
new GameAction("pan view", "Pan Viewport", 1f, true, new List<Param>()
{
new Param("valA", new EntityTypes.Float(-50, 50, 0), "Right / Left", "Next position on the X axis"),

View file

@ -8,6 +8,7 @@ using HeavenStudio.Common;
using HeavenStudio.Editor;
using Jukebox;
using Jukebox.Legacy;
using System;
namespace HeavenStudio
{
@ -210,8 +211,11 @@ namespace HeavenStudio
overlayView.SetActive(toggle);
}
public void SetAmbientGlowColour(Color colour)
[NonSerialized] public bool usingMinigameAmbientColor;
public void SetAmbientGlowColour(Color colour, bool minigameColor, bool overrideMinigameColor = true)
{
if (overrideMinigameColor) usingMinigameAmbientColor = minigameColor;
ambientBg.color = colour;
GameSettings.UpdatePreviewAmbient(colour);
}