Thursday, April 2, 2015

Working on the inventory system

Ahoy, yarrr.
Why the pirate sounds, you might ask.
Well, yes, as you probably was thinking, the reason for that is totally random.


Anyway, I'm now working on a inventory system.
It's not the first time I try to model a item system and I remember that I always struggled to that.
But this time seems to be going in an interesting way.
All thanks a post I've found in some forum were people were talking about how to make a inventory system.

Well, I show you how it's now (it's a bit crude but it's just to show how the interaction goes).

1. The inventory will show both the player and the slave inventory.

2.Clicking on an item will open a context menu which can have 1 or more actions. For example: Equip, Use, Sell... In the example here bra is a dress and so can be equipped.

3. Selecting Equip will move the item to the girl inventory and equip it (as you can see by the subtle white under the top)



Now, for the technical part. How the Inventory system actually work.
Earlier I said I read the post. That post actually kinda opened my mind.
One of the people told to just make a base class Item and then subclass to make more specialized items.
E.g. Item -> EdibleItem -> Cake

That's was my idea at first, but then someone wrote something like this:
Instead of subclassing you should think an Item as a set of feature.
BOOM. That blow my mind.

Long story short, items in game are substantially just a named container for action you can do with them.
For example the bra we have seen in the images is an Item named bra, which contains an action named Equip. The Equip action when called move the item to the slave inventory and equip it.

This let me attach behaviour to the object freely.
Next thing I'm gonna do is to create some kind of store in the game and add a Sellable action for the items.


Okay, that's to much for one post, so see you next time YAAAARRR

No comments:

Post a Comment