Exemplo n.º 1
0
        public MapMeshGenerator(DynamicBuffer <int> tilemap, int width, int height, float sqaureSize, TileType meshType)
        {
            this.width  = width;
            this.height = height;
            squareGrid  = new SquareGrid(tilemap.AsNativeArray(), width, height, sqaureSize, meshType);

            for (int x = 0; x < squareGrid.GetLength(0); x++)
            {
                for (int y = 0; y < squareGrid.GetLength(1); y++)
                {
                    Square top   = (y != squareGrid.GetLength(1) - 1)? squareGrid.GetSquare(x, y + 1) : null;
                    Square left  = (x != 0) ? squareGrid.GetSquare(x - 1, y) : null;
                    Square bot   = (y != 0) ? squareGrid.GetSquare(x, y - 1) : null;
                    Square right = (x != squareGrid.GetLength(0) - 1) ? squareGrid.GetSquare(x + 1, y) : null;

                    TriangulateSquare(squareGrid.GetSquare(x, y), top, left, bot, right);
                }
            }
        }