Пример #1
0
        public Texture2D GetTexture()
        {
            int         xSize      = 16;
            int         zSize      = 16;
            int         chunkWidth = picWidth / 16;
            int         chunkDepth = picHeight / 16;
            Texture2D   tex        = new Texture2D(chunkWidth * xSize, chunkDepth * zSize);
            ArraysCache cache      = ArraysCacheManager.GetCache();

            for (int x = 0; x < chunkWidth; x++)
            {
                for (int z = 0; z < chunkDepth; z++)
                {
                    int[] result = mainLayer.getInts(cache, x * xSize, z * zSize, xSize, zSize);
                    cache.release();
                    for (int i = 0; i < result.Length; i++)
                    {
                        int   tempX = i % xSize;
                        int   tempZ = i / xSize;
                        Color c;
                        int   biomeId = ((result[i] & BiomeBits));

                        BiomeConfig biomeConfig = WorldConfig.Instance.GetBiomeConfigById(biomeId);
                        c = biomeConfig.color;
                        tex.SetPixel(x * xSize + tempX, z * zSize + tempZ, c);
                    }
                }
            }
            tex.Apply();
            return(tex);
        }
        public int[] GetBiomes(int[] biomeArray, int x, int z, int x_size, int z_size)
        {
            if ((biomeArray == null) || biomeArray.Length < x_size * z_size)
            {
                biomeArray = new int[x_size * z_size];
            }

            ArraysCache cache = ArraysCacheManager.GetCache();

            int[] result = this._biomeLayer.getInts(cache, x, z, x_size, z_size);
            ArraysCacheManager.ReleaseCache(cache);

            Array.Copy(result, 0, biomeArray, 0, x_size * z_size);

//			for (int i = 0; i < result.Length; i++) {
//				int tempX = i % x_size;
//				int tempZ = i / x_size;
//
//				biomeArray[tempX,tempZ] = result[i];
//			}
            return(biomeArray);
        }