void Awake() { moduleId = moduleIdCounter++; for (int i = 0; i < ArrowsAndCircle.Length; i++) { int Press = i; ArrowsAndCircle[i].OnInteract += delegate() { StartCoroutine(PressButton(Press)); return(false); }; } for (int x = 0; x < BallColors.Length; x++) { int Press = x; BallColors[x].GetComponent <KMSelectable>().OnInteract += delegate() { BallPress(Press); return(false); }; } BallHold.GetComponent <KMSelectable>().OnInteract += delegate() { Hold = StartCoroutine(HoldBallCoroutine()); return(false); }; BallHold.GetComponent <KMSelectable>().OnInteractEnded += delegate() { StopCoroutine(Hold); StartCoroutine(Toss()); }; }
IEnumerator TwitchHandleForcedSolve() { if (IncorrectAnswer) { StopAllCoroutines(); Everything1.SetActive(false); Everything2.SetActive(true); BallHold.SetActive(false); Audio.PlaySoundAtTransform(SFX[1].name, transform); Module.HandlePass(); TextAndShadow[0].text = "Hole In One"; TextAndShadow[1].text = "Hole In One"; yield break; } if (!Checking) { if (!Clicked) { while (StickNum != (GatheredNumber % 5)) { if (StickNum < (GatheredNumber % 5)) { ArrowsAndCircle[2].OnInteract(); yield return(new WaitForSecondsRealtime(0.1f)); } else if (StickNum > (GatheredNumber % 5)) { ArrowsAndCircle[0].OnInteract(); yield return(new WaitForSecondsRealtime(0.1f)); } } ArrowsAndCircle[1].OnInteract(); } if (!AbleToHillBall) { while (!Pressable) { yield return(true); } BallColors[BallValue].GetComponent <KMSelectable>().OnInteract(); yield return(new WaitForSecondsRealtime(0.1f)); } BallHold.GetComponent <KMSelectable>().OnInteract(); while (HoldValue != PowerNeeded + 1) { yield return(null); } BallHold.GetComponent <KMSelectable>().OnInteractEnded(); } while (Checking) { yield return(true); } }
IEnumerator Toss() { Checking = true; if (HoldValue != PowerNeeded + 1) { IncorrectAnswer = true; } Audio.PlaySoundAtTransform(SFX[0].name, transform); AbleToHillBall = false; Debug.LogFormat("[Hole in One #{0}] You hit the ball with a power level of {1}", moduleId, HoldValue != 27 ? HoldValue.ToString() : "???"); BallHold.GetComponent <KMSelectable>().AddInteractionPunch(((float)HoldValue / 10f)); BallHold.SetActive(false); yield return(new WaitForSecondsRealtime(3f)); if (IncorrectAnswer) { Debug.LogFormat("[Hole in One #{0}] You did something incorrectly. The module striked and performed a reset.", moduleId); Audio.PlaySoundAtTransform(SFX[3].name, transform); yield return(new WaitForSecondsRealtime(0.75f)); Module.HandleStrike(); HoldValue = 0; TextAndShadow[0].text = "Power: 0"; TextAndShadow[1].text = "Power: 0"; BallHold.SetActive(true); Clicked = false; IncorrectAnswer = false; Start(); Proceed(); } else { Debug.LogFormat("[Hole in One #{0}] You did everything correctly. The module solved.", moduleId); Audio.PlaySoundAtTransform(SFX[2].name, transform); yield return(new WaitForSecondsRealtime(0.75f)); Audio.PlaySoundAtTransform(SFX[1].name, transform); Module.HandlePass(); TextAndShadow[0].text = "Hole In One"; TextAndShadow[1].text = "Hole In One"; } Checking = false; }
void BallPress(int Press) { BallColors[Press].GetComponent <KMSelectable>().AddInteractionPunch(0.2f); if (Pressable) { Debug.LogFormat("[Hole in One #{0}] You used Golf Ball #{1}", moduleId, (Press + 1).ToString()); Audio.PlaySoundAtTransform(SFX[4].name, transform); if (Press != BallValue) { IncorrectAnswer = true; } BallHold.GetComponent <MeshRenderer>().material.color = BallColors[Press].GetComponent <MeshRenderer>().material.color; Everything1.SetActive(false); Everything2.SetActive(true); if (Bomb.GetSerialNumberNumbers().Last() % 2 == 0) { Debug.LogFormat("[Hole in One #{0}] The last digit of the serial is even. You must perform the Caesar shift forwards.", moduleId); Debug.LogFormat("[Hole in One #{0}] The focused letter is {1}", moduleId, numberTable[BallValue, StoredValue % 5]); PowerNeeded = (Array.IndexOf(Alphabreak, numberTable[BallValue, StoredValue % 5]) + StoredValue) % 26; Debug.LogFormat("[Hole in One #{0}] After performing the Caesar shift, the current letter must be the letter \"{1}\"", moduleId, Alphabreak[PowerNeeded]); PowerNeeded = 25 - PowerNeeded; Debug.LogFormat("[Hole in One #{0}] After performing the Atbash cipher, the correct letter must be \"{1}\"", moduleId, Alphabreak[PowerNeeded]); Debug.LogFormat("[Hole in One #{0}] You must hit the ball when the power level is {1}", moduleId, (PowerNeeded + 1).ToString()); } else { Debug.LogFormat("[Hole in One #{0}] The last digit of the serial is odd. You must perform the Caesar shift backwards.", moduleId); Debug.LogFormat("[Hole in One #{0}] The focused letter is {1}", moduleId, numberTable[BallValue, StoredValue % 5]); PowerNeeded = Array.IndexOf(Alphabreak, numberTable[BallValue, StoredValue % 5]) - StoredValue; while (PowerNeeded < 0) { PowerNeeded += 26; } Debug.LogFormat("[Hole in One #{0}] After performing the Caesar shift, the current letter must be the letter \"{1}\"", moduleId, Alphabreak[PowerNeeded]); PowerNeeded = 25 - PowerNeeded; Debug.LogFormat("[Hole in One #{0}] After performing the Atbash cipher, the correct letter must be \"{1}\"", moduleId, Alphabreak[PowerNeeded]); Debug.LogFormat("[Hole in One #{0}] You must hit the ball when the power level is {1}", moduleId, (PowerNeeded + 1).ToString()); } Pressable = false; AbleToHillBall = true; } }
IEnumerator ProcessTwitchCommand(string command) { string[] parameters = command.Split(' '); if (Regex.IsMatch(command, @"^\s*right\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) { yield return(null); if (Clicked) { yield return("sendtochaterror You are unable to perform this currently. The command was not processed."); yield break; } ArrowsAndCircle[2].OnInteract(); } if (Regex.IsMatch(command, @"^\s*select\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) { yield return(null); if (Clicked) { yield return("sendtochaterror You are unable to perform this currently. The command was not processed."); yield break; } ArrowsAndCircle[1].OnInteract(); } if (Regex.IsMatch(command, @"^\s*left\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) { yield return(null); if (Clicked) { yield return("sendtochaterror You are unable to perform this currently. The command was not processed."); yield break; } ArrowsAndCircle[0].OnInteract(); } if (Regex.IsMatch(parameters[0], @"^\s*ball\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) { yield return(null); if (!Pressable) { yield return("sendtochaterror You are unable to perform this currently. The command was not processed."); yield break; } if (parameters.Length != 2) { yield return("sendtochaterror Invalid parameter length. The command was not processed."); yield break; } if (!parameters[1].EqualsAny(ValidNumbers)) { yield return("sendtochaterror Ball number being selected was invalid. The command was not processed."); yield break; } BallColors[Int32.Parse(parameters[1]) - 1].GetComponent <KMSelectable>().OnInteract(); } if (Regex.IsMatch(parameters[0], @"^\s*hit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) { yield return(null); if (!AbleToHillBall) { yield return("sendtochaterror You are unable to perform this currently. The command was not processed."); yield break; } if (parameters.Length != 2) { yield return("sendtochaterror Invalid parameter length. The command was not processed."); yield break; } if (parameters[1].Length > 2) { yield return("sendtochaterror Number will never reach longer than 3 digits. The command was not processed."); yield break; } int Out; if (!Int32.TryParse(parameters[1], out Out)) { yield return("sendtochaterror Number being sent was invalid. The command was not processed."); yield break; } if (Out < 1 || Out > 26) { yield return("sendtochaterror Number being sent was not between 1-26. The command was not processed."); yield break; } BallHold.GetComponent <KMSelectable>().OnInteract(); while (HoldValue != Out) { yield return(null); } BallHold.GetComponent <KMSelectable>().OnInteractEnded(); if (IncorrectAnswer) { yield return("strike"); } else { yield return("solve"); } } }