From 687f2b53f445b331cd96a8b007231dbbfd955faf Mon Sep 17 00:00:00 2001 From: Carson Kompon Date: Tue, 1 Mar 2022 02:27:49 -0500 Subject: [PATCH] Added Checkbox Parameter + Toggle Inputs Event So now you can disable inputs if you need to :) --- Assets/Scripts/Beatmap.cs | 1 + Assets/Scripts/GameManager.cs | 7 +++++++ Assets/Scripts/Games/PlayerActionObject.cs | 2 +- Assets/Scripts/Games/SpaceSoccer/Kicker.cs | 2 +- .../EventSelector/EventParameterManager.cs | 5 +++++ .../EventSelector/EventPropertyPrefab.cs | 13 +++++++++++++ Assets/Scripts/Minigames.cs | 7 +++++++ Assets/Scripts/PlayerInput.cs | 13 +++++++------ 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Beatmap.cs b/Assets/Scripts/Beatmap.cs index c52efa68..ed9b5849 100644 --- a/Assets/Scripts/Beatmap.cs +++ b/Assets/Scripts/Beatmap.cs @@ -25,6 +25,7 @@ namespace RhythmHeavenMania [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valA; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valB; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public float valC; + [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 EasingFunction.Ease ease; diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 159633c5..dac3fdd6 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -36,6 +36,7 @@ namespace RhythmHeavenMania public float startBeat; [NonSerialized] public GameObject currentGameO; public bool autoplay; + public bool canInput = true; public event Action onBeatChanged; @@ -195,10 +196,16 @@ namespace RhythmHeavenMania } } + public void ToggleInputs(bool inputs) + { + canInput = inputs; + } + #region Play Events public void Play(float beat) { + canInput = true; StartCoroutine(PlayCo(beat)); onBeatChanged?.Invoke(beat); } diff --git a/Assets/Scripts/Games/PlayerActionObject.cs b/Assets/Scripts/Games/PlayerActionObject.cs index ba53a092..7de8c723 100644 --- a/Assets/Scripts/Games/PlayerActionObject.cs +++ b/Assets/Scripts/Games/PlayerActionObject.cs @@ -33,7 +33,7 @@ namespace RhythmHeavenMania.Games { if (aceTimes == 0) { - if (triggersAutoplay && (GameManager.instance.autoplay || autoPlay) && normalizedBeat > 0.99f) + if (triggersAutoplay && (GameManager.instance.autoplay || autoPlay) && GameManager.instance.canInput && normalizedBeat > 0.99f) { OnAce(); if (!autoPlay) diff --git a/Assets/Scripts/Games/SpaceSoccer/Kicker.cs b/Assets/Scripts/Games/SpaceSoccer/Kicker.cs index 339aaad3..93408070 100644 --- a/Assets/Scripts/Games/SpaceSoccer/Kicker.cs +++ b/Assets/Scripts/Games/SpaceSoccer/Kicker.cs @@ -358,7 +358,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer private void CheckIfFall(float normalizedBeat) { - if (normalizedBeat > Minigame.LateTime() && !GameManager.instance.autoplay) + if (normalizedBeat > Minigame.LateTime() && (!GameManager.instance.autoplay || !GameManager.instance.canInput)) { Jukebox.PlayOneShotGame("spaceSoccer/missNeutral"); ball = null; diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs index c828eacb..1fdafe94 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs @@ -15,6 +15,7 @@ namespace RhythmHeavenMania.Editor [Header("Property Prefabs")] [SerializeField] private GameObject IntegerP; [SerializeField] private GameObject FloatP; + [SerializeField] private GameObject BooleanP; [SerializeField] private GameObject DropdownP; [SerializeField] private GameObject ColorP; @@ -106,6 +107,10 @@ namespace RhythmHeavenMania.Editor { prefab = FloatP; } + else if(type is bool) + { + prefab = BooleanP; + } else if (objType.IsEnum) { prefab = DropdownP; diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs index ce4fc5ff..642857b2 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs @@ -21,6 +21,10 @@ namespace RhythmHeavenMania.Editor public Slider slider; public TMP_InputField inputField; + [Header("Boolean")] + [Space(10)] + public Toggle toggle; + [Header("Dropdown")] [Space(10)] public TMP_Dropdown dropdown; @@ -86,6 +90,15 @@ namespace RhythmHeavenMania.Editor parameterManager.entity[propertyName] = slider.value; }); } + else if(type is bool) + { + toggle.isOn = (bool)type; + + toggle.onValueChanged.AddListener(delegate + { + parameterManager.entity[propertyName] = toggle.isOn; + }); + } else if (objType.IsEnum) { List dropDownData = new List(); diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 72e0798a..fbabb3e9 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -105,6 +105,13 @@ namespace RhythmHeavenMania new Param("valB", new EntityTypes.Float(0, 1, 0), "End Opacity"), new Param("ease", EasingFunction.Ease.Linear, "Ease") } ), + new GameAction("toggle inputs", delegate + { + GameManager.instance.ToggleInputs(eventCaller.currentEntity.toggle); + }, 0.5f, true, new List() + { + new Param("toggle", true, "Enable Inputs") + }), }), new Minigame("countIn", "Count-Ins", "", false, true, new List() { diff --git a/Assets/Scripts/PlayerInput.cs b/Assets/Scripts/PlayerInput.cs index fba3208f..768d5cec 100644 --- a/Assets/Scripts/PlayerInput.cs +++ b/Assets/Scripts/PlayerInput.cs @@ -6,38 +6,39 @@ namespace RhythmHeavenMania { public class PlayerInput { + public static bool Pressed(bool includeDPad = false) { bool keyDown = Input.GetKeyDown(KeyCode.Z) || (includeDPad && GetAnyDirectionDown()); - return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput ; } public static bool PressedUp(bool includeDPad = false) { bool keyUp = Input.GetKeyUp(KeyCode.Z) || (includeDPad && GetAnyDirectionUp()); - return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; } public static bool Pressing(bool includeDPad = false) { bool pressing = Input.GetKey(KeyCode.Z) || (includeDPad && GetAnyDirection()); - return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; } public static bool AltPressed() { - return Input.GetKeyDown(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + return Input.GetKeyDown(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; } public static bool AltPressedUp() { - return Input.GetKeyUp(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + return Input.GetKeyUp(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; } public static bool AltPressing() { - return Input.GetKey(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying; + return Input.GetKey(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput; } public static bool GetAnyDirectionDown()