From 5c46e64fc0708e6e9036780fdbc33965356f03c3 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Fri, 19 Jan 2024 23:05:26 -0500 Subject: [PATCH] fix #631 --- .../Games/FirstContact/FirstContact.cs | 60 ++++++++----------- ...PlayerInput.ControllerLoaderGenerator.g.cs | 2 + .../ControllerLoaderGenerator.cs | 2 + ...Generator.Editor.ProjectSettingsData.asset | 3 + 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/Assets/Scripts/Games/FirstContact/FirstContact.cs b/Assets/Scripts/Games/FirstContact/FirstContact.cs index be4e8bf6..06da55d6 100644 --- a/Assets/Scripts/Games/FirstContact/FirstContact.cs +++ b/Assets/Scripts/Games/FirstContact/FirstContact.cs @@ -316,17 +316,24 @@ namespace HeavenStudio.Games if (PlayerInput.GetIsAction(InputAction_Press) && !IsExpectingInputNow(InputAction_Press)) { - translator.DoScaledAnimationAsync("translator_eh", 0.5f); if (isSpeaking) { - if (callDiagIndex == 0) + if (noHitOnce || callDiagIndex == 0) + { FailContact(); + } else + { + SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-3, 3), false)); TrailingContact(); + ScoreMiss(); + } } else if (!noHitOnce && !missionControl.activeInHierarchy) { + translator.DoScaledAnimationAsync("translator_eh", 0.5f); SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_MISS2_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-2, 1), false)); + ScoreMiss(); } } } @@ -414,7 +421,7 @@ namespace HeavenStudio.Games { var input = inputs[i]; double relativeBeat = input.beat - intervalBeat; - ScheduleInput(beat, length + relativeBeat, InputAction_Press, AlienTapping, AlienOnMiss, AlienEmpty); + ScheduleInput(beat, length + relativeBeat, InputAction_Press, AlienTapping, AlienOnMiss, AlienEmpty, CanAlienTapping); callDiagList.Add((input["dialogue"], input["newline"])); } BeatAction.New(this, new List() @@ -422,6 +429,7 @@ namespace HeavenStudio.Games new BeatAction.Action(beat, delegate { isSpeaking = true; + hasMissed = false; SoundByte.PlayOneShotGame("firstContact/turnover"); alienTextbox.SetActive(false); alien.Play("alien_point", 0, 0); @@ -582,56 +590,38 @@ namespace HeavenStudio.Games hasMissed = true; } + public bool CanAlienTapping() + { + return !(hasMissed || noHitOnce); + } + public void AlienTapping(PlayerActionEvent caller, float state) //OnHit { - if (hasMissed && callDiagIndex == 0) + (string dialogue, bool showNewline) = callDiagList[callDiagIndex]; + translateTextbox.SetActive(true); + if (showNewline) { - caller.isEligible = false; - ScoreMiss(); - return; - }; - - if (noHitOnce) - { - caller.isEligible = false; - FailContact(); - return; + ResetTranslateTextbox(true); } - if (state >= 1f || state <= -1f) { SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-3, 3), false)); - translator.DoScaledAnimationAsync("translator_speak", 0.5f); - if (callDiagIndex == 0) return; TrailingContact(); + callDiagIndex++; return; } translator.DoScaledAnimationAsync("translator_speak", 0.5f); SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-3, 3), false)); SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_B"); - if (hasMissed) - { - caller.isEligible = false; - return; - } - else - { - (string dialogue, bool showNewline) = callDiagList[callDiagIndex]; - if (showNewline) - { - ResetTranslateTextbox(true); - } - respDiagBuffer += dialogue; - translateTextbox.SetActive(true); - UpdateTranslateTextbox(); - callDiagIndex++; - } + respDiagBuffer += dialogue; + UpdateTranslateTextbox(); + callDiagIndex++; } public void AlienOnMiss(PlayerActionEvent caller) //OnMiss { - if (!noHitOnce) + if (!noHitOnce && !hasMissed) { SoundByte.PlayOneShotGame("firstContact/alienNoHit"); noHitOnce = true; diff --git a/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs b/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs index 0dece7f9..c1e067ac 100644 --- a/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs +++ b/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs @@ -18,8 +18,10 @@ namespace HeavenStudio public static int InitInputControllers() { + inputDevices = new List(); InputController[] controllers; PlayerInputRefresh = new(); + PlayerInputCleanUp = null; controllers = InputJoyshockInitializer.Initialize(); if (controllers != null) diff --git a/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs b/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs index 488835cc..e7a8618e 100644 --- a/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs +++ b/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs @@ -80,8 +80,10 @@ namespace {context.TargetClass.Namespace} sb.IndentLevel(3); sb.Append($@" + inputDevices = new List(); InputController[] controllers; PlayerInputRefresh = new(); + PlayerInputCleanUp = null; "); foreach (var loadRunner in loadRunners) diff --git a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset index 31be55a4..4390d956 100644 --- a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset +++ b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset @@ -26,5 +26,8 @@ MonoBehaviour: - Assets/Editor/SpritesheetScaler.cs - Assets/Scripts/USG.g/LoadMinigames.Minigames.MinigameLoaderGenerator.g.cs - Assets/Scripts/Games/TheDazzles/TheDazzles.cs + - Assets/Scripts/Games/FirstContact/FirstContact.cs + - Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs + - Assets/Scripts/InputSystem/PlayerInput.cs PathsToSkipImportEvent: [] PathsToIgnoreOverwriteSettingOnAttribute: []