I want my game to have a number of 'treasures' on each level. When the player finds them they get to keep them, even if they die before finishing the level. However, once a treasure is found, it should no longer appear on the level in future level replays.
My plan is to give each treasure object an instance variable called treasureID with a value unique to that treasure, and have a CSV string key in my saveGameDictionary called "treasuresFound". When a treasure is found, I'll add its treasureID to treasuresFound. On start of layout, I'll delete any treasure objects whose treasureID is in treasuresFound.
One sticking point is creating the treasureID value. I don't want to manually create them in the Layout editor when placing the treasure objects, because this will be very tedious and time consuming as I will have hundreds of treasures. It will also be prone to error - how will I be sure I didn't accidentally use the same treasureID twice across different layouts? So instead, I want a way to automatically set treasureID values that will be consistent with future plays of the game/levels.
Any idea on how to do that? I don't think using the treasure UID is an option, since I believe that can change from one game play to the next.
Thanks