예제 #1
0
    private void Awake()
    {
        ModuleID = ModuleIDCounter++;

        foreach (KMSelectable Key in Keys)
        {
            Key.OnInteract += delegate()
            {
                if (!ModuleSolved && !Calculating)
                {
                    Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Key.transform);
                    Key.AddInteractionPunch(.4f);
                    Debug.LogFormat("[Kanji #{0}] You pressed '{1}'.", ModuleID, Key.GetComponentInChildren <TextMesh>().text);
                    var CorrectButton   = Combinations[ScreenText.text];
                    var SubmittedButton = Key.GetComponentInChildren <TextMesh>().text;
                    var Result          = CorrectButton == SubmittedButton;

                    if (Unicorn && SubmittedButton != "龍")
                    {
                        Debug.LogFormat("[Kanji #{0}] Unicorn was present but the wrong button was submitted!", ModuleID);
                        StartCoroutine(HandleStrike());
                        return(false);
                    }

                    if (Unicorn && SubmittedButton == "龍")
                    {
                        Debug.LogFormat("[Kanji #{0}] Unicorn! Congratulations!", ModuleID);
                        StartCoroutine(HandleSolve());
                        return(false);
                    }

                    if (!Result)
                    {
                        Debug.LogFormat("[Kanji #{0}] Incorrect! The required button was not pressed. The correct button was {1}. Strike issued and resetting stage...", ModuleID, CorrectButton);
                        StartCoroutine(HandleStrike());
                        return(false);
                    }

                    Stage += 1;
                    if (Stage == 4)
                    {
                        StartCoroutine(HandleSolve());
                    }
                    else
                    {
                        StartCoroutine(StageAdvanceAnimation());
                    }
                    return(false);
                }
                return(false);
            };
        }
    }