Switch Statements to the Rescue
Ok, let’s add a new PowerUp to our game. We need some shields to protect our player.
Our switch statement makes it a snap in Unity.
Picking up a PowerUp (from a 2dCollision), we can identify which PowerUp routine to execute based on the value held in the powerupID variable held on the Powerup.
Assigning the ID is done in the UI since we’ve Serialized the field: