public void GenerateNewMap() { details.SetActive(false); visualizer.SetActive(true); if (firstTime) { mapData = new int[width * height]; tileData = new GameObject[mapData.Length]; for (int i = 0; i < mapData.Length; i++) { mapData[i] = i % 2; tileData[i] = Instantiate(floorTile, visualizer.transform); if (mapData[i] == 0) { tileData[i].GetComponent <SpriteRenderer>().color = wallColor; } Vector3 newPos = tileData[i].transform.position; newPos.y = (height / 2) - (i / width - .5f); newPos.x = (width / 2) - (i % width); tileData[i].transform.position = newPos; } firstTime = false; } Map_Randomization random = new Map_Randomization(); random.width = this.width; random.height = this.height; random.GenerateLevel(); this.mapData = random.mapData; DisplayMapData(); }
private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Map_Randomization random = new Map_Randomization(); random.width = this.width; random.height = this.height; random.GenerateLevel(); this.mapData = random.mapData; DisplayMapData(); } }