public static void TargetKey(CoderKey key) { instance.targetKey = key; if (instance.animation.isPlaying) { instance.animation.Stop(); } instance.animation.Play("AxeSwing-" + key.name); instance.knightAnim.SetBool("Swing", false); instance.knightAnim.SetBool("Swing", true); instance.knightAnim.SetBool("Swing", false); }
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 } }
private static void DeactivateKey(CoderKey key) { key.Deactivate(); //LastActiveKey = ActiveKey; ActiveKey = null; }
private static void ActivateKey(CoderKey key) { key.Activate(); ActiveKey = key; }