Android game rpg inventory system

前端 未结 5 921
不知归路
不知归路 2021-01-12 04:37

I am using an ArrayList as my \"inventory\". I am having trouble figuring out a way to add multiples of the same item without taking up a spot in the \"inventory\". For exam

5条回答
  •  灰色年华
    2021-01-12 04:59

    You're probably better off creating a class called InventorySlot, with a quantity and contents field. This also give you the flexibility of adding other properties, such as what the inventory slot can contain, should you decide to create a 'potions' only sack or something like that.

    Alternatively, a StackCount and a boolean IsStackable, or perhaps MaxStack property is used in quite a few MMO's, it's a perfectly valid technique too.

提交回复
热议问题