Book Image

Mastering LibGDX Game Development

By : Patrick Hoey
Book Image

Mastering LibGDX Game Development

By: Patrick Hoey

Overview of this book

Table of Contents (18 chapters)
Mastering LibGDX Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Shop store UI with items and money transactions


The final point of discussion in this chapter is the StoreInventoryUI class, as shown the following screenshot (Figure 11):

Figure 11

This class allows the player the ability to trade with various NPCs and is a fundamental feature for any RPG. This class is also a good example of how events can be triggered from a conversation, as we have discussed in the previous section, such as when we wish to see the wares of a shopkeeper.

The overall class relationship is represented in the following class diagram (Figure 12):

Figure 12

Again, PlayerHUD acts as a relay between the different UI windows that it owns, communicating relevant notifications. One such communication is when the player's money (GP) is updated, an event gets triggered. If the money is updated in the StoreInventoryUI, the PlayerHUD will communicate that change to the StatusUI and the player's GP will be updated accordingly, and vice versa. We will also have observers on the InventorySlot...