private void GenerateMap() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); if (useRandomSeed) { seed = Time.time.ToString(); } rand = new System.Random(seed.GetHashCode()); map = new Block[width, height]; ProcessMap(ProcessRandomFillMap); carveStartingZone(); for (int i = 0; i < smoothIterations; i++) { mapCopy = (Block[, ])map.Clone(); ProcessMap(ProcessSmooth); map = mapCopy; } for (int i = 0; i < coalVeinAmount; i++) { CreateCoalVeinSeed(); } for (int i = 0; i < gemVeinAmount; i++) { CreateGemVeinSeed(); } // Although there should technically be a mapCopy here... // The ores look better without it. /shrug // mapCopy = (Block[,])map.Clone(); ProcessMap(ProcessSolidSmooth); // map = mapCopy; ProcessMap(ProcessCreateTerrain); // Record the amount of time it took to generate map. stopwatch.Stop(); TimeSpan ts = stopwatch.Elapsed; string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); UnityEngine.Debug.Log("Time to generate map: " + elapsedTime); // Send map to A* grid. grid.CreateGrid(map); }
IEnumerator CreateRoomsCoroutine() { CreateRooms(); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); Vector2Int roomsSize = GetRoomsSize(); aStarGrid.gridSize = roomsSize; aStarGrid.CreateGrid(); Instantiate(brawler); }