diff --git a/Assets/Resources/Games/cannery.prefab b/Assets/Resources/Games/cannery.prefab index ce43dd6c6..a23be9738 100644 --- a/Assets/Resources/Games/cannery.prefab +++ b/Assets/Resources/Games/cannery.prefab @@ -661,7 +661,7 @@ SpriteRenderer: m_FlipX: 0 m_FlipY: 0 m_DrawMode: 2 - m_Size: {x: 100, y: 0.47} + m_Size: {x: 100, y: 0.45} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 @@ -761,6 +761,8 @@ MonoBehaviour: scheduledInputs: [] canGO: {fileID: 8575099813453766973} blackout: {fileID: 6779319467216197044} + alarmMat: {fileID: 2100000, guid: cffd715f1564d4440881c6fe148baa9c, type: 2} + bgPlaneSR: {fileID: 5948254459511631684} conveyorBeltAnim: {fileID: 3839135881600344077} alarmAnim: {fileID: 3637100343128600021} dingAnim: {fileID: 7386547292618809648} @@ -1087,12 +1089,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: startBeat: 0 + parentAnim: {fileID: 0} anim: {fileID: 5817211847633092072} - sr: {fileID: 8380232789943656751} - canSprites: - - {fileID: 947544752, guid: 5a8f2715082952e4b804a4b950cf25d4, type: 3} - - {fileID: -1665090095, guid: 5a8f2715082952e4b804a4b950cf25d4, type: 3} - cannedSprite: {fileID: 1930332746, guid: 5a8f2715082952e4b804a4b950cf25d4, type: 3} --- !u!95 &5817211847633092072 Animator: serializedVersion: 5 diff --git a/Assets/Resources/Sprites/Games/Cannery/Cannery.png b/Assets/Resources/Sprites/Games/Cannery/Cannery.png index d4be36346..a346bab66 100644 Binary files a/Assets/Resources/Sprites/Games/Cannery/Cannery.png and b/Assets/Resources/Sprites/Games/Cannery/Cannery.png differ diff --git a/Assets/Resources/Sprites/Games/Cannery/Cannery.png.meta b/Assets/Resources/Sprites/Games/Cannery/Cannery.png.meta index 3f7224ffa..55ca905e3 100644 --- a/Assets/Resources/Sprites/Games/Cannery/Cannery.png.meta +++ b/Assets/Resources/Sprites/Games/Cannery/Cannery.png.meta @@ -47,7 +47,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 215 + spritePixelsToUnits: 197 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 @@ -108,10 +108,10 @@ TextureImporter: name: Cannery_0 rect: serializedVersion: 2 - x: 139 - y: 1886 - width: 222 - height: 178 + x: 129 + y: 1907 + width: 206 + height: 116 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -129,10 +129,10 @@ TextureImporter: name: Cannery_1 rect: serializedVersion: 2 - x: 408 - y: 1886 - width: 222 - height: 178 + x: 378 + y: 1906 + width: 206 + height: 141 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -150,10 +150,10 @@ TextureImporter: name: Cannery_2 rect: serializedVersion: 2 - x: 659 - y: 1887 - width: 223 - height: 178 + x: 610 + y: 1907 + width: 207 + height: 165 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -171,10 +171,10 @@ TextureImporter: name: Cannery_3 rect: serializedVersion: 2 - x: 1042 - y: 1868 - width: 188 - height: 104 + x: 965 + y: 1893 + width: 174 + height: 90 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -192,10 +192,10 @@ TextureImporter: name: Cannery_4 rect: serializedVersion: 2 - x: 1958 - y: 352 - width: 212 - height: 1659 + x: 1784 + y: 569 + width: 175 + height: 1459 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -213,10 +213,10 @@ TextureImporter: name: Cannery_5 rect: serializedVersion: 2 - x: 2354 - y: 352 - width: 212 - height: 1659 + x: 2172 + y: 1559 + width: 177 + height: 371 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -234,10 +234,10 @@ TextureImporter: name: Cannery_9 rect: serializedVersion: 2 - x: 1035 - y: 1025 - width: 776 - height: 680 + x: 963 + y: 1114 + width: 709 + height: 619 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -255,10 +255,10 @@ TextureImporter: name: Cannery_16 rect: serializedVersion: 2 - x: 712 - y: 505 - width: 243 - height: 370 + x: 659 + y: 627 + width: 225 + height: 323 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -276,12 +276,12 @@ TextureImporter: name: Cannery_17 rect: serializedVersion: 2 - x: 1067 - y: 502 - width: 243 - height: 370 + x: 483 + y: 511 + width: 224 + height: 93 alignment: 0 - pivot: {x: 0.5, y: 0.5} + pivot: {x: 0, y: 0} border: {x: 0, y: 0, z: 0, w: 0} outline: [] physicsShape: [] @@ -297,12 +297,12 @@ TextureImporter: name: Cannery_18 rect: serializedVersion: 2 - x: 1439 - y: 508 - width: 243 - height: 370 + x: 122 + y: 585 + width: 251 + height: 167 alignment: 0 - pivot: {x: 0.5, y: 0.5} + pivot: {x: 0, y: 0} border: {x: 0, y: 0, z: 0, w: 0} outline: [] physicsShape: [] @@ -318,10 +318,10 @@ TextureImporter: name: Cannery_21 rect: serializedVersion: 2 - x: 224 - y: 86 - width: 2218 - height: 206 + x: 208 + y: 240 + width: 2054 + height: 190 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -339,10 +339,10 @@ TextureImporter: name: Cannery_15 rect: serializedVersion: 2 - x: 446 - y: 695 - width: 93 - height: 147 + x: 436 + y: 777 + width: 87 + height: 136 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -360,10 +360,10 @@ TextureImporter: name: Cannery_6 rect: serializedVersion: 2 - x: 123 - y: 1048 - width: 754 - height: 762 + x: 114 + y: 1130 + width: 699 + height: 706 alignment: 0 pivot: {x: 0.5, y: 0.5} border: {x: 0, y: 0, z: 0, w: 0} @@ -377,6 +377,174 @@ TextureImporter: indices: edges: [] weights: [] + - serializedVersion: 2 + name: Cannery_7 + rect: + serializedVersion: 2 + x: 2628 + y: 1343 + width: 720 + height: 630 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: e88f826d2c942d343ad384ad304e4622 + internalID: -2125757524 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: Cannery_8 + rect: + serializedVersion: 2 + x: 2157 + y: 1192 + width: 196 + height: 108 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: 3b04e321e20f74343985c4951f592cb1 + internalID: -506358788 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: Cannery_10 + rect: + serializedVersion: 2 + x: 2119 + y: 1005 + width: 255 + height: 97 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: 9a0758c2c57fe0245982ee36c145e82c + internalID: -595179016 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: Cannery_11 + rect: + serializedVersion: 2 + x: 2093 + y: 878 + width: 308 + height: 76 + alignment: 0 + pivot: {x: 0.5, y: 0.5} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: 84d71a99c626fcb47bf9af2c04cdf16f + internalID: -627351396 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: Cannery_12 + rect: + serializedVersion: 2 + x: 1047 + y: 744 + width: 225 + height: 267 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: aae6773ff14e4384ba6defdf7b0daa2d + internalID: -107611502 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: Cannery_13 + rect: + serializedVersion: 2 + x: 1308 + y: 497 + width: 222 + height: 81 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: a5ffdad5e5873c64fa570dd143d1f2ac + internalID: -930593981 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: Cannery_14 + rect: + serializedVersion: 2 + x: 1033 + y: 512 + width: 207 + height: 86 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: 5f2a7f616cb9c2d4ab01c0ffbba4b53c + internalID: 626725903 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: Cannery_19 + rect: + serializedVersion: 2 + x: 115 + y: 922 + width: 266 + height: 177 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: 6d1615345ef625841af57697ace0af3c + internalID: -2139971189 + vertices: [] + indices: + edges: [] + weights: [] outline: [] physicsShape: [] bones: [] diff --git a/Assets/Scripts/Games/RhythmCannery.meta b/Assets/Scripts/Games/Cannery.meta similarity index 100% rename from Assets/Scripts/Games/RhythmCannery.meta rename to Assets/Scripts/Games/Cannery.meta diff --git a/Assets/Scripts/Games/RhythmCannery/Can.cs b/Assets/Scripts/Games/Cannery/Can.cs similarity index 74% rename from Assets/Scripts/Games/RhythmCannery/Can.cs rename to Assets/Scripts/Games/Cannery/Can.cs index 8a1cf2c73..a7a2d431f 100644 --- a/Assets/Scripts/Games/RhythmCannery/Can.cs +++ b/Assets/Scripts/Games/Cannery/Can.cs @@ -12,21 +12,19 @@ namespace HeavenStudio.Games.Scripts_Cannery public double startBeat; [Header("Components")] + [SerializeField] Animator parentAnim; [SerializeField] Animator anim; - [SerializeField] SpriteRenderer sr; - - [Header("Sprites")] - [SerializeField] Sprite[] canSprites; - [SerializeField] Sprite cannedSprite; + // [SerializeField] SpriteRenderer sr; Cannery game; private void Awake() { game = Cannery.instance; - int random = Random.Range(0, 2); + int random = Random.Range(-1, 1); Debug.Log(random); - sr.sprite = canSprites[random]; + var pos = transform.position; + pos.x *= random; game.ScheduleInput(startBeat, 1, Minigame.InputAction_BasicPress, Hit, null, null); } @@ -36,14 +34,14 @@ namespace HeavenStudio.Games.Scripts_Cannery float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 2); Debug.Log(normalizedBeat); if (normalizedBeat > 1) Destroy(gameObject); - anim.DoNormalizedAnimation("Move", normalizedBeat); + parentAnim.DoNormalizedAnimation("Move", normalizedBeat); } private void Hit(PlayerActionEvent caller, float state) { game.cannerAnim.DoScaledAnimationAsync("Can", 0.5f); SoundByte.PlayOneShotGame("cannery/can"); - sr.sprite = cannedSprite; + anim.DoScaledAnimationAsync("Canned", 0.5f); } } } diff --git a/Assets/Scripts/Games/RhythmCannery/Can.cs.meta b/Assets/Scripts/Games/Cannery/Can.cs.meta similarity index 100% rename from Assets/Scripts/Games/RhythmCannery/Can.cs.meta rename to Assets/Scripts/Games/Cannery/Can.cs.meta diff --git a/Assets/Scripts/Games/RhythmCannery/Cannery.cs b/Assets/Scripts/Games/Cannery/Cannery.cs similarity index 53% rename from Assets/Scripts/Games/RhythmCannery/Cannery.cs rename to Assets/Scripts/Games/Cannery/Cannery.cs index 5c7b83dce..94ee10786 100644 --- a/Assets/Scripts/Games/RhythmCannery/Cannery.cs +++ b/Assets/Scripts/Games/Cannery/Cannery.cs @@ -37,6 +37,35 @@ namespace HeavenStudio.Games.Loaders function = delegate { Cannery.instance.Blackout(); }, defaultLength = 0.5f, }, + new GameAction("backgroundColor", "Background Color") + { + function = delegate { + var e = eventCaller.currentEntity; + Cannery.instance.BackgroundColorChange(e.beat, e.length, e["startColor"], e["endColor"], e["ease"]); + }, + defaultLength = 1f, + resizable = true, + parameters = new List() + { + new Param("startColor", new Color(1, 1, 1), "Start Color", "Set the color at the start of the event."), + new Param("endColor", new Color(1, 1, 1), "End Color", "Set the color at the end of the event."), + new Param("ease", Util.EasingFunction.Ease.Instant, "Ease", "Set the easing of the action."), + }, + }, + new GameAction("alarmColor", "Alarm Color") + { + function = delegate { + var e = eventCaller.currentEntity; + Cannery.instance.AlarmColor(e.beat, e.length, e["startColor"], e["endColor"], e["ease"]); + }, + defaultLength = 0.5f, + parameters = new List() + { + new Param("startColor", new Color(0.8627f, 0.3725f, 0.0313f), "Start Color", "Set the color at the start of the event."), + new Param("endColor", new Color(0.8627f, 0.3725f, 0.0313f), "End Color", "Set the color at the end of the event."), + new Param("ease", Util.EasingFunction.Ease.Instant, "Ease", "Set the easing of the action."), + } + }, } // , // new List() { "mob", "normal" }, @@ -56,6 +85,8 @@ namespace HeavenStudio.Games [Header("Objects")] [SerializeField] GameObject canGO; [SerializeField] GameObject blackout; + [SerializeField] Material alarmMat; + [SerializeField] SpriteRenderer bgPlaneSR; [Header("Animators")] [SerializeField] Animator conveyorBeltAnim; @@ -63,27 +94,48 @@ namespace HeavenStudio.Games public Animator dingAnim; public Animator cannerAnim; + private ColorEase bgColorEase; + private ColorEase alarmColorEase; + private bool alarmBop = true; public static Cannery instance; - void Awake() + private void Awake() { instance = this; canGO.SetActive(false); } - void Update() + private void Update() { conveyorBeltAnim.DoNormalizedAnimation("Move", (Conductor.instance.songPositionInBeats / 2) % 1); + + bgPlaneSR.color = GetNewColor(bgColorEase); + alarmMat.SetColor("_ColorAlpha", GetNewColor(alarmColorEase)); } public override void OnGameSwitch(double beat) { - List cans = GameManager.instance.Beatmap.Entities.FindAll(e => e.datamodel == "cannery/can" && beat > e.beat && beat < e.beat + 1); + List events = GameManager.instance.Beatmap.Entities.FindAll(e => e.datamodel.Split('/')[0] == "cannery"); + List cans = events.FindAll(e => e.datamodel == "cannery/can" && beat > e.beat && beat < e.beat + 1); foreach (var can in cans) { SendCan(can.beat); } + RiqEntity bgEvent = events.FindLast(e => e.datamodel == "cannery/backgroundColor" && e.beat < beat); + if (bgEvent != null) { + var e = bgEvent; + BackgroundColorChange(e.beat, e.length, e["startColor"], e["endColor"], e["ease"]); + } else { + BackgroundColorChange(0, 0, new Color(0.8627f, 0.3725f, 0.0313f), new Color(0.8627f, 0.3725f, 0.0313f), 0); + } + RiqEntity alarmEvent = events.FindLast(e => e.datamodel == "cannery/alarmColor" && e.beat < beat); + if (alarmEvent != null) { + var e = alarmEvent; + BackgroundColorChange(e.beat, e.length, e["startColor"], e["endColor"], e["ease"]); + } else { + BackgroundColorChange(0, 0, Color.white, Color.white, 0); + } } public override void OnPlay(double beat) @@ -110,6 +162,16 @@ namespace HeavenStudio.Games } } + public void AlarmColor(double beat, float length, Color startColor, Color endColor, int ease) + { + alarmColorEase = new(beat, length, startColor, endColor, ease); + } + + public void BackgroundColorChange(double beat, float length, Color startColor, Color endColor, int ease) + { + bgColorEase = new(beat, length, startColor, endColor, ease); + } + public static void CanSFX(double beat) { SoundByte.PlayOneShotGame("cannery/ding", beat); @@ -117,7 +179,6 @@ namespace HeavenStudio.Games public void SendCan(double beat) { - // dingAnim.DoScaledAnimationFromBeatAsync("Ding", 0.5f, beat); // do the ding animation on the beat BeatAction.New(this, new() { new(beat, delegate { dingAnim.DoScaledAnimationFromBeatAsync("Ding", 0.5f, beat); }) }); diff --git a/Assets/Scripts/Games/RhythmCannery/Cannery.cs.meta b/Assets/Scripts/Games/Cannery/Cannery.cs.meta similarity index 100% rename from Assets/Scripts/Games/RhythmCannery/Cannery.cs.meta rename to Assets/Scripts/Games/Cannery/Cannery.cs.meta diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index 6c01f9aa7..d9f2cc88c 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -485,6 +485,36 @@ namespace HeavenStudio.Games #endregion + #region Color + public struct ColorEase + { + public double startBeat; + public float length; + public Color startColor, endColor; + public Util.EasingFunction.Ease ease; + public readonly Util.EasingFunction.Function easeFunc; + 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); + } + } + + 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)); + + 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); + } + #endregion + private void OnDestroy() { foreach (var evt in scheduledInputs) diff --git a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset index 6fe15e0af..38f654827 100644 --- a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset +++ b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset @@ -17,6 +17,7 @@ MonoBehaviour: DenseViewWidthThreshold: 512 _disableAutoReloadInBackground: 0 ImportedScriptPaths: - - Assets/Scripts/Games/RhythmCannery/Can.cs + - Assets/Scripts/Games/Cannery/Can.cs + - Assets/Scripts/Games/Cannery/Cannery.cs PathsToSkipImportEvent: [] PathsToIgnoreOverwriteSettingOnAttribute: []