예제 #1
0
        private GraffitiBlockData GetGraffitiBlockData(int startXPos, int startYPos, Texture2D layerTexture)
        {
            GraffitiBlockData graffitiBlockData = new GraffitiBlockData();
            List <PixelData>  pixels            = new List <PixelData>();

            for (int x = startXPos; x < startXPos + polygonWidth; x++)
            {
                for (int y = startYPos; y < startYPos + polygonHeight; y++)
                {
                    Color pixel = layerTexture.GetPixel(x, y);

                    if (pixel.a <= 0)
                    {
                        continue;
                    }

                    pixels.Add(new PixelData
                    {
                        xPos  = x,
                        yPos  = y,
                        color = pixel
                    });
                }
            }

            graffitiBlockData.pixels = pixels;
            return(graffitiBlockData);
        }
예제 #2
0
        private void ParseLayer(Texture2D layerTexture)
        {
            int blockXCount = BlocksX;
            int blockYCount = BlocksY;
            int blockID     = 0;

            for (int j = blockYCount - 1; j >= 0; j--)
            {
                for (int i = 0; i < blockXCount; i++)
                {
                    int startXPos = i * polygonWidth;
                    int startYPos = j * polygonHeight;

                    GraffitiBlockData block = GetGraffitiBlockData(startXPos, startYPos, layerTexture);

                    if (block.pixels.Count > 0)
                    {
                        block.blockID = blockID;
                        _graffitiBlocksData.Add(block);
                    }

                    blockID++;
                }
            }
        }