예제 #1
0
    void P2win()
    {
        rock.interactable     = false;
        paper.interactable    = false;
        scissors.interactable = false;
        lose.gameObject.SetActive(true);
        p2w++;
        CompScore.p2score = p2w;

        if (p2w == 10)
        {
            LoseSound.Play();
            if (Users.CurrentUser.username == "admin")
            {
                logs.Add(new GameLog("admin", System.DateTime.Now.ToString(), "Robot", "n/a")); // comp won, log admin data into system
            }

            else
            {
                logs.Add(new GameLog(Users.CurrentUser.username, System.DateTime.Now.ToString(), "Robot", "n/a")); // comp won, log player daya into system
            }
            SaveGameData();
        }
    }
예제 #2
0
        private void btnGuess_Click(object sender, EventArgs e)
        {
            if (txtGuess.Text.Trim().Length > 0 && txtGuess.Text.Trim().Length < 2)
            {
                guess = txtGuess.Text.Trim().ToUpper();
                for (int i = 0; word.Length > i; i++)
                {
                    ///correct guess
                    if (word.IndexOf(guess, i) != -1)
                    {
                        displayWord = displayWord.Remove(word.IndexOf(guess, i), 1);
                        displayWord = displayWord.Insert(word.IndexOf(guess, i), guess);
                    }
                    lblWord.Text = displayWord;
                }
                ///incorrect guess
                if (word.IndexOf(guess) == -1)
                {
                    usedLetters.Add(guess);
                    lstUsedLetters.DataSource = null;
                    lstUsedLetters.DataSource = usedLetters;
                    numOfGuesses--;
                    lblDescrition.Text = "Enter a single letter and then press the green button. You have " + numOfGuesses + " attempts or you lose!";
                }
            }
            txtGuess.Text = "";

            switch (numOfGuesses)
            {
            case 6:
                imgHangman.Image = Properties.Resources.HangmanFresh;
                break;

            case 5:
                imgHangman.Image = Properties.Resources.HangmanHead;
                break;

            case 4:
                imgHangman.Image = Properties.Resources.HangmanBody;
                break;

            case 3:
                imgHangman.Image = Properties.Resources.HangmanLeg1;
                break;

            case 2:
                imgHangman.Image = Properties.Resources.HangmanLeg2;
                break;

            case 1:
                imgHangman.Image = Properties.Resources.HangmanArm1;
                break;

            ///lose check
            case 0:
                imgHangman.Image = Properties.Resources.HangmanArm2;
                LoseSound.Play();
                lblDescrition.Text = "You have " + numOfGuesses + " attempts. You Lose!";
                btnGuess.Enabled   = false;
                break;
            }
            ///win check
            if (numOfGuesses >= 0 & !displayWord.Contains("-"))
            {
                WinSound.Play();
                lblDescrition.Text = "You Win!!!! and you still have " + numOfGuesses + " attempt(s) left. Good job! :)";
                btnGuess.Enabled   = false;
            }
        }
 public void PlayLoseSoundAudio()
 {
     LoseSound.Play();
 }