public void initiate() { poolmanager.instance.initiate(); elementaryAffection.instance.initiate(); if (_map == null) { _map = new GameObject("(" + mapSize + "x" + mapSize + ") map"); mapData data = _map.AddComponent <mapData>(); mapGfx gfx = _map.AddComponent <mapGfx>(); mapGenerator generator = _map.AddComponent <mapGenerator>(); List <string> layerNames = new List <string>() { "ground", "path", "decoration", "tower" }; data.mapSize = mapSize; data.layers = layerNames; data.initiate(); layerNames.Add("waypoint"); gfx.prefixIdentifier = new List <string>() { "basis", "ground", "spawn", "bottomLeftPath", "bottomRightPath", "horizontalPath", "upperLeftPath", "upperRightPath", "verticalPath" }; gfx.initiate(layerNames); generator.buildBoardFoundation(data, gfx); generator.buildRandomBoard(data, gfx); gfx.instantiateBoard(data.getBoard(), data.mapSize); createWavesystem(generator.startWaypoint); } else { Destroy(_map); _map = null; Destroy(_wavesystem); _wavesystem = null; elementaryAffection.instance.reset(); initiate(); } }