Beispiel #1
0
        // Displaying the winner of the whole game and blocking any further actions on buttons
        private void DisplayGameWinner(string winner)
        {
            // Hiding all gesture buttons
            foreach (Button button in gestureButtons)
            {
                button.Hide();
            }

            // Hiding all gesture labels (texts under buttons)
            Lbl_Rock.Hide();
            Lbl_Paper.Hide();
            Lbl_Scissors.Hide();
            Lbl_Lizard.Hide();
            Lbl_Spock.Hide();

            // Changing 'Next Round' button colour to 'inactive'
            Btn_NxtRound.BackColor = SystemColors.ControlLight;

            // Showing the winning message
            Lbl_GameWinner.Show();

            // If the computer has won
            if (winner == "Computer")
            {
                // Changing the colours of the texts
                Lbl_PlayerScore.ForeColor   = Color.Red;
                Lbl_ComputerScore.ForeColor = Color.Green;
                Lbl_GameWinner.ForeColor    = Color.Red;
                Lbl_GameWinner.Text         = @"Computer wins! Try again ¯\_( ͡° ͜ʖ ͡°)_/¯";
            }
            else
            {
                // Changing the colours of the texts
                Lbl_PlayerScore.ForeColor   = Color.Green;
                Lbl_ComputerScore.ForeColor = Color.Red;
                Lbl_GameWinner.ForeColor    = Color.Green;
                Lbl_GameWinner.Text         = "Congratulations, " + playerName + "!\n" + @"You have won! ᕦ( ͡° ͜ʖ ͡°)ᕤ";
            }
        }
Beispiel #2
0
        // Setting the scene. Displaying the number of rounds, player name etc.
        private void HackDayGame_Load(object sender, EventArgs e)
        {
            // Getting the number of points to win from GameData script and displaying it
            pointsToWin = GameData.pointsToWin;
            if (pointsToWin == 1)
            {
                Lbl_PointsToWin.Text = "Playing to 1 point.";
            }
            else
            {
                Lbl_PointsToWin.Text = "Playing to " + pointsToWin + " points.";
            }

            // Erasing winner texts as they have default text for visual purposes
            Lbl_RoundWinner.Text = "";
            Lbl_GameWinner.Text  = "";
            Lbl_GameWinner.Hide(); // this text needs to be hidden as it will display on top of the buttons

            // Getting the player's name from GameData script
            playerName = GameData.playerName;
            if (playerName == "" || playerName == null)
            {
                playerName = "Player";
            }

            // Displaying player's name
            Lbl_PlayerScore.Text = playerName + "\n 0";

            // Changing 'Next Round' button color to 'inactive'
            Btn_NxtRound.BackColor = SystemColors.ControlLight;

            // Storing all gesture buttons in List
            gestureButtons = new List <Button>();
            gestureButtons.Add(Btn_Rock);
            gestureButtons.Add(Btn_Paper);
            gestureButtons.Add(Btn_Scissors);
            gestureButtons.Add(Btn_Lizard);
            gestureButtons.Add(Btn_Spock);
        }