Handling character level-ups
As I previously mentioned, in this section, you are going to level up your hero’s experience and skills. As usual, you’ll be dabbling in code magic to make it happen! After all, you are programming a fantasy game.
I know it might seem like a good idea to write your code inside the Character class but trust me when I say that there’s actually a much better spot for it. That is the PlayerState
class, which we incidentally have already set for this occasion – a while ago, I asked you to create the US_PlayerState
class and now is the time to add some valuable code in it.
As introduced in Chapter 4, Setting Up Your First Multiplayer Environment, PlayerState
is a class that holds information about a player’s game state and exists on both the server and clients. As we need to synchronize experience points and levels for the character, this is the ideal location to place everything.
What we need to do here is to keep...