Exemple #1
0
        public bool CreateMap(int x, int z)
        {
            bool negativeSize      = x <= 0 || z <= 0;
            bool multipleChunkSize = x % HexMetrics.chunkSizeX == 0 && z % HexMetrics.chunkSizeZ == 0;

            if (negativeSize || !multipleChunkSize)
            {
                Debug.LogError("Unsupported map size.");
                return(false);
            }
            ClearPath();
            ClearUnits();
            if (chunks != null)
            {
                for (int i = 0; i < chunks.Length; i++)
                {
                    Destroy(chunks[i].gameObject);
                }
            }
            cellCountX  = x;
            cellCountZ  = z;
            chunkCountX = cellCountX / HexMetrics.chunkSizeX;
            chunkCountZ = cellCountZ / HexMetrics.chunkSizeZ;
            cellShaderData.Initialize(cellCountX, cellCountZ);
            CreateChunks();
            CreateCells();
            for (int i = 0; i < cells.Length; i++)
            {
                cells[i].DisableHighlight();
            }
            return(true);
        }
Exemple #2
0
        public bool CreateMap(int x, int z, bool wrapping)
        {
            if (x <= 0 || x % HexMetrics.chunkSizeX != 0 ||
                z <= 0 || z % HexMetrics.chunkSizeZ != 0)
            {
                Debug.LogError("Unsupported map size.");
                return(false);
            }

            ClearPath();
            ClearUnits();
            if (columns != null)
            {
                for (int i = 0; i < columns.Length; i++)
                {
                    Destroy(columns[i].gameObject);
                }
            }

            cellCountX               = x;
            cellCountZ               = z;
            this.wrapping            = wrapping;
            currentCenterColumnIndex = -1;
            HexMetrics.wrapSize      = wrapping ? cellCountX : 0;
            chunkCountX              = cellCountX / HexMetrics.chunkSizeX;
            chunkCountZ              = cellCountZ / HexMetrics.chunkSizeZ;
            cellShaderData.Initialize(cellCountX, cellCountZ);
            CreateChunks();
            CreateCells();

            return(true);
        }