We need a way to keep track of different types of ammo for different guns. we will do this with two data structures - a Dictionary and an Enumerator
It is a collection of key-value pairs, where each unique key maps to a specific value.Â
Just like a real-world dictionary, you can look up a word (the key) and find its definition (the value).
Enums, also referred to as enumerations, are a data type that contains a fixed set of constants.
Essentially it is a dictionary of constants.
Attach a new script to it
In the ammo_handler script
define the AmmoHandler as a class
Setup the enum to list the weapon types
Small bullets for the SMG, large bullets for the Rifle
Setup the dictionary variable called ammo_storage
This links the ammo types to the number of bullets
Define a has_ammo function to return true or false if we have at least 1 of a type of ammo
Define a use_ammo function to use up ammo of the type passed to the function if there is at least 1 bullet to shoot
Open the hit_scan_weapon script
Add an export var for the AmmoHandler
Add an export var for the ammo_type
Set the Ammo Type to Bullet
Do the same for the SMG but set Ammo Type to Small Bullet