Phase 2: Ammo UI
Objective: Create a visual representation of the players ammo
Following on from the last post, we will now add the ammo UI elements in a similar way as the thrusters fuel level. We add the neccessary UI element inside the canvas (UI Image) then set the source image. Inside the UIManager script, create a serialized image and a serialized sprite array. Move to the inspector and set the images for the ammo is the correct order from sprite 0 up with zero being no ammo. for this case add one extra sprite for when the chaos powerup is in effect as we have a special sprite with a power color to use for the duration of the powerup.
Inside the UIManager script we edit the previous UpdateAmmo method to set the UI Image to the Sprite array value of the ammo. We add an isChaosActive bool that is activated in a public ChaosActive method that has the bool value passed from the player script when activated and deactivated. Inside the Update ammo we check to see if Chaos is active and use the special ammo sprite in this case and if not use the sprite variant to match the ammo.
In the next post, we will look at adding a negative collectable