The Shop


The shop is an integral part of this title as it allows the player to expand their options and play how they want to play. It also gives validity to exploring out of the way areas and retreading old territory to get more currency that you could not previously reach. Some of the core mechanics required for our shop was dialog to UI integration, currency check / exchange, obsoleting purchased stock,  and preventing the player from leaving the shop area without grabbing their items that they had purchased.

Working on the dialog to UI integration was the first of my troubles, but luckily an easier task. We already had a robust dialog system, so I just needed to hook up new UI elements and track to make sure everything was closing down when necessary. The currency check was one of the more enjoyable tasks albeit rather short in execution. Simply, I had to access the players data to see how much currency they had. Then if the player tried to purchase an item which was not already purchased, it would first check if the player had currency greater than or equal to the price. After that, I just need to adjust the players data to subtract the items cost from their current currency count. Obsoleting purchased stock brings me back to my new best friend, the saved data. Shop items for the HUB npc (and any future shop keepers) have an item id not too different from how the bestiary and map track their 'nodes'. If an item id is saved as purchased, the button in the shop is red and the text is striked through to indicate it is no longer available. At this point, the button is disabled in code. The last thing is a bit of an unusual addition to our game. When an item is purchased, the shop is shut down, the shopkeeper plays an animation, and the item is spawned. To prevent the player from somehow leaving the room without their item (and then having to worry about saving that gameobject to stay next to the shopkeeper) I added invisible walls to all shop items to prevent the player from leaving the shop area while an item is present. The only reason why the item does not go straight into the players inventory is because we had an animation for the shopkeeper handing over an item and we *had* to use it.