Example #1
0
 /// <summary>
 /// Применение темплейта
 /// </summary>
 /// <param name="template"></param>
 void SetTemplate(ChunkTemplates.Template template)
 {
     Debug.Log("Chunk SetChunk");
     currentTemplate = template;
     for (int y = 0; y < ChunkTemplates.chunkHeight; y++)
     {
         for (int x = 0; x < ChunkTemplates.chunkWidth; x++)
         {
             //Debug.Log(x + " " + y);
             mapGenBlocks[y][x].SetBlockType(template.elements[y * ChunkTemplates.chunkWidth + x].ttype);
         }
     }
 }
Example #2
0
        public ChunkTemplates.Template GetTemplate()
        {
            Debug.Log("Chunk GetTemplate");
            ChunkTemplates.Template template = new ChunkTemplates.Template();

            for (int i = 0; i < mapGenBlocks.Length; i++)
            {
                for (int k = 0; k < mapGenBlocks[i].Length; k++)
                {
                    ChunkTemplates.Block block = new ChunkTemplates.Block();
                    block.ttype       = mapGenBlocks[i][k].blockType;
                    block.coordinates = new Vector2Int(k, i);

                    template.elements[i * ChunkTemplates.chunkWidth + k] = block;
                }
            }

            return(template);
        }
Example #3
0
        /// <summary>
        /// Возвращает матрицу текущего шаблона
        /// </summary>
        /// <returns></returns>
        public ChunkTemplates.Template GetTemplateMatrix()
        {
            Debug.Log("Chunk GetTemplateMatrix");
            ChunkTemplates.Template template = new ChunkTemplates.Template();
            for (int i = 0; i < mapGenBlocks.Length; i++)
            {
                for (int k = 0; k < mapGenBlocks[i].Length; k++)
                {
                    ChunkTemplates.Block block = new ChunkTemplates.Block();
                    block.ttype       = mapGenBlocks[i][k].blockType;
                    block.coordinates = new Vector2Int(k, i);

                    template.elements[i * ChunkTemplates.chunkWidth + k] = block;
                }
            }
            template.ttype = currentTemplate.ttype;

            template.topExit    = currentTemplate.topExit;
            template.bottomExit = currentTemplate.bottomExit;
            template.leftExit   = currentTemplate.leftExit;
            template.rightExit  = currentTemplate.rightExit;

            return(template);
        }