There are multiple methods to deal with this.
- You could create an enum with custom values that you could refer to:
public enum Grenades { Standard = 5, Cluster = 10, }public enum Grenades { Standard = 5, Cluster = 10, }
You can then refer to it by int value = Grenades.Standardint value = Grenades.Standard
- You could use a dictionary to store values:
You could use a dictionary to store values:
Dictionary<string, int> grenades= new Dictionary<string, int>(); grenades.add("standard", 5); grenades.add("cluster", 10)
int value = grenades["standard"];
Dictionary<string, int> grenades= new Dictionary<string, int>(); grenades.add("standard", 5); grenades.add("cluster", 10)
int value = grenades["standard"]
Note: You may be better off building one script for grenades and possibly using prefabs for each of the values.
Link to dictionary info https://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx
Link to enum source https://msdn.microsoft.com/en-us/library/sbbt4032.aspx