Ejemplo n.º 1
0
        public SquareGrid(int[,] map, float squareSize)
        {
            int   nodeCountX = map.GetLength(0);
            int   nodeCountY = map.GetLength(1);
            float mapWidth   = nodeCountX * squareSize;
            float mapHeight  = nodeCountY * squareSize;

            ControllNode[,] controllNodes = new ControllNode[nodeCountX, nodeCountY];

            for (int x = 0; x < nodeCountX; x++)
            {
                for (int y = 0; y < nodeCountY; y++)
                {
                    Vector3 pos = new Vector3(-mapWidth / 2 + x * squareSize + squareSize / 2, 0, -mapHeight / 2 + y * squareSize + squareSize / 2);
                    controllNodes[x, y] = new ControllNode(pos, map[x, y] == 1, squareSize);
                }
            }
            squares = new Square[nodeCountX - 1, nodeCountY - 1];

            for (int x = 0; x < nodeCountX - 1; x++)
            {
                for (int y = 0; y < nodeCountY - 1; y++)
                {
                    squares[x, y] = new Square(controllNodes[x, y + 1], controllNodes[x + 1, y + 1], controllNodes[x + 1, y], controllNodes[x, y]);
                }
            }
        }
Ejemplo n.º 2
0
        public Square(ControllNode topLeft, ControllNode topRight, ControllNode bottomRight, ControllNode bottomLeft)
        {
            this.topLeft     = topLeft;
            this.topRight    = topRight;
            this.bottomRight = bottomRight;
            this.bottomLeft  = bottomLeft;

            centerTop    = topLeft.right;
            centerRight  = bottomRight.above;
            centerBottom = bottomLeft.right;
            centerLeft   = bottomLeft.above;

            if (topLeft.active)
            {
                configuration += 8;
            }
            if (topRight.active)
            {
                configuration += 4;
            }
            if (bottomRight.active)
            {
                configuration += 2;
            }
            if (bottomLeft.active)
            {
                configuration += 1;
            }
        }
Ejemplo n.º 3
0
        public SquareGrid(int [,] map, float squareSize)
        {
            int nodeCountX = map.GetLength(0);
            int nodeCountY = map.GetLength(1);

            float mapWidth  = nodeCountX * squareSize;
            float mapHeight = nodeCountY * squareSize;


            ControllNode[,] controllNodes = new ControllNode[nodeCountX, nodeCountY];

            //Create all controll nodes to use in the squares grid
            for (int x = 0; x < nodeCountX; x++)
            {
                for (int y = 0; y < nodeCountY; y++)
                {
                    Vector3 position = new Vector3(-mapWidth / 2 + x * squareSize + squareSize / 2, 0, -mapHeight / 2 + y * squareSize + squareSize / 2);
                    controllNodes[x, y] = new ControllNode(position, map[x, y] == 1, squareSize);
                }
            }

            //Squares use minimum 2 controll nodes in each direction, so the [,] dimension is -1
            squares = new Square[nodeCountX - 1, nodeCountY - 1];

            for (int x = 0; x < nodeCountX - 1; x++)
            {
                for (int y = 0; y < nodeCountY - 1; y++)
                {
                    squares[x, y] = new Square(controllNodes[x, y + 1], controllNodes[x + 1, y + 1], controllNodes[x + 1, y], controllNodes[x, y]);
                }
            }
        }
Ejemplo n.º 4
0
        public Square(ControllNode _topRight, ControllNode _topLeft, ControllNode _bottomRight, ControllNode _bottomLeft)
        {
            topRight    = _topRight;
            topLeft     = _topLeft;
            bottomRight = _bottomRight;
            bottomLeft  = _bottomLeft;

            centreTop    = topLeft.right;
            centreRight  = bottomRight.above;
            centreBottom = bottomLeft.right;
            centreLeft   = bottomLeft.above;
        }
Ejemplo n.º 5
0
		public Square (ControllNode _topLeft, ControllNode _topRight, ControllNode _bottomRight, ControllNode _bottomLeft) {
			topLeft = _topLeft;
			topRight = _topRight;
			bottomRight = _bottomRight;
			bottomLeft = _bottomLeft;
			
			centerTop = topLeft.right;
			centerRight = bottomRight.above;
			centerLeft = bottomLeft.above;
			centerBottom = bottomLeft.right;
			
			if(topLeft.active)
				configuration += 8;
			if(topRight.active)
				configuration += 4;
			if(bottomRight.active)
				configuration += 2;
			if(bottomLeft.active)
				configuration += 1;
								
		}
Ejemplo n.º 6
0
		public SquareGrid (int[,] map, float squareSize) {
			int nodeCountX = map.GetLength(0);
			int nodeCountY = map.GetLength(1);
			float mapWidht = nodeCountX * squareSize;
			float mapHeight = nodeCountY * squareSize;
			
			ControllNode[,] controllNodes = new ControllNode[nodeCountX, nodeCountY];
			
			for(int x = 0; x < nodeCountX; x ++) {
				for(int y = 0; y < nodeCountY; y ++) {
					Vector3 pos = new Vector3(-mapWidht/2 + x * squareSize + squareSize/2, 0, -mapHeight/2 + y * squareSize + squareSize/2);
					controllNodes[x, y] = new ControllNode(pos, map[x,y] == 1, squareSize );
					
				}
			}
			
			squares = new Square[nodeCountX - 1, nodeCountY - 1];
			
			for(int x = 0; x < nodeCountX-1; x ++) {
				for(int y = 0; y < nodeCountY-1; y ++) {
					squares[x, y] = new Square(controllNodes[x, y+1], controllNodes[x+1, y+1], controllNodes[x+1, y], controllNodes[x,y]);		
				}
			}
			
			
			
		}