Пример #1
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);
            }
        }