Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- public struct Potion
- {
- public Potion(string name, float speed, float scale, string sprite)
- {
- m_Name = name;
- m_Speed = speed;
- m_Scale = scale;
- m_Sprite = sprite;
- }
- public string m_Name;
- public float m_Speed;
- public float m_Scale;
- public string m_Sprite;
- }
- public static Dictionary<string, Potion> PotionDictionaryExample = new Dictionary<string, Potion>();
- public static List<Potion> PotionListExample = new List<Potion>();
- static void Main(string[] args)
- {
- ///////////////
- //DICTIONARY
- //If you need to access the potions by name use a dictionary
- //setter
- PotionDictionaryExample["Potion 1"] = new Potion("Some name", 5.0f, 1.0f, "image_of_a_potion.tif");
- //getter
- Potion potionFromDict = PotionDictionaryExample["Potion 1"];
- //print example from your paste
- foreach (var potion in PotionDictionaryExample)
- {
- Console.WriteLine(String.Format("{0} {1} {2} {3} {4}",
- potion.Key,
- potion.Value.m_Name,
- potion.Value.m_Speed,
- potion.Value.m_Scale,
- potion.Value.m_Sprite));
- }
- ///////////////
- //LIST
- //If you just need to access via index eg: Potions[0] use a list
- //setter
- PotionListExample.Add(new Potion("Some name", 5.0f, 1.0f, "image_of_a_potion.tif"));
- //getter
- Potion potionFromList = PotionListExample[0];
- //print example from your paste
- foreach (var potion in PotionListExample)
- {
- Console.WriteLine(String.Format("{0} {1} {2} {3}",
- potion.m_Name,
- potion.m_Speed,
- potion.m_Scale,
- potion.m_Sprite));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement