private void OnGUI() { GUI.skin = skin; //GUI.Label(new Rect(10,10,100,40),"Build Mode: "+runtimeBuilder.GetCurrentBuildMode()); if (isShow) { int x = 0; int y = 0; int yOffset = 0; GUI.Box(new Rect(0, 80, 1050, 750), "Tiles"); for (int i = 0; i < allCategories.Count; i++) { if (allCategories[i].name.Equals("Street") || allCategories[i].name.Equals("Street_dynamic")) { for (int j = 0; j < allCategories[i].allTiles.Count; j++) { // Get Tile from current cateogry tiles uteRuntimeBuilder.Tile tile = (uteRuntimeBuilder.Tile)allCategories[i].allTiles[j]; GUI.Box(new Rect(10 + (x * 125), 100 + (y * 175) + yOffset, 120, 175), tile.name); if (GUI.Button(new Rect(10 + (x * 125), 240 + (y * 175) + yOffset, 120, 30), "BUY")) { // Set selected tile for building runtimeBuilder.SetCurrentTile(tile.mainObject); // Hide list isShow = false; } // Draw Tile preview texture GUI.DrawTexture(new Rect(15 + (x * 125), 125 + (y * 175) + yOffset, 110, 110), tile.preview); // Show tile name //GUI.Label(new Rect(14+(x*125),100+(y*175)+yOffset,120,125),tile.name); x++; if (x == 8) { x = 0; y++; } } yOffset += 175; x = 0; } } } // Show/Hide items if (GUI.Button(new Rect(450, Screen.height - 70, 200, 70), "ITEMS")) { if (isShow) { isShow = false; } else { isShow = true; // Cancel current Tile runtimeBuilder.CancelCurrentTile(); } } if (GUI.Button(new Rect(10, Screen.height - 70, 200, 70), "Mass Build")) { runtimeBuilder.SetBuildMode(uteRuntimeBuilder.BuildMode.Mass); } if (GUI.Button(new Rect(220, Screen.height - 70, 200, 70), "Normal Build")) { runtimeBuilder.SetBuildMode(uteRuntimeBuilder.BuildMode.Normal); } if (GUI.Button(new Rect(Screen.width - 200, Screen.height - 70, 200, 70), "Rotate")) { runtimeBuilder.RotateCurrentTileLeft(); } }
private IEnumerator GenerateMapProcedurally() { // Disable mouse Input while map is generating runtimeBuilder.DisableMouseInputForBuild(); int x = 0; int xSize = 80; int z = 0; int zSize = 80; uteRuntimeBuilder.Tile tile; for (int i = 0; i < xSize * zSize; i++) { // Get Tile from Category by Tile Name tile = runtimeBuilder.GetTileFromCategoryByName(mCraftCategory.name, "water"); // Pass Tile mainObject to RuntimeBuilder runtimeBuilder.SetCurrentTileInstantly(tile.mainObject); // Place Tile at Vector3 position runtimeBuilder.PlaceCurrentTileAtPosition(new Vector3(x - 25f, 0, z - 25f)); if (x > 10 && x < xSize - 10 && z > 10 && z < zSize - 10) { tile = runtimeBuilder.GetTileFromCategoryByName(mCraftCategory.name, "grass"); runtimeBuilder.SetCurrentTileInstantly(tile.mainObject); runtimeBuilder.PlaceCurrentTileAtPosition(new Vector3(x - 25f, 1, z - 25f)); if (Random.Range(0, 10) == 0) { for (int j = 0; j < Random.Range(4, 10); j++) { tile = runtimeBuilder.GetTileFromCategoryByName(mCraftCategory.name, "stone"); runtimeBuilder.SetCurrentTileInstantly(tile.mainObject); runtimeBuilder.PlaceCurrentTileAtPosition(new Vector3(x - 25f, 2 + j, z - 25f)); } } else if (Random.Range(0, 10) == 0) { for (int k = 0; k < Random.Range(2, 5); k++) { tile = runtimeBuilder.GetTileFromCategoryByName(mCraftCategory.name, "dirt"); runtimeBuilder.SetCurrentTileInstantly(tile.mainObject); runtimeBuilder.PlaceCurrentTileAtPosition(new Vector3(x - 25f, 2 + k, z - 25f)); } } } x++; if (x == xSize) { yield return(0); x = 0; z++; } } // Enable mouse Input runtimeBuilder.EnableMouseInputForBuild(); runtimeBuilder.CancelCurrentTile(); }