Esempio n. 1
0
        private void AddHorizontalSituationScore(Tile self, ref int[,] score, int xstart, int xend, int ystart)
        {
            if (!_game.IsFree(xstart, ystart))
            {
                return;
            }
            var q = 0;

            for (var x = xstart; x <= xend; x++)
            {
                if (_game.GetTileAt(xstart, ystart) == self)
                {
                    q++;
                }
            }
            if (q >= 7)
            {
                score[xstart, ystart] += 90;
            }
        }
Esempio n. 2
0
        private void FlipAt(bool black, Direction direction, int x, int y)
        {
            var dir     = DirectionHelper.DirectionToPoint(direction);
            var targetX = x;
            var targetY = y;
            var changes = new List <Point>();

            do
            {
                ApplyMovement(dir, ref targetX, ref targetY);

                if (!OnBoard(targetX, targetY) || _game.GetTileAt(targetX, targetY) == Tile.None)
                {
                    return;
                }

                if (IsFriendColor(black, targetX, targetY))
                {
                    if (changes.Count > 0)
                    {
                        break;
                    }
                    return;
                }

                if (IsEnemyColor(black, targetX, targetY))
                {
                    changes.Add(new Point(targetX, targetY));
                }
            } while (true);

            foreach (var point in changes)
            {
                _game.SetTileAt(point.X, point.Y, black ? Tile.Black : Tile.White);
            }
        }
Esempio n. 3
0
        public void Draw(Graphics g, Game game)
        {
            using var bgBrush      = new SolidBrush(Color.FromArgb(190, 190, 190));
            using var highlightPen = new Pen(Color.FromArgb(220, 220, 220));
            using var shadowPen    = new Pen(Color.FromArgb(150, 150, 150));
            using var black        = new SolidBrush(game.GameStatus == GameStatus.NotStarted ? Color.FromArgb(90, 90, 90) : Color.FromArgb(0, 0, 0));
            using var white        = new SolidBrush(game.GameStatus == GameStatus.NotStarted ? Color.FromArgb(230, 230, 230) : Color.FromArgb(255, 255, 255));
            g.ResetClip();
            g.Clear(Color.FromArgb(180, 180, 180));
            const int t    = TileSize - 1;
            var       xpos = BoardX;
            var       ypos = BoardY;

            for (var y = 0; y < 8; y++)
            {
                for (var x = 0; x < 8; x++)
                {
                    g.SetClip(new Rectangle(xpos, ypos, t, t));
                    g.FillRectangle(bgBrush, xpos, ypos, t, t);
                    switch (game.GetTileAt(x, y))
                    {
                    case Tile.Black:
                        g.FillEllipse(black, xpos + 2, ypos + 2, t - 5, t - 5);
                        break;

                    case Tile.White:
                        g.FillEllipse(white, xpos + 2, ypos + 2, t - 5, t - 5);
                        break;
                    }
                    g.DrawRectangle(shadowPen, xpos - 1, ypos - 1, t, t);
                    g.DrawRectangle(highlightPen, xpos, ypos, t, t);
                    xpos += TileSize;
                }
                xpos  = BoardX;
                ypos += TileSize;
            }
        }