Exemplo n.º 1
0
        static bool BlankCheck(Point pos, BoxDirection direction, char[,] Board)
        {
            int sizeX, sizeY;

            if (direction == BoxDirection.Vertical)
            {
                sizeX = BoxXsize;
                sizeY = BoxYsize;
            }
            else
            {
                sizeX = BoxYsize;
                sizeY = BoxXsize;
            }
            for (int top = 0; top < sizeY; top++)
            {
                for (int left = 0; left < sizeX; left++)
                {
                    if (Board[pos.Y + top, pos.X + left] != BlankChar)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        Corner GetCornerFromDirection(Corner orig, BoxDirection direction)
        {
            Corner result = null;

            Point newP = orig.GetLocation();

            switch (direction)
            {
            case BoxDirection.Up:
                newP.Offset(0, -1);
                break;

            case BoxDirection.Down:
                newP.Offset(0, 1);
                break;

            case BoxDirection.Left:
                newP.Offset(-1, 0);
                break;

            case BoxDirection.Right:
                newP.Offset(1, 0);
                break;
            }

            if (CornerPointOnBoard(newP))
            {
                result = m_CornerRows[newP.Y][newP.X];
            }

            return(result);
        }
Exemplo n.º 3
0
        static void SetBox(int num, Point pos, BoxDirection direction, char[,] Board)
        {
            int sizeX, sizeY;

            if (direction == BoxDirection.Vertical)
            {
                sizeX = BoxXsize;
                sizeY = BoxYsize;
            }
            else
            {
                sizeX = BoxYsize;
                sizeY = BoxXsize;
            }
            for (int top = 0; top < sizeY; top++)
            {
                for (int left = 0; left < sizeX; left++)
                {
                    char c = BlankChar;
                    if (num != 0)
                    {
                        c = ' ';
                        if (top == 0 && left == 0)
                        {
                            c = '┌';
                        }
                        else if (top == 0 && left == sizeX - 1)
                        {
                            c = '┐';
                        }
                        else if (top == sizeY - 1 && left == 0)
                        {
                            c = '└';
                        }
                        else if (top == sizeY - 1 && left == sizeX - 1)
                        {
                            c = '┘';
                        }
                        else if (top == 0 || top == sizeY - 1)
                        {
                            c = '─';
                        }
                        else if (left == 0 || left == sizeX - 1)
                        {
                            c = '│';
                        }
                    }
                    Board[pos.Y + top, pos.X + left] = c;
                }
            }
        }
Exemplo n.º 4
0
 static void RemoveBox(Point pos, BoxDirection direction, char[,] Board)
 {
     SetBox(0, pos, direction, Board);
 }
Exemplo n.º 5
0
        Box CreateBox(IMove move, BoxDirection direction, Player player)
        {
            bool   wouldBox = false;
            Corner ul = null, ur = null, ll = null, lr = null;

            switch (direction)
            {
            case BoxDirection.Up:
            {
                if (!(move.GetLine() as Line).Vertical)
                {
                    ll = move.GetLine().GetStart() as Corner;
                    ul = GetCornerFromDirection(ll, BoxDirection.Up);
                    lr = move.GetLine().GetEnd() as Corner;
                    ur = GetCornerFromDirection(lr, BoxDirection.Up);
                }
            }
            break;

            case BoxDirection.Down:
            {
                if (!(move.GetLine() as Line).Vertical)
                {
                    ul = move.GetLine().GetStart() as Corner;
                    ur = move.GetLine().GetEnd() as Corner;
                    ll = GetCornerFromDirection(ul, BoxDirection.Down);
                    lr = GetCornerFromDirection(ur, BoxDirection.Down);
                }
            }
            break;

            case BoxDirection.Left:
            {
                if ((move.GetLine() as Line).Vertical)
                {
                    ur = move.GetLine().GetStart() as Corner;
                    lr = move.GetLine().GetEnd() as Corner;
                    ul = GetCornerFromDirection(ur, BoxDirection.Left);
                    ll = GetCornerFromDirection(lr, BoxDirection.Left);
                }
            }
            break;

            case BoxDirection.Right:
            {
                if ((move.GetLine() as Line).Vertical)
                {
                    ul = move.GetLine().GetStart() as Corner;
                    ll = move.GetLine().GetEnd() as Corner;
                    ur = GetCornerFromDirection(ul, BoxDirection.Right);
                    lr = GetCornerFromDirection(ll, BoxDirection.Right);
                }
            }
            break;

            default:
                throw new ArgumentException("Direction must be one of Up, Down, Left, Right");
            }

            Box box = null;

            if (ul != null && ur != null && ll != null && lr != null)
            {
                wouldBox = MakesBox(ul, ur, ll, lr, move as Move);
                if (wouldBox)
                {
                    box = new Box(ul, ur, lr, ll, player, this);
                }
            }

            return(box);
        }
Exemplo n.º 6
0
 public BoxBuilder Direction(BoxDirection value)
 {
     base.Options["direction"] = value;
     return(this);
 }