internal void InitLevel(int withd, int height, GameObject pBaseTile, GameObject parentElement, scr_LevelManager_proc lMng, Texture2D inputLayout = null) { TerrainHeight = height; TerrainWidth = withd; lvlManager = lMng; baseTile = pBaseTile; ground = new byte[TerrainWidth, TerrainHeight]; above = new byte[TerrainWidth, TerrainHeight]; ground_trs = new Transform[TerrainWidth, TerrainHeight]; above_trs = new Transform[TerrainWidth, TerrainHeight]; ground_msh = new MeshFilter[TerrainWidth, TerrainHeight]; above_msh = new MeshFilter[TerrainWidth, TerrainHeight]; ground_col = new BoxCollider[TerrainWidth, TerrainHeight]; above_col = new BoxCollider[TerrainWidth, TerrainHeight]; ground_ren = new Renderer[TerrainWidth, TerrainHeight]; above_ren = new Renderer[TerrainWidth, TerrainHeight]; for (int i = 0; i < TerrainHeight; i++) { for (int j = 0; j < TerrainWidth; j++) { ground[j, i] = 11; above[j, i] = 0; if (ground_trs[j, i] == null) { ground_trs[j, i] = Instantiate(baseTile, new Vector3(j - (TerrainWidth / 2), -1, i - (TerrainHeight / 2)), Quaternion.identity).transform; ground_msh[j, i] = ground_trs[j, i].GetComponent <MeshFilter>(); ground_col[j, i] = ground_trs[j, i].GetComponent <BoxCollider>(); ground_ren[j, i] = ground_trs[j, i].GetComponent <Renderer>(); ground_trs[j, i].parent = transform; } if (above_trs[j, i] == null) { above_trs[j, i] = Instantiate(baseTile, new Vector3(j - (TerrainWidth / 2), 0, i - (TerrainHeight / 2)), Quaternion.identity).transform; above_msh[j, i] = above_trs[j, i].GetComponent <MeshFilter>(); above_col[j, i] = above_trs[j, i].GetComponent <BoxCollider>(); above_ren[j, i] = above_trs[j, i].GetComponent <Renderer>(); above_trs[j, i].parent = transform; } } } if (inputLayout != null) { SetMapToTextureLayout(inputLayout); } }
public List <Transform> TransList_Gale_ground; // gelb void Awake() { if (inst != null) { Destroy(this); return; } inst = this; currentLevelParent = Instantiate(basicEmpty); currentLevel = currentLevelParent.AddComponent <scr_Level_proc>(); currentLevelParent.name = "Terrain"; currentLevel.InitLevel(TERRAINWITH, TERRAINHEIGHT, baseTile, currentLevelParent, this, Img_LevelInput); currentLevel.ConstructBorder(); }