//First, generate the map, and then save it as a Prefab. Then, add that prefab to the MapPrefab variable of the map object the Maps script in the Game Manager. public void ChooseMap() { var allMaps = GameManager.Instance.GetComponent <Maps>().allMapsDict; int menuIndex = mapSelector.value; List <TMP_Dropdown.OptionData> menuOptions = mapSelector.options; mapName = menuOptions[menuIndex].text; if (allMaps.ContainsKey(mapName)) { mapDetails.mapName = mapName; mapDetails.mapCode = allMaps[mapName].mapCode; mapDetails.enemyMax = allMaps[mapName].enemyMax; mapDetails.levelMin = allMaps[mapName].levelMin; mapDetails.levelMax = allMaps[mapName].levelMax; mapDetails.spawnInterval = allMaps[mapName].spawnInterval; mapDetails.width = allMaps[mapName].width; mapDetails.height = allMaps[mapName].height; //clear the active tiles and active towers list GameManager.Instance.activeTiles.Clear(); GameManager.Instance.activeTowers.Clear(); mapDetails.LoadMap(mapName); mapObject.transform.position = new Vector2(0f, 0f); loadTowerMenuBtn.interactable = true; GameManager.Instance.inGame = true; GameManager.Instance.activeMap = mapDetails; //mapDetailsObject.SetActive(true); worldMapObject.SetActive(false); } //mapObject.GetComponentInChildren<MapDetails>().DisplayMap(mapName); }
public void ImportMap() { GameObject[] maps = GameObject.FindGameObjectsWithTag("MapTile"); tileNumber = 0; for (int m = 0; m < maps.Length; m++) { Destroy(maps[m]); } string code = codeInput.text; mapDetails.LoadMap(code); return; }