Display Max Ammo on UI
Currently we only display the current ammo on the UI screen. Today we update the UI to also show the max ammo. We could hard code this since the max ammo count shouldn’t change normally. This has some drawbacks in case the game balance is changed by changing the max ammo or new power ups are added that change the max ammo. Then all hard coded values need to be changed every time.
To prevent this we get the max ammo value directly from the player script.
public void UpdateUIAmmo(int currentAmmo, int maxAmmo)
_ammoText.text = currentAmmo +”/”+ maxAmmo;
Update Player Script
Updated the code to pass in the max ammo count aswell everytime we call the function.
Small Bug Fix
When the game is started the ammo text was set in the UI Manager Script to 15. We changed it to update it from the Player Script when the game is started. Since the current ammo and max ammo come from the player script we will call the update ammo count method at the start.