Best way to cycle through different generation settings?
Ok, so I'm messing around making terrain using procedurally generated meshes in a 2D sidescrolling platformer type game. I have made it so that there are different types of terrain that can be generated but I don't change these within the scene, they're there so I can have different scenes with different types of terrain. I currently have three types and I call each one regularLand, sandDunes and mountainLand. Basically, in sandDunes the generated mesh follows a wavey pattern, in mountainLand the mesh constantly slopes downward and then in regularLand I have further sub types. Inside of regularLand I can randomly produce a startIsland, midIsland, endIsland to make one long island piece one piece at a time. There is also a smallIsland which is as it sounds and lastly bridgeTerrain, again as it sounds, just the mesh is really thin here.
The way I have set this up is by creating an enum called MainTerrainType and this includes regularLand, sandDunes and mountainLand. Then I have another enum called RegularLandSubTerrainType which includes startIsland, midIsland, endIsland, smallIsland and bridgeTerrain.
Now, I'm relatively new to Unity and coding and this feels really cumbersome and as if it's really bad coding practise. This is because throughout the rest of my code I need to test what type of terrain the class is currently producing, like I use the midIsland terrain to place a cave type thing, for example:
if(mainTerrainType == MainTerrainType.regularLand && regularLandSubTerrainType == RegularLandSubTerrainType.midIsland) { //Make a cave and place cave prefabs. }
or
if(mainTerrainType == MainTerrainType.regularLand && regularLandSubTerrainType == RegularLandSubTerrainType.startIsland) { //Make startIsland and make the start of the mesh sloped and the end of the mesh flat ready for the next piece. }
Can you see what I mean? What would be a good way to do this better? Also, I let the decision on what terrain to make next up to the script with hardcoded variables. I'd prefer to use public ints to set different variables for different scenes. So at the moment, startIsland can only transition to either midIsland or endIsland. I create a random int between 0 and 100 and say, if the int is <= 20 goto midIsland, if its >= 21 goto endIsland. But to have public ints for all the possible transitions seems like poor code and I'd have a massive list of public ints in the Inspector. I wouldn't mind coding it, but is there a better way?
Thanks in advance.
Your answer
Follow this Question
Related Questions
How to spawn in loop like snail but in square 0 Answers
Procedural Generation : Grass placement 2 Answers
Road on Low-poly Terrain?? 0 Answers
Diamond Square Algorithm Problems 0 Answers
Triangles for sphere 0 Answers