Exemplo n.º 1
0
        /// <summary>
        /// Creates a new block with a specified color value index
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <param name="color"></param>
        public static void AddCube(int x, int y, int z, int color)
        {
            if (Singleton == null)
            {
                return;
            }

            int chunkX   = Mathf.FloorToInt(x / 16f);
            int chunkY   = Mathf.FloorToInt(y / 16f);
            int chunkZ   = Mathf.FloorToInt(z / 16f);
            int chunkKey = Singleton.Vector3ToInt(chunkX, chunkY, chunkZ);

            ChunkController chunk = Singleton.GetChunkByBlock(x, y, z);

            if (chunk == null)
            {
                chunk = Singleton.CreateChunk(chunkX, chunkY, chunkZ);
                Singleton.chunks.Add(chunkKey, chunk);
            }

            int paletteWidth = ColorPaletteManager.GetPaletteWidth();
            int colorX       = color % paletteWidth;
            int colorY       = Mathf.FloorToInt(color / paletteWidth);

            chunk.AddCube(Mathf.Abs(x - chunkX * 16), Mathf.Abs(y - chunkY * 16), Mathf.Abs(z - chunkZ * 16), colorX, colorY);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new block using the current closestColor
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public static void AddCube(int x, int y, int z)
        {
            if (Singleton == null)
            {
                return;
            }

            int chunkX   = Mathf.FloorToInt(x / 16f);
            int chunkY   = Mathf.FloorToInt(y / 16f);
            int chunkZ   = Mathf.FloorToInt(z / 16f);
            int chunkKey = Singleton.Vector3ToInt(chunkX, chunkY, chunkZ);

            ChunkController chunk = Singleton.GetChunkByBlock(x, y, z);

            if (chunk == null)
            {
                chunk = Singleton.CreateChunk(chunkX, chunkY, chunkZ);
                Singleton.chunks.Add(chunkKey, chunk);
            }

            var closestColor = ColorpickerController.GetClosestColor();

            chunk.AddCube(Mathf.Abs(x - chunkX * 16), Mathf.Abs(y - chunkY * 16), Mathf.Abs(z - chunkZ * 16), closestColor.x, closestColor.y);
        }