Skip to main content

There are multiple methods to deal with this.

  1. 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

  1. 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

There are multiple methods to deal with this.

  1. You could create an enum with custom values that you could refer to:

public enum Grenades { Standard = 5, Cluster = 10, }

You can then refer to it by int value = Grenades.Standard

  1. 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"]

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

There are multiple methods to deal with this.

  1. You could create an enum with custom values that you could refer to:

public enum Grenades { Standard = 5, Cluster = 10, }

You can then refer to it by int value = Grenades.Standard

  1. 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"];

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

typo
Source Link
DavidC
  • 281
  • 1
  • 8

There are multiple emthodsmethods to deal with this.

  1. You could create an enum with custom values that you could refer to:

public enum Grenades { Standard = 5, Cluster = 10, }

You can then refer to it by int value = Grenades.Standard

  1. 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"]

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

There are multiple emthods to deal with this.

  1. You could create an enum with custom values that you could refer to:

public enum Grenades { Standard = 5, Cluster = 10, }

You can then refer to it by int value = Grenades.Standard

  1. 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"]

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

There are multiple methods to deal with this.

  1. You could create an enum with custom values that you could refer to:

public enum Grenades { Standard = 5, Cluster = 10, }

You can then refer to it by int value = Grenades.Standard

  1. 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"]

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

Source Link
DavidC
  • 281
  • 1
  • 8

There are multiple emthods to deal with this.

  1. You could create an enum with custom values that you could refer to:

public enum Grenades { Standard = 5, Cluster = 10, }

You can then refer to it by int value = Grenades.Standard

  1. 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"]

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