From 8960d9da5572b86eb5337684070fea820ca98b84 Mon Sep 17 00:00:00 2001 From: Slaith <34562469+Slaith12@users.noreply.github.com> Date: Sun, 27 Mar 2022 11:13:13 -0700 Subject: [PATCH 1/2] Allowed lion count and mii faces to be set before game switches and fixed some bugs from last pr I went through every single game script to look for bugs in intialization, there shouldn't be anything else that was caused by the pr (there is a bug in Spaceball where a ball cue won't trigger correctly if it's on the same beat as the switch, but i'm not sure how to fix it) --- Assets/Scripts/GameManager.cs | 9 +-------- Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs | 8 ++++++++ .../Games/DrummingPractice/DrummingPractice.cs | 8 ++++++-- Assets/Scripts/Games/KarateMan/KarateMan.cs | 1 + Assets/Scripts/Games/KarateMan/Pot.cs | 7 ++----- Assets/Scripts/Games/WizardsWaltz/WizardsWaltz.cs | 14 +++++--------- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index bf16ac11..809eedd9 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -345,8 +345,6 @@ namespace HeavenStudio SetGame(game); - yield return new WaitForEndOfFrame(); //this is needed so that the minigame can have Start() called before OnGameSwitch() - Minigame miniGame = currentGameO.GetComponent(); if (miniGame != null) miniGame.OnGameSwitch(beat); @@ -356,7 +354,7 @@ namespace HeavenStudio this.GetComponent().enabled = false; } - private void SetGame(string game, bool onGameSwitch = true) + private void SetGame(string game) { Destroy(currentGameO); @@ -385,11 +383,6 @@ namespace HeavenStudio currentGameO.transform.parent = eventCaller.GamesHolder.transform; currentGameO.name = game; } - /*if (onGameSwitch) - { - if (GetGame(currentGame).GetComponent() != null) - GetGame(game).GetComponent().OnGameSwitch(); - }*/ SetCurrentGame(game); diff --git a/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs index 0cd83ade..f31ec61e 100644 --- a/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs +++ b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs @@ -32,6 +32,14 @@ namespace HeavenStudio.Games instance = this; InitLions(); } + public override void OnGameSwitch(float beat) + { + Beatmap.Entity changeLion = GameManager.instance.Beatmap.entities.FindLast(c => c.datamodel == "clappyTrio/change lion count" && c.beat <= beat); + if(changeLion != null) + { + EventCaller.instance.CallEvent(changeLion, true); + } + } private void InitLions() { diff --git a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs index 6df2d10e..453d65c2 100644 --- a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs +++ b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs @@ -46,9 +46,13 @@ namespace HeavenStudio.Games SetMiis(); } - public void OnGameSwitch() + public override void OnGameSwitch(float beat) { - SetMiis(); + Beatmap.Entity changeMii = GameManager.instance.Beatmap.entities.FindLast(c => c.datamodel == "drummingPractice/set mii" && c.beat <= beat); + if(changeMii != null) + { + EventCaller.instance.CallEvent(changeMii, true); + } } private void Update() diff --git a/Assets/Scripts/Games/KarateMan/KarateMan.cs b/Assets/Scripts/Games/KarateMan/KarateMan.cs index 3e469f91..088ddf41 100644 --- a/Assets/Scripts/Games/KarateMan/KarateMan.cs +++ b/Assets/Scripts/Games/KarateMan/KarateMan.cs @@ -256,6 +256,7 @@ namespace HeavenStudio.Games Jukebox.PlayOneShotGame(outSnd); } + p.Init(); } List cuedVoices = new List(); // "Hit" voices cued in advance are stored here so they aren't called multiple times in Update(). diff --git a/Assets/Scripts/Games/KarateMan/Pot.cs b/Assets/Scripts/Games/KarateMan/Pot.cs index 2aa47ef4..bed773b0 100644 --- a/Assets/Scripts/Games/KarateMan/Pot.cs +++ b/Assets/Scripts/Games/KarateMan/Pot.cs @@ -56,7 +56,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan private int missTimes = 0; - private void Awake() + public void Init() { anim = GetComponent(); spriteComp = Sprite.GetComponent(); @@ -66,10 +66,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan Sprite.transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360)); BulbLightSprite.transform.eulerAngles = Sprite.transform.eulerAngles; - if (type == 2) - hitLength = 14f; - else - hitLength = 14f; + hitLength = 14f; if (type == 6) CookingPotLid.SetActive(true); diff --git a/Assets/Scripts/Games/WizardsWaltz/WizardsWaltz.cs b/Assets/Scripts/Games/WizardsWaltz/WizardsWaltz.cs index 7e864394..b66d7830 100644 --- a/Assets/Scripts/Games/WizardsWaltz/WizardsWaltz.cs +++ b/Assets/Scripts/Games/WizardsWaltz/WizardsWaltz.cs @@ -27,7 +27,7 @@ namespace HeavenStudio.Games bool intervalStarted; public float wizardBeatOffset = 0f; - [NonSerialized] public int plantsLeft = 0; + [NonSerialized] public int plantsLeft = 0; //this variable is unused public static WizardsWaltz instance; @@ -35,16 +35,12 @@ namespace HeavenStudio.Games { instance = this; wizard.Init(); - } - private void Start() - { - List starts = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "wizardsWaltz/start interval").Select(c => c.beat).ToList(); + Beatmap.Entity nextStart = GameManager.instance.Beatmap.entities.Find(c => c.datamodel == "wizardsWaltz/start interval" && c.beat + c.length >= Conductor.instance.songPositionInBeats); - if (starts.Count > 0) + if (nextStart != null) { - var nextInterval = starts.IndexOf(Mathp.GetClosestInList(starts, Conductor.instance.songPositionInBeats)); - wizardBeatOffset = starts[nextInterval]; + EventCaller.instance.CallEvent(nextStart, true); } } @@ -64,7 +60,7 @@ namespace HeavenStudio.Games var am = beatInterval / 2f; var x = Mathf.Sin(Mathf.PI * songPos / am) * 6 + UnityEngine.Random.Range(-0.5f, 0.5f); var y = Mathf.Cos(Mathf.PI * songPos / am) * 0.5f + UnityEngine.Random.Range(-0.5f, 0.5f); - var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f + UnityEngine.Random.Range(-0.2f, 0.2f); ; + var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f + UnityEngine.Random.Range(-0.2f, 0.2f); MagicFX magic = Instantiate(fxBase, fxHolder.transform).GetComponent(); From 71e4e9c1f6f89a25e4517bd5ae73c9f601426103 Mon Sep 17 00:00:00 2001 From: Slaith <34562469+Slaith12@users.noreply.github.com> Date: Sun, 27 Mar 2022 18:23:59 -0700 Subject: [PATCH 2/2] Fixed barrel break not working --- Assets/Scripts/Games/KarateMan/BarrelDestroyEffect.cs | 2 +- Assets/Scripts/Games/KarateMan/Pot.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Games/KarateMan/BarrelDestroyEffect.cs b/Assets/Scripts/Games/KarateMan/BarrelDestroyEffect.cs index 6eba7d93..31521bb6 100644 --- a/Assets/Scripts/Games/KarateMan/BarrelDestroyEffect.cs +++ b/Assets/Scripts/Games/KarateMan/BarrelDestroyEffect.cs @@ -20,7 +20,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan public GameObject shadow; - private void Awake() + public void Init() { SpriteRenderer = this.gameObject.GetComponent(); SpriteRenderer.sprite = KarateMan.instance.BarrelSprites[spriteIndex]; diff --git a/Assets/Scripts/Games/KarateMan/Pot.cs b/Assets/Scripts/Games/KarateMan/Pot.cs index bed773b0..507c13eb 100644 --- a/Assets/Scripts/Games/KarateMan/Pot.cs +++ b/Assets/Scripts/Games/KarateMan/Pot.cs @@ -410,6 +410,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan bde.spriteIndex = 4; break; } + bde.Init(); } } }