コード例 #1
0
ファイル: Game.cs プロジェクト: iismail1997/TicTacToe
 // init
 public Game(SetUp s)
 {
     theBoard   = s.getBoard();
     theDisplay = s.getDisplay();
     thePlayers = s.getPlayers();
     checkWin   = s.getCheckWin();
     theOption  = s.getOption();
 }
コード例 #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();
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: Rullazzz/TicTacToe
        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));
            }
        }
コード例 #4
0
ファイル: Main.cs プロジェクト: Rullazzz/TicTacToe
        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;
        }
コード例 #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            NewGame f = new NewGame();

            f.ShowDialog();
        }