예제 #1
0
        private void btn_HighScores_Click(object sender, EventArgs e)
        {
            //only allow one instance of the highscore board
            if (Application.OpenForms["frm_ScoreBoard"] == null)
            {
                if (Cheating)
                {
                    HighScores = new frm_ScoreBoard(CheatsFromListBox());
                }
                else
                {
                    HighScores = new frm_ScoreBoard();
                }

                HighScores.Show();
            }
            else
            {
                HighScores.Focus();
            }
        }
예제 #2
0
        //private utility functions functions

        private void SetMyProfileStats()
        {
            try
            {
                if (File.Exists(HighScoresFilename))
                {
                    using (StreamReader reader = new StreamReader(HighScoresFilename))
                    {
                        string playerinfo            = "";
                        bool   player_found          = false;
                        bool   fieldformatfaultfound = false;
                        while (!reader.EndOfStream)
                        {
                            playerinfo = reader.ReadLine();
                            string[] player_data = playerinfo.Split(',');
                            if (player_data.Length != HighScoresFileFieldsCount)
                            {
                                fieldformatfaultfound = true;
                            }
                            if (player_data[0] == txt_UserName.Text)
                            {
                                player_found = true;
                                try
                                {
                                    txt_HighScore.Text    = player_data[2];
                                    txt_TimesPlayed.Text  = player_data[3];
                                    txt_Deaths.Text       = player_data[4];
                                    txt_BulletsShot.Text  = player_data[5];
                                    txt_CloseCalls.Text   = player_data[6];
                                    txt_DeiExMachina.Text = player_data[7];
                                    frm_PlayerProfile.UpdatePic(player_data[1]);
                                    pb_ProfilePic.Image = frm_PlayerProfile.profilePic;
                                }
                                catch (IndexOutOfRangeException ex)
                                {
                                    fieldformatfaultfound = true;
                                    Console.WriteLine(ex.Message);
                                }
                            }
                        }
                        if (fieldformatfaultfound)
                        {
                            MessageBox.Show("Possible Error in High Score File");
                        }
                        if (!player_found)
                        {
                            txt_HighScore.Text    = 0 + "";
                            txt_TimesPlayed.Text  = 0 + "";
                            txt_Deaths.Text       = 0 + "";
                            txt_BulletsShot.Text  = 0 + "";
                            txt_CloseCalls.Text   = 0 + "";
                            txt_DeiExMachina.Text = 0 + "";
                        }
                        //restart highscore board
                        if (Application.OpenForms["frm_ScoreBoard"] != null)
                        {
                            HighScores.Close();
                            if (Cheating)
                            {
                                HighScores = new frm_ScoreBoard(CheatsFromListBox());
                            }
                            else
                            {
                                HighScores = new frm_ScoreBoard();
                            }

                            HighScores.Show();
                        }
                        else
                        {
                            HighScores.Focus();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }