コード例 #1
0
        static void GetPlayers()
        {
            bool done = false;

            while (!done)
            {
                try
                {
                    Console.Write("Enter number of players: ");
                    numplayers = int.Parse(Console.ReadLine());
                    done       = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine("You did not enter a valid number");
                }
            }

            for (int x = 1; x <= numplayers; x++)
            {
                Console.Write("Enter name of player {0}: ", x);
                string playername = Console.ReadLine();
                therules.AddPlayer(playername);
            }
        }
コード例 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Get the players
            frmCreatePlayers frmPlayers = new frmCreatePlayers();

            frmPlayers.ShowDialog();
            if (frmPlayers.DialogResult != DialogResult.OK)
            {
                return;
            }

            // Create rules object and add the players to it
            Rules therules = new Rules();

            foreach (string playername in frmPlayers.Players)
            {
                therules.AddPlayer(playername);
            }

            if (therules.PlayerCount == 0)
            {
                return;
            }

            // Pass the Rules to the main game form
            Application.Run(new frmMainGame(therules));
        }
コード例 #3
0
        static void Main()
        {
            // Create rules object and add the player to it
            Rules therules = new Rules();

            therules.AddPlayer("Player");


            Application.Run(new MainGame(therules));
        }