I am running into an issue of trying to implement an inventory system within XNA (doesn't really matter, could be any platform) but so far. Here is the issue I am trying to wrap my head around:
How can I get an item from the world (think when you kill a monster it drops armor) and get it into my player's inventory?
If an inventory is just a list of items, technically, how could I get Steel Sword from the world into my player's inventory without having a class do more than one thing?
I currently have an item struct, which contains a unique hex value, a count of how many items there are (for stackables, like arrows) and a Texture for rendering within the inventory, and some other unimportant properties (name, description, etc).
It would be bad design if I had to modify my existing item class to house a world position, along with collision detection (don't want the item falling through the earth).
Thanks for any considerations!
WorldItemwhich is seperate to yourInventoryItem? (Maybe theWorldItemhas anInventoryItemtemplate that's put into the player's inventory when picked up). – George Duckett Jan 4 '12 at 13:28Inventorythat takes aWorldItemand adds it asInventoryItem. So that it could also handle cases where items need to stack (eg. Arrows). – bummzack Jan 4 '12 at 13:36