Ejemplo n.º 1
0
        private void BtnEllLoad_Click(object sender, EventArgs e)
        {
            string line  = "";
            bool   found = false;

            if (!File.Exists(Application.StartupPath + "\\SavesTest.txt"))
            {
                MessageBox.Show("There is no Save file in your computer, you must create a player and save it first.", "ATTENTION");
                this.Hide();
                StartForm start = new StartForm();
                start.ShowDialog();
                this.Close();
            }
            else
            {
                StreamReader sr = new StreamReader(Application.StartupPath + "\\SavesTest.txt");
                while ((line = sr.ReadLine()) != null)
                {
                    string[] new_player = line.Split(';');
                    Player   player     = new Player();
                    player.Name             = new_player[0];
                    player.Gender           = new_player[1];
                    player.Species          = new_player[2];
                    player.Credits          = Int32.Parse(new_player[3]);
                    player.PazaakGamesWon   = Int32.Parse(new_player[4]);
                    player.PazaakGamesLost  = Int32.Parse(new_player[5]);
                    player.DejarikGamesWon  = Int32.Parse(new_player[6]);
                    player.DejarikGamesLost = Int32.Parse(new_player[7]);
                    playersSaved.Add(player);
                }
                sr.Close();
            }

            foreach (Player p in playersSaved)
            {
                if (TBoxName.Text == p.Name)
                {
                    playerSelected.Name             = p.Name;
                    playerSelected.Gender           = p.Gender;
                    playerSelected.Species          = p.Species;
                    playerSelected.Credits          = p.Credits;
                    playerSelected.PazaakGamesWon   = p.PazaakGamesWon;
                    playerSelected.PazaakGamesLost  = p.PazaakGamesLost;
                    playerSelected.DejarikGamesWon  = p.DejarikGamesWon;
                    playerSelected.DejarikGamesLost = p.DejarikGamesLost;
                    found = true;
                }
            }
            if (!found)
            {
                MessageBox.Show("The name: " + TBoxName.Text + " does not appear on our guest file", "ATTENTION");
            }
            this.Hide();
            MenuAccueil menu = new MenuAccueil();

            menu.Player1 = playerSelected;
            menu.ShowDialog();
            this.Close();
        }
Ejemplo n.º 2
0
        private void BtnEllNext_Click(object sender, EventArgs e)
        {
            this.Hide();
            player.Species          = VerificationSpecies();
            player.Name             = TxtBoxNameGen.Text;
            player.Credits          = 500;
            player.PazaakGamesWon   = 0;
            player.PazaakGamesLost  = 0;
            player.DejarikGamesLost = 0;
            player.DejarikGamesWon  = 0;
            MenuAccueil menuAccueil = new MenuAccueil();

            menuAccueil.Player1 = player;
            if (CBoxFemale.Checked)
            {
                player.Gender = "Female";
            }
            else if (CBoxMale.Checked)
            {
                player.Gender = "Male";
            }
            menuAccueil.ShowDialog();
            this.Close();
        }