Exemple #1
0
 // init
 public Game(SetUp s)
 {
     theBoard   = s.getBoard();
     theDisplay = s.getDisplay();
     thePlayers = s.getPlayers();
     checkWin   = s.getCheckWin();
     theOption  = s.getOption();
 }
Exemple #2
0
        public SetUp()
        {
            // Start -- menu
            theBoard   = new BoardGame();
            theDisplay = new Display(theBoard);
            Console.WriteLine("Enter player one's name");
            String player1 = Console.ReadLine();

            Console.WriteLine("Enter player two's name");
            String player2 = Console.ReadLine();

            thePlayers = new Players(player1, player2);
            checkWin   = new CheckWinner();
            theOption  = new NewGame();
        }
Exemple #3
0
        private void Button_Click(object sender, EventArgs e)
        {
            if (sender is Button button)
            {
                if (button.Text != "")
                {
                    return;
                }
                if (IsFirstPlayer)
                {
                    button.Text          = "X";
                    IsFirstPlayer        = false;
                    PlayerTurnlabel.Text = SecondPlayer;
                }
                else
                {
                    button.Text          = "O";
                    IsFirstPlayer        = true;
                    PlayerTurnlabel.Text = FirstPlayer;
                }
                if (CheckGame(IsFirstPlayer ? SecondPlayer : FirstPlayer))
                {
                    var formContinue = new ContinueGame();
                    if (formContinue.ShowDialog() == DialogResult.Yes)
                    {
                        // TODO: Переделать.
                        var formNewGame = new NewGame();
                        formNewGame.ShowDialog();

                        if (formNewGame.DialogResult == DialogResult.OK && formNewGame.IsNewNames)
                        {
                            formNewGame.SetNewNames(ref FirstPlayer, ref SecondPlayer);
                            ResetButtons();
                        }
                    }
                    else
                    {
                        Application.Exit();
                    }
                }
            }
            else
            {
                throw new ArgumentNullException(nameof(sender));
            }
        }
Exemple #4
0
        public Main()
        {
            InitializeComponent();
            var formNewGame = new NewGame();

            formNewGame.ShowDialog();

            if (formNewGame.DialogResult == DialogResult.OK && formNewGame.IsNewNames)
            {
                formNewGame.SetNewNames(ref FirstPlayer, ref SecondPlayer);
            }
            this.Width  = 400;
            this.Height = 500;
            CreateButtons(buttons);
            SetButtons(buttons);
            IsFirstPlayer        = true;
            PlayerTurnlabel.Text = FirstPlayer;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            NewGame f = new NewGame();

            f.ShowDialog();
        }