예제 #1
0
        private int Get4DirMask(Array2D <int> input, int x, int y, TilerPattern p)
        {
            //   3
            // 0   1
            //   2

            int m = 0;

            if (p.Connects(GetCell(input, x - 1, y)))
            {
                m |= 1;
            }
            if (p.Connects(GetCell(input, x + 1, y)))
            {
                m |= 2;
            }
            if (p.Connects(GetCell(input, x, y - 1)))
            {
                m |= 4;
            }
            if (p.Connects(GetCell(input, x, y + 1)))
            {
                m |= 8;
            }

            //if (x != 0 && p.Connects(mapInput[input[x - 1, y]])) m |= 1;
            //if (y != 0 && p.Connects(mapInput[input[x, y - 1]])) m |= 4;
            //if (x != input.sizeX - 1 && p.Connects(input[x + 1, y])) m |= 2;
            //if (y != input.sizeY - 1 && p.Connects(input[x, y - 1])) m |= 8;

            return(m);
        }
예제 #2
0
        private int Get8DirMask(Array2D <int> input, int x, int y, TilerPattern p)
        {
            // 0 1 2
            // 3   4
            // 5 6 7

            int m = 0;

            if (p.Connects(GetCell(input, x - 1, y - 1)))
            {
                m |= 1;
            }
            if (p.Connects(GetCell(input, x, y - 1)))
            {
                m |= 2;
            }
            if (p.Connects(GetCell(input, x + 1, y - 1)))
            {
                m |= 4;
            }
            if (p.Connects(GetCell(input, x - 1, y)))
            {
                m |= 8;
            }
            if (p.Connects(GetCell(input, x + 1, y)))
            {
                m |= 16;
            }
            if (p.Connects(GetCell(input, x - 1, y + 1)))
            {
                m |= 32;
            }
            if (p.Connects(GetCell(input, x, y + 1)))
            {
                m |= 64;
            }
            if (p.Connects(GetCell(input, x + 1, y + 1)))
            {
                m |= 128;
            }

            //if (x != 0)
            //{
            //	if (y != 0 && p.Connects(mapInput[input[x - 1, y - 1]]))
            //		m |= (1 << 0);
            //	if (y != input.sizeY - 1 && p.Connects(mapInput[input[x - 1, y + 1]]))
            //		m |= (1 << 5);
            //	if (p.Connects(mapInput[input[x - 1, y]]))
            //		m |= (1 << 3);
            //}

            //if (x != input.sizeX - 1)
            //{
            //	if (y != 0 && p.Connects(mapInput[input[x + 1, y - 1]]))
            //		m |= (1 << 2);
            //	if (y != input.sizeY - 1 && p.Connects(mapInput[input[x + 1, y + 1]]))
            //		m |= (1 << 7);
            //	if (p.Connects(mapInput[input[x + 1, y]]))
            //		m |= (1 << 4);
            //}

            //if (y != 0 && p.Connects(mapInput[input[x, y - 1]]))
            //	m |= (1 << 1);
            //if (y != input.sizeY - 1 && p.Connects(mapInput[input[x, y + 1]]))
            //	m |= (1 << 6);

            return(m);
        }