コード例 #1
0
ファイル: Form1.cs プロジェクト: eNuoTiZ/Othello
        private void Square_Click(object sender, EventArgs e)
        {
            PictureBox pictureBox = sender as PictureBox;

            if (!Game.GetInstance().TheEnd&& pictureBox != null)
            {
                Game.Move move = new Game.Move(-1, -1);

                string[] coords = pictureBox.Tag.ToString().Split(';');

                move._column = Convert.ToInt32(coords[0]);
                move._row    = Convert.ToInt32(coords[1]);

                if (move._column >= 0 && move._column < 8 && move._row >= 0 && move._row < 8)
                {
                    if (_game.IsSquarePlayable(_game.Board, _players[_game.PlayerTurn].ColorPlayer, move))
                    {
                        int points = Game.GetInstance()
                                     .Play(ref Game.GetInstance().Board, _players[_game.PlayerTurn].ColorPlayer, move);

                        if (points > 0)
                        {
                            UpdateHistory(move);

                            _players[_game.PlayerTurn].Score += points + 1;

                            Game.GetInstance().InvertTurn();
                            Game.GetInstance().Turn++;

                            _players[_game.PlayerTurn].Score -= points;

                            DrawBoard();
                        }
                        else
                        {
                            Game.GetInstance().InvertTurn();
                            Game.GetInstance().Turn++;
                        }

                        if (_game.BoardFull(_game.Board))
                        {
                            _game.TheEnd = true;
                        }

                        PlayAi();
                    }
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: eNuoTiZ/Othello
        void PictureBox_MouseEnter(object sender, EventArgs e)
        {
            PictureBox pictureBox = sender as PictureBox;

            if (pictureBox != null)
            {
                Game.Move move = new Game.Move(-1, -1);

                string[] coords = ((PictureBox)sender).Tag.ToString().Split(';');

                move._column = Convert.ToInt32(coords[0]);
                move._row    = Convert.ToInt32(coords[1]);

                statusLabel.Text = string.Format("{0}-{1}", move._row, move._column);

                if (cbDisplayAvailableMoves.Checked && _game.IsSquarePlayable(_game.Board, _players[_game.PlayerTurn].ColorPlayer, move))
                {
                    pictureBox.Image = Resources.AvailableMove;
                }
            }
        }