From 5cf22550229a18332e33b6aea66629abf815500b Mon Sep 17 00:00:00 2001 From: minenice55 Date: Fri, 11 Mar 2022 13:20:24 -0500 Subject: [PATCH 1/3] Drumming Practice: individually set each mii note: had to add a third integer value to the Beatmap parameters, may wanna consider using some kind of array in the future --- Assets/Scripts/Beatmap.cs | 3 ++ .../Scripts/Games/DrummingPractice/Drummer.cs | 3 ++ .../DrummingPractice/DrummingPractice.cs | 39 ++++++++++++++----- Assets/Scripts/Minigames.cs | 8 ++-- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Beatmap.cs b/Assets/Scripts/Beatmap.cs index ed9b5849..0fa4c5d1 100644 --- a/Assets/Scripts/Beatmap.cs +++ b/Assets/Scripts/Beatmap.cs @@ -21,6 +21,8 @@ namespace RhythmHeavenMania { public float beat; public int track; + + // consideration: use arrays instead of hardcoding fixed parameter names [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float length; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valA; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valB; @@ -28,6 +30,7 @@ namespace RhythmHeavenMania [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public bool toggle; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type2; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int type3; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public EasingFunction.Ease ease; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorA; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public Color colorB; diff --git a/Assets/Scripts/Games/DrummingPractice/Drummer.cs b/Assets/Scripts/Games/DrummingPractice/Drummer.cs index f6a7c38e..01d344c3 100644 --- a/Assets/Scripts/Games/DrummingPractice/Drummer.cs +++ b/Assets/Scripts/Games/DrummingPractice/Drummer.cs @@ -23,6 +23,9 @@ namespace RhythmHeavenMania.Games.DrummingPractice private bool hitting = false; + // in the future: use the MiiStudio API to render any mii from a nintendo account / MNMS / Mii Studio code? + // figure out how to call the API from unity? + // used expressions: "normal", "smile", "sorrow" [System.Serializable] public class MiiFace { diff --git a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs index f6fb732d..265a243a 100644 --- a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs +++ b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs @@ -12,6 +12,7 @@ namespace RhythmHeavenMania.Games.DrummingPractice { public enum MiiType { + Random = -1, GuestA, GuestB, GuestC, @@ -96,27 +97,47 @@ namespace RhythmHeavenMania.Games.DrummingPractice rightDrummer.SetFace(type); } - public void SetMiis(int playerFace, bool all = false) + public void SetMiis(int playerFace, int leftFace = -1, int rightFace = -1, bool all = false) { - player.mii = playerFace; + if (playerFace == -1) + { + do + { + player.mii = UnityEngine.Random.Range(0, player.miiFaces.Count); + } + while (player.mii == leftFace || player.mii == rightFace); + } + else + player.mii = playerFace; - if (all) + if (all && playerFace != -1) { leftDrummer.mii = playerFace; rightDrummer.mii = playerFace; } else { - do + if (leftFace == -1) { - leftDrummer.mii = UnityEngine.Random.Range(0, leftDrummer.miiFaces.Count); + do + { + leftDrummer.mii = UnityEngine.Random.Range(0, player.miiFaces.Count); + } + while (leftDrummer.mii == player.mii); } - while (leftDrummer.mii == player.mii); - do + else + leftDrummer.mii = leftFace; + + if (rightFace == -1) { - rightDrummer.mii = UnityEngine.Random.Range(0, rightDrummer.miiFaces.Count); + do + { + rightDrummer.mii = UnityEngine.Random.Range(0, player.miiFaces.Count); + } + while (rightDrummer.mii == leftDrummer.mii || rightDrummer.mii == player.mii); } - while (rightDrummer.mii == leftDrummer.mii || rightDrummer.mii == player.mii); + else + rightDrummer.mii = rightFace; } SetFaces(0); diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 8fd7d84e..047ae6b3 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -413,10 +413,12 @@ namespace RhythmHeavenMania { new Param("toggle", true, "Applause", "Whether or not an applause should be played on a successful hit") }), - new GameAction("set mii", delegate { var e = eventCaller.currentEntity; DrummingPractice.instance.SetMiis(e.type, e.toggle); }, 0.5f, parameters: new List() + new GameAction("set mii", delegate { var e = eventCaller.currentEntity; DrummingPractice.instance.SetMiis(e.type, e.type2, e.type3, e.toggle); }, 0.5f, parameters: new List() { - new Param("type", DrummingPractice.MiiType.GuestA, "Mii", "The Mii that the player will control"), - new Param("toggle", false, "Set All", "Whether all Miis should be set") + new Param("type", DrummingPractice.MiiType.Random, "Player Mii", "The Mii that the player will control"), + new Param("type2", DrummingPractice.MiiType.Random, "Left Mii", "The Mii that the player will control"), + new Param("type3", DrummingPractice.MiiType.Random, "Right Mii", "The Mii that the player will control"), + new Param("toggle", false, "Set All to Player", "Sets all Miis to the Player's Mii") }), }), From b506c8f4522276e22998acdd9ab9c9b62771f7b8 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Fri, 11 Mar 2022 13:24:24 -0500 Subject: [PATCH 2/3] de-hardcode conditional --- .../Scripts/Games/DrummingPractice/DrummingPractice.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs index 265a243a..ec2623b3 100644 --- a/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs +++ b/Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs @@ -44,7 +44,7 @@ namespace RhythmHeavenMania.Games.DrummingPractice // TODO: Move this to OnGameSwitch() when functional? private void Start() { - SetMiis(UnityEngine.Random.Range(0, player.miiFaces.Count)); + SetMiis(); } private void Update() @@ -97,9 +97,9 @@ namespace RhythmHeavenMania.Games.DrummingPractice rightDrummer.SetFace(type); } - public void SetMiis(int playerFace, int leftFace = -1, int rightFace = -1, bool all = false) + public void SetMiis(int playerFace = (int) MiiType.Random, int leftFace = (int) MiiType.Random, int rightFace = (int) MiiType.Random, bool all = false) { - if (playerFace == -1) + if (playerFace == (int) MiiType.Random) { do { @@ -117,7 +117,7 @@ namespace RhythmHeavenMania.Games.DrummingPractice } else { - if (leftFace == -1) + if (leftFace == (int) MiiType.Random) { do { @@ -128,7 +128,7 @@ namespace RhythmHeavenMania.Games.DrummingPractice else leftDrummer.mii = leftFace; - if (rightFace == -1) + if (rightFace == (int) MiiType.Random) { do { From 07074783af7d0acb78ee4e987fe3dde6bdf6f709 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Fri, 11 Mar 2022 13:27:35 -0500 Subject: [PATCH 3/3] correct descriptions --- Assets/Scripts/Minigames.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 047ae6b3..3b739174 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -416,8 +416,8 @@ namespace RhythmHeavenMania new GameAction("set mii", delegate { var e = eventCaller.currentEntity; DrummingPractice.instance.SetMiis(e.type, e.type2, e.type3, e.toggle); }, 0.5f, parameters: new List() { new Param("type", DrummingPractice.MiiType.Random, "Player Mii", "The Mii that the player will control"), - new Param("type2", DrummingPractice.MiiType.Random, "Left Mii", "The Mii that the player will control"), - new Param("type3", DrummingPractice.MiiType.Random, "Right Mii", "The Mii that the player will control"), + new Param("type2", DrummingPractice.MiiType.Random, "Left Mii", "The Mii on the left"), + new Param("type3", DrummingPractice.MiiType.Random, "Right Mii", "The Mii on the right"), new Param("toggle", false, "Set All to Player", "Sets all Miis to the Player's Mii") }),