Пример #1
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            if (txtEd_Name.Text.Length > 0)
            {
                // Set the new PlayerName to the text in the textfield
                My_Hangman_Game_Activity.PlayerName = txtEd_Name.Text.ToString();
                // Give them a score of 0 to begin with
                My_Hangman_Game_Activity.score = 0;
                var cc = new My_Sqlite_Connection();
                // Insert the Players name and score into the database
                cc.InsertNewPlayer(My_Hangman_Game_Activity.PlayerName, My_Hangman_Game_Activity.score);

                // And update the list
                All_Records = cc.ViewAll();


                var da = new Resources.My_Adapter_Spinner(this, All_Records);
                // And display the updated list on the spinner
                Name_Spinner.Adapter = da;
                Toast.MakeText(this, "Profile Name Saved ", ToastLength.Short).Show();
                StartActivity(typeof(My_Hangman_Game_Activity));
            }
            // Display a message if there is an empty textfield
            else
            {
                Toast.MakeText(this, "Please enter  your name", ToastLength.Short).Show();
            }
        }
Пример #2
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.GFail1);

                break;

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

                break;

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

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

                break;

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

                break;

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

                break;

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

                break;

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

                // 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 My_Sqlite_Connection();
                cc.UpdateScore(Id, PlayerName, score);
                System.Threading.Thread.Sleep(500);


                StartActivity(typeof(MainActivity));
                break;
            }
        }
Пример #3
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 My_Sqlite_Connection();

            cc.UpdateScore(Id, PlayerName, score);
            // And load a new word
            LoadNewRandomWord();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.My_All_Score_Layout);
            btn_play_again        = FindViewById <Button>(Resource.Id.btn_play_again);
            btn_play_again.Click += btn_play_again_Click;

            MyCon    = new My_Sqlite_Connection();
            List_Max = MyCon.ViewAll();

            ListView List_View_All = FindViewById <ListView>(Resource.Id.List_View_All);

            List_View_All.Adapter = new My_Adapter_Spinner(this, List_Max);
        }
Пример #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            My_Sqlite_Connection Con = new My_Sqlite_Connection();

            All_Records = Con.ViewAll();

            Name_Spinner = FindViewById <Spinner>(Resource.Id.Name_Spinner);
            Hangman_Joban.Resources.My_Adapter_Spinner da = new Resources.My_Adapter_Spinner(this, All_Records);

            Name_Spinner.Adapter = da;

            Name_Spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Name_Spinner_ItemSelected);

            txtEd_Name = FindViewById <TextView>(Resource.Id.txtEd_Name);

            Button btn_save = FindViewById <Button>(Resource.Id.btn_save);

            btn_save.Click += btn_save_Click;
        }