示例#1
0
        // This switch statement is based upon how many guesses the player has left
        //From 7 through to 0. Each case statement displays a different picture and runs the "GuessedWrongText" method, which just displays  a text.
        private void GuessFailed()
        {
            switch (GuessesLeft)
            {
            case 7:

                imgHangman.SetImageResource(Resource.Drawable.F1);

                break;

            case 6:
                imgHangman.SetImageResource(Resource.Drawable.F2);

                break;

            case 5:
                imgHangman.SetImageResource(Resource.Drawable.F3);
                break;

            case 4:
                imgHangman.SetImageResource(Resource.Drawable.F4);

                break;

            case 3:
                imgHangman.SetImageResource(Resource.Drawable.F5);

                break;

            case 2:
                imgHangman.SetImageResource(Resource.Drawable.F6);

                break;

            case 1:
                imgHangman.SetImageResource(Resource.Drawable.F7);

                break;

            // Case 0(0 turns left), the player has lost the game.
            case 0:
                imgHangman.SetImageResource(Resource.Drawable.F8);

                // For losing the game, the player incurs a 12 point penalty to their score. If it puts their score below 0, it will be set to 0
                score = score - 12;
                if (score < 0)
                {
                    score = 0;
                }
                System.Threading.Thread.Sleep(200);
                Toast.MakeText(this, "You have run out of guesses! You LOSE. Your Score was " + score, ToastLength.Short).Show();
                var cc = new ConClass();
                cc.UpdateScore(Id, PlayerName, score);
                System.Threading.Thread.Sleep(500);


                StartActivity(typeof(MainActivity));
                break;
            }
        }
示例#2
0
        private void GameWon()
        {
            // Set the image to  default
            DefaultImage();
            // Display the text
            Toast.MakeText(this, "You guessed the word correctly", ToastLength.Short).
            Show();
            var cc = new ConClass();

            cc.UpdateScore(Id, PlayerName, score);
            // And load a new word
            LoadNewRandomWord();
        }