Пример #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.GuessFailed1);

            //    break;
            case 6:
                imgHangman.SetImageResource(Resource.Drawable.GuessFailed1);

                break;

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

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

                break;

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

                break;

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

                break;

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

                break;

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

                // 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);
                msg         = "You Lost!";
                txtMsg.Text = msg;
                txtMsg.SetTextColor(Android.Graphics.Color.Red);
                txtWordToGuess.Text = rand.ToString();
                //Toast.MakeText(this, "You have run out of guesses! You LOSE. Your Score was " + score, ToastLength.Short).Show();
                var cc = new DBConnection();
                DisableButtons();
                btnNewGame.Enabled = true;
                cc.UpdateScore(Id, PlayerName, score);
                System.Threading.Thread.Sleep(500);
                //btnNewGame.Enabled = false;
                //LoadRandomWord();
                //btnNewGame.Enabled = false;
                //DefaultImage();
                //StartActivity(typeof(MainActivity));
                break;
            }
        }