Common shapes
Six small Platformer methods show the graph forms that keep appearing in gameplay code.
On this page
A method can look unique in C# while using a shape you already know. These six come from the Platformer’s real runtime scripts. Each page names the game problem, traces the graph, shows the current source, and makes one small extension visible.
Pick the shape
Section titled “Pick the shape”- Guard clause:
Door.Enterleaves early for a missing player, locked goal, or completed level. - Count and threshold:
ScoreCounter.OnCoinCountChangedturns a coin total into a door decision. - Switch on a state:
EnemyStateMachine.ApplyStategives each state its own calls. - Turn at the edge:
EnemyPatrol.FixedUpdatereverses at the left or right bound. - Scan a list:
PlayerMotor.UpdateGroundedfinds the first contact normal that points up past the grounding threshold. - Call a neighbor:
PlayerController.CollectCoinpasses work to the coin, score, HUD, and audio components.
Read the flow guides when the white exec wire is the question. Read calls and data when the receiver, argument, or returned value is the question.
- Guard clause: start with the smallest control-flow shape.
- Flow: learn branches, loops, switches, returns, and throws.
- Calls and data: learn calls, reads, writes, operators, and values.