I am creating a procedurally generated side scroller and I have a question regarding proper code structure/Architecture when it comes to connecting different platforms and large scale cases. There are various platform types I need to connect (e.g. a hill which leads into a tunnel which then leads into a cave, etc). I can successfully generate and connect the meshes using a bezier curve. My problem is that the way I am handling each platform connection case seems very clunky/inelegant the more I expand.
Currently I am using switch statements to handle each scenario like the above mentioned. Below is a small snippet of how I am handling each case.
public void SetTransition(int PrevPlatform, int CurrPlatform , Vector3 LastPosition)
{
switch (PrevPlatform) {
case 0:
GroundTransition (CurrPlatform,LastPosition);
break;
case 1:
CaveTransition (CurrPlatform,LastPosition);
break;
case 2:
WaterTransition (CurrPlatform,LastPosition);
break;
case 3:
TunnelTransition (CurrPlatform,LastPosition);
break;
case 4:
WallJumpTransition (CurrPlatform,LastPosition);
break;
}
}
From here I have separate functions that handle the cases using more switch statements. The problem now is that I am starting to have a large number of branching functions that are relying each case. My code structure is becoming this large tree of switch statements. For the most part it works but I wanted to reach out to other developers before I continued this route. Is there a more effective, organized methodology to handling large scale cases?