From 8409cb281880c30740c6409542788feb35203885 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Tue, 21 Feb 2023 22:56:01 +0100 Subject: [PATCH] Tunnel Defuckedificaition + small tweaks and additions (#309) * tweaks and fixes * SMALL FIX --- Assets/Resources/Games/tapTroupe.prefab | 2 +- Assets/Scripts/Games/Fireworks/Fireworks.cs | 26 +++-- .../Scripts/Games/Fireworks/FireworksBomb.cs | 6 +- Assets/Scripts/Games/Fireworks/Rocket.cs | 6 +- .../Scripts/Games/RhythmSomen/RhythmSomen.cs | 17 ++- Assets/Scripts/Games/Ringside/Ringside.cs | 2 +- .../Games/SneakySpirits/SneakySpirits.cs | 14 ++- Assets/Scripts/Games/Tunnel/Tunnel.cs | 105 +++++++++--------- 8 files changed, 106 insertions(+), 72 deletions(-) diff --git a/Assets/Resources/Games/tapTroupe.prefab b/Assets/Resources/Games/tapTroupe.prefab index 8af56dda..d76944f5 100644 --- a/Assets/Resources/Games/tapTroupe.prefab +++ b/Assets/Resources/Games/tapTroupe.prefab @@ -1964,7 +1964,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -10 + m_SortingOrder: -11 m_Sprite: {fileID: 7482667652216324306, guid: 48e93eef0688c4a259cb0eddcd8661f7, type: 3} m_Color: {r: 0, g: 0, b: 0, a: 0.8156863} m_FlipX: 0 diff --git a/Assets/Scripts/Games/Fireworks/Fireworks.cs b/Assets/Scripts/Games/Fireworks/Fireworks.cs index 74cfa42e..ceb3d585 100644 --- a/Assets/Scripts/Games/Fireworks/Fireworks.cs +++ b/Assets/Scripts/Games/Fireworks/Fireworks.cs @@ -11,36 +11,39 @@ namespace HeavenStudio.Games.Loaders public static class AgbFireworkLoader { public static Minigame AddGame(EventCaller eventCaller) { - return new Minigame("fireworks", "Fireworks", "0058CE", false, false, new List() + return new Minigame("fireworks", "Fireworks \n(Hanabi)", "0058CE", false, false, new List() { new GameAction("firework", "Firework") { - preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, false, e["whereToSpawn"], e["toggle"], e["explosionType"]); }, + preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, false, e["whereToSpawn"], e["toggle"], e["explosionType"], e["applause"]); }, defaultLength = 4f, parameters = new List() { new Param("whereToSpawn", Fireworks.WhereToSpawn.Middle, "Where to spawn?", "Where should the firework spawn?"), new Param("explosionType", Fireworks.ExplosionType.MixedCircular, "Explosion Pattern", "What pattern should the firework explode with?"), + new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"), new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?") } }, new GameAction("sparkler", "Sparkler") { - preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, true, e["whereToSpawn"], e["toggle"], e["explosionType"]); }, + preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, true, e["whereToSpawn"], e["toggle"], e["explosionType"], e["applause"]); }, defaultLength = 2f, parameters = new List() { new Param("whereToSpawn", Fireworks.WhereToSpawn.Middle, "Where to spawn?", "Where should the firework spawn?"), new Param("explosionType", Fireworks.ExplosionType.MixedCircular, "Explosion Pattern", "What pattern should the firework explode with?"), + new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"), new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?") } }, new GameAction("bomb", "Bomb") { - function = delegate {var e = eventCaller.currentEntity; Fireworks.instance.SpawnBomb(e.beat, e["toggle"]); }, + function = delegate {var e = eventCaller.currentEntity; Fireworks.instance.SpawnBomb(e.beat, e["toggle"], e["applause"]); }, defaultLength = 3f, parameters = new List() { + new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"), new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?") } }, @@ -87,6 +90,7 @@ namespace HeavenStudio.Games public int whereToSpawn; public bool practice; public int explosionType; + public bool applause; } public enum WhereToSpawn { @@ -138,7 +142,7 @@ namespace HeavenStudio.Games { foreach (var firework in queuedFireworks) { - SpawnFirework(firework.beat, firework.isSparkler, firework.whereToSpawn, firework.practice, firework.explosionType); + SpawnFirework(firework.beat, firework.isSparkler, firework.whereToSpawn, firework.practice, firework.explosionType, firework.applause); } queuedFireworks.Clear(); } @@ -182,7 +186,7 @@ namespace HeavenStudio.Games } } - public static void PreSpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType) + public static void PreSpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause) { if (isSparkler) { @@ -204,18 +208,18 @@ namespace HeavenStudio.Games { new BeatAction.Action(beat, delegate { - Fireworks.instance.SpawnFirework(beat, isSparkler, whereToSpawn, practice, explosionType); + Fireworks.instance.SpawnFirework(beat, isSparkler, whereToSpawn, practice, explosionType, applause); }) }); } else { - queuedFireworks.Add(new QueuedFirework { beat = beat, isSparkler = isSparkler, whereToSpawn = whereToSpawn, practice = practice, explosionType = explosionType }); + queuedFireworks.Add(new QueuedFirework { beat = beat, isSparkler = isSparkler, whereToSpawn = whereToSpawn, practice = practice, explosionType = explosionType, applause = applause }); } } - void SpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType) + void SpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause) { if (isSparkler && practice) { @@ -250,10 +254,11 @@ namespace HeavenStudio.Games } Rocket spawnedRocket = Instantiate(firework, spawnPoint, false); spawnedRocket.isSparkler = isSparkler; + spawnedRocket.applause = applause; spawnedRocket.Init(beat, explosionType); } - public void SpawnBomb(float beat, bool practice) + public void SpawnBomb(float beat, bool practice, bool applause) { Jukebox.PlayOneShotGame("fireworks/bomb"); if (practice) @@ -269,6 +274,7 @@ namespace HeavenStudio.Games { FireworksBomb spawnedBomb = Instantiate(bomb, bombSpawn, false); spawnedBomb.curve = bombCurve; + spawnedBomb.applause = applause; spawnedBomb.Init(beat + 1); }) }); diff --git a/Assets/Scripts/Games/Fireworks/FireworksBomb.cs b/Assets/Scripts/Games/Fireworks/FireworksBomb.cs index ed6edac7..5bf5ef23 100644 --- a/Assets/Scripts/Games/Fireworks/FireworksBomb.cs +++ b/Assets/Scripts/Games/Fireworks/FireworksBomb.cs @@ -9,6 +9,7 @@ namespace HeavenStudio.Games.Scripts_Fireworks public class FireworksBomb : PlayerActionObject { public BezierCurve3D curve; + public bool applause; private bool exploded; private Fireworks game; private float startBeat; @@ -49,13 +50,14 @@ namespace HeavenStudio.Games.Scripts_Fireworks return; } - Success(); + Success(caller); } - void Success() + void Success(PlayerActionEvent caller) { Jukebox.PlayOneShotGame("fireworks/explodeBomb"); game.FadeFlashColor(Color.white, new Color(1, 1, 1, 0), 0.5f); + if (applause) Jukebox.PlayOneShot("applause", caller.timer + caller.startBeat + 1f); } void Out(PlayerActionEvent caller) { } diff --git a/Assets/Scripts/Games/Fireworks/Rocket.cs b/Assets/Scripts/Games/Fireworks/Rocket.cs index 4f526bdb..15d3f608 100644 --- a/Assets/Scripts/Games/Fireworks/Rocket.cs +++ b/Assets/Scripts/Games/Fireworks/Rocket.cs @@ -15,6 +15,7 @@ namespace HeavenStudio.Games.Scripts_Fireworks public bool isSparkler; private Fireworks game; public float startBeat; + public bool applause; private bool exploded; private float startY; @@ -54,14 +55,15 @@ namespace HeavenStudio.Games.Scripts_Fireworks anim.gameObject.SetActive(false); return; } - Success(); + Success(caller); } - void Success() + void Success(PlayerActionEvent caller) { Jukebox.PlayOneShotGame("fireworks/explodeRocket"); selectedParticleEffect.Play(); anim.gameObject.SetActive(false); + if (applause) Jukebox.PlayOneShot("applause", caller.timer + caller.startBeat + 1f); } void Out(PlayerActionEvent caller) { } diff --git a/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs b/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs index 65b2a4c9..21f82f76 100644 --- a/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs +++ b/Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs @@ -31,6 +31,15 @@ namespace HeavenStudio.Games.Loaders { function = delegate { RhythmSomen.instance.DoBell(eventCaller.currentEntity.beat); }, }, + new GameAction("bop", "Bop") + { + function = delegate { var e = eventCaller.currentEntity; RhythmSomen.instance.ToggleBop(e["toggle"]); }, + defaultLength = 0.5f, + parameters = new List() + { + new Param("toggle", false, "Bop?", "Should the somen man bop or not?") + } + } }); } } @@ -51,6 +60,7 @@ namespace HeavenStudio.Games public Animator CloseCrane; public Animator FarCrane; public GameObject Player; + private bool shouldBop = true; public GameEvent bop = new GameEvent(); @@ -66,7 +76,7 @@ namespace HeavenStudio.Games void Update() { var cond = Conductor.instance; - if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1)) + if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1) && shouldBop) { SomenPlayer.Play("HeadBob", -1, 0); } @@ -80,6 +90,11 @@ namespace HeavenStudio.Games } } + public void ToggleBop(bool bopOrNah) + { + shouldBop = bopOrNah; + } + public void DoFarCrane(float beat) { //Far Drop Multisound diff --git a/Assets/Scripts/Games/Ringside/Ringside.cs b/Assets/Scripts/Games/Ringside/Ringside.cs index d4b8b949..371c56b7 100644 --- a/Assets/Scripts/Games/Ringside/Ringside.cs +++ b/Assets/Scripts/Games/Ringside/Ringside.cs @@ -11,7 +11,7 @@ namespace HeavenStudio.Games.Loaders { public static Minigame AddGame(EventCaller eventCaller) { - return new Minigame("ringside", "Ringside \n[WIP]", "WUTRU3", false, false, new List() + return new Minigame("ringside", "Ringside", "WUTRU3", false, false, new List() { new GameAction("question", "Question") { diff --git a/Assets/Scripts/Games/SneakySpirits/SneakySpirits.cs b/Assets/Scripts/Games/SneakySpirits/SneakySpirits.cs index 725fac46..1b623384 100644 --- a/Assets/Scripts/Games/SneakySpirits/SneakySpirits.cs +++ b/Assets/Scripts/Games/SneakySpirits/SneakySpirits.cs @@ -29,6 +29,11 @@ namespace HeavenStudio.Games.Loaders new Param("volume7", new EntityTypes.Integer(0, 100, 100), "Move Volume 7", "What height and what volume should this move be at?"), } }, + new GameAction("forceReload", "Bow Force Reload") + { + function = delegate { SneakySpirits.instance.ForceReload(); }, + defaultLength = 1f, + }, new GameAction("movebow", "Bow Enter or Exit") { function = delegate {var e = eventCaller.currentEntity; SneakySpirits.instance.MoveBow(e.beat, e.length, e["exit"], e["ease"]); }, @@ -125,6 +130,13 @@ namespace HeavenStudio.Games } } + public void ForceReload() + { + if (hasArrowLoaded) return; + bowAnim.DoScaledAnimationAsync("BowDraw", 0.25f); + hasArrowLoaded = true; + } + public void MoveBow(float beat, float length, bool enter, int ease) { movingStartBeat = beat; @@ -180,7 +192,7 @@ namespace HeavenStudio.Games } BeatAction.New(instance.gameObject, new List() { - new BeatAction.Action(beat + length * 3, delegate { bowAnim.DoScaledAnimationAsync("BowDraw", 0.25f); hasArrowLoaded = true; }) + new BeatAction.Action(beat + length * 3, delegate { ForceReload(); }) }); List ghostSpawns = new List(); diff --git a/Assets/Scripts/Games/Tunnel/Tunnel.cs b/Assets/Scripts/Games/Tunnel/Tunnel.cs index 4871881a..73aceea3 100644 --- a/Assets/Scripts/Games/Tunnel/Tunnel.cs +++ b/Assets/Scripts/Games/Tunnel/Tunnel.cs @@ -14,31 +14,20 @@ namespace HeavenStudio.Games.Loaders { return new Minigame("tunnel", "Tunnel \n[WIP]", "B4E6F6", false, false, new List() { - - new GameAction("cowbell", "Cowbell") { - function = delegate { Tunnel.instance.StartCowbell(eventCaller.currentEntity.beat, eventCaller.currentEntity["toggle"], eventCaller.currentEntity.length); }, - defaultLength = 1f, + preFunction = delegate { Tunnel.PreStartCowbell(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, + defaultLength = 4f, resizable = true, - parameters = new List() - { - new Param("toggle", false, "Driver can stop", "Lets the driver stop if the player makes too many mistakes"), - } }, new GameAction("countin", "Count In") { - function = delegate { Tunnel.instance.CountIn(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, - defaultLength = 3f, + preFunction = delegate { Tunnel.CountIn(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, + defaultLength = 4f, resizable = true, } - - } - //new List() {"ntr", "aim"}, - //"ntrcoin", "en", - //new List() {} - ); + }); } } } @@ -47,11 +36,8 @@ namespace HeavenStudio.Games { public class Tunnel : Minigame { - public static Tunnel instance { get; set; } - - [Header("Backgrounds")] public SpriteRenderer fg; public SpriteRenderer bg; @@ -80,12 +66,22 @@ namespace HeavenStudio.Games public float handStart; public float handProgress; public bool started; + public struct QueuedCowbell + { + public float beat; + public float length; + } + static List queuedInputs = new List(); private void Awake() { instance = this; } + void OnDestroy() + { + if (queuedInputs.Count > 0) queuedInputs.Clear(); + } private void Start() { @@ -97,34 +93,30 @@ namespace HeavenStudio.Games { var cond = Conductor.instance; - if (cond.ReportBeat(ref cowbell.lastReportedBeat, cowbell.startBeat % 1)) + //update hand position + handProgress = Math.Min(Conductor.instance.songPositionInBeats - handStart, 1); + + + frontHand.transform.position = handCurve.GetPoint(EasingFunction.EaseOutQuad(0, 1, handProgress)); + if (!cond.isPlaying || cond.isPaused) { - if (cond.songPositionInBeats >= cowbell.startBeat && cond.songPositionInBeats < cowbell.startBeat + cowbell.length) - { - ScheduleInput(cond.songPositionInBeats, 1, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty); - } + return; } - - if (PlayerInput.Pressed() && !IsExpectingInputNow()) { HitCowbell(); //print("unexpected input"); driverAnimator.Play("Angry1", -1, 0); } + if (queuedInputs.Count > 0) + { + foreach (var input in queuedInputs) + { + StartCowbell(input.beat, input.length); + } + queuedInputs.Clear(); + } - - //update hand position - handProgress = Math.Min(Conductor.instance.songPositionInBeats - handStart, 1); - - - frontHand.transform.position = handCurve.GetPoint(EasingFunction.EaseOutQuad(0, 1, handProgress)); - - } - - private void LateUpdate() - { - //nothing } @@ -137,27 +129,32 @@ namespace HeavenStudio.Games cowbellAnimator.Play("Shake",-1,0); } - public void StartCowbell(float beat, bool driverStops, float length) + public static void PreStartCowbell(float beat, float length) + { + if (GameManager.instance.currentGame == "tunnel") + { + instance.StartCowbell(beat, length); + } + else + { + queuedInputs.Add(new QueuedCowbell { beat = beat, length = length }); + } + } + + public void StartCowbell(float beat, float length) { started = true; - - cowbell.length = length; - cowbell.startBeat = beat; - - - //for (int i = 1; i <= length; i++) - //{ - //ScheduleInput(beat, i, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty); - //} - - + for(int i = 0; i < length; i++) + { + ScheduleInput(beat, i, InputType.STANDARD_DOWN, CowbellSuccess, CowbellMiss, CowbellEmpty); + } } public void CowbellSuccess(PlayerActionEvent caller, float state) { HitCowbell(); //print(state); - if(Math.Abs(state) >= 0.5) + if(Math.Abs(state) >= 1f) { driverAnimator.Play("Disturbed", -1, 0); @@ -184,13 +181,13 @@ namespace HeavenStudio.Games - public void CountIn(float beat, float length) + public static void CountIn(float beat, float length) { List cuelist = new List(); - for (int i = 0; i <= length; i++) + for (int i = 0; i < length; i++) { if(i % 2 == 0) { @@ -206,7 +203,7 @@ namespace HeavenStudio.Games } } - MultiSound.Play(cuelist.ToArray()); + MultiSound.Play(cuelist.ToArray(), forcePlay: true); }