Hey everyone,
I am working on an inventory system and I got stuck in a tiny part. My inventory system is a "render" only system -- basically it doesn't hold any information aside from what to display and even then that is temporary. I want to know how can I loop over my dictionary keys and over all current slots of type "ingredients" for example and then change the slot animations accordingly.
Elaborating on this, here is what I have.
I created a sprite called "InventorySlot". It has one instance variable called "category". This identifies what kind of slot is it; weapons, potions, armor, etc...
InventorySlot has a few animations, these animations are the icons for each of the items in the game. On the other hand I have a Dictionary called "Inventory" it has a key for every item in the game with a value referring to the amount the player has.
What I want to basically do is this:
For every key in the dictionary, find all InventorySlots in the layout. Set the first InventorySlot to the first key and the second InventorySlot to the second key and so forth...
I thought this would be easy and what I tried is setup an Event with "For Each Key in Dictionary" with a Sub Event "InventorySlot > category is equal to "Weapons" and then an action "Set InventorySlot animation to Inventory.CurrentKey.
This didn't work even though the keys and animations have the same exact names. What I got is all slots are set to the last key since the loop picks ALL InventorySlot in each iteration. So I am not sure how to tell the loop to pick one by one and set their animation and once it picks one, it skips (breaks) this iteration and moves on to the next iteration.
Any ideas?