コード例 #1
0
    //check the answer and update the screen
    public void CheckAnswer(string input)
    {
        //first we update the display
        letterDisplay.UpdateDisplay(input, currentWord.GetCharArray);

        //fetch a checkedanswer from the currentword
        CheckedAnswer result = currentWord.HandleSubmission(input, this);

        GuessedLetterCount += result.guessedLetters;

        //reward points and update the ui on both clients
        MasterManager.instance.score += result.totalPoints;
        NetworkEvent.UpdateUI(scoreUI, nickName + ": " + MasterManager.instance.score.ToString());

        //if correct show a green flash, if not show a red flash and update the gallow
        if (result.correct)
        {
            fader.FadeRight();
        }
        else
        {
            fader.FadeWrong();
            NetworkEvent.UpdatePlayerGallows(MasterManager.instance.wrongAnswers, gallowUI);
            MasterManager.instance.wrongAnswers++;
        }

        //if the word is guessed, call the rpc to set up a new word
        if (WordGuessed())
        {
            UpdateWordInGameView();
        }
    }
コード例 #2
0
    //callback for when the whole word is correct
    private CheckedAnswer OnWordValidated(string post, Gamemanager owner)
    {
        CheckedAnswer result = new CheckedAnswer();

        result.totalPoints    = word.Length * points;
        result.guessedLetters = word.Length;
        result.correct        = true;
        return(result);
    }
コード例 #3
0
    //callback for when a single char answer is correct
    private CheckedAnswer OnCharValidated(string post, Gamemanager owner)
    {
        //create and return a checkanswer object which contains all the information
        CheckedAnswer result = new CheckedAnswer();

        result.timesInWord    = word.Length - word.Replace(post, "").Length;
        result.totalPoints    = result.timesInWord * points;
        result.guessedLetters = 1;
        result.correct        = true;
        return(result);
    }