public static void InterpretKeyPress(CoderKey key) { if (key == BackspaceKey && ErrorCount > 0) { DeactivateKey(key); instance.audio.PlayOneShot(instance.typingSound); CoderOutput.DeleteError(); ErrorCount--; if (ErrorCount == 0) { ActivateKey(MissedActiveKey); } else { ActivateKey(BackspaceKey); } } else if (key == ActiveKey) { key.Deactivate(); instance.audio.PlayOneShot(instance.typingSound); CoderOutput.PrintLine(); CoderScoreboard.GetPoint(); ActivateKey(PickRandomKeyNoRepeats()); } else { if (ErrorCount == 0) { // If not backspace, save it for later MissedActiveKey = ActiveKey; } DeactivateKey(ActiveKey); instance.audio.PlayOneShot(instance.errorSound); CoderOutput.PrintError(); ActivateKey(BackspaceKey); ErrorCount = 1; // Track all errors with single boolean // ErrorCount++; // Track each error individually } }
public static void EndLevel() { if (!LevelEnded) { instance.levelEnded = true; CoderCountdown.StopStopWatch(); CoderKeyboard.DeactivateAllKeys(); CoderStatusText.DisplayResults(CoderScoreboard.GetLevel()); CoderMusicPlayer.StopMusic(); if (CoderScoreboard.GetLevel() == "fail") { instance.audio.PlayOneShot(instance.loseSound); } else { instance.audio.PlayOneShot(instance.winSound); } instance.exitButton.SetActive(true); } }
//public GameObject goldMedal, silverMedal, bronzeMedal; void Awake() { instance = this; }