Coding a Mission System

posted in KrisWolfe
Published July 17, 2019
Advertisement

I finished a dialogue system so that it will take any number of dialogue sentences that require a button press to move to the next sentence, then can handle any number of dialogue options from that choice. The map can loop on nodes and really go anywhere, along with code to run once the dialogue finishes.

 

Having set that up, I wanted to work on a mission manager. I wanted this to be completely divorced from my other managers and just listen in on the other systems. It would, unfortunately, need to know what's out there, but that's a simple compromise for now until I can learn to pass events and delegates through methods.

The mission manager is nice. For now I have two types of missions. The first is to stockpile resources, the other is to build a number of a certain building. I quickly discovered some powerful features of properties.

I realized that I did not need to define a delegate for every event. I defined one delegate, which was resource changed, that passed an integer. I then declared an event for each resource, then had a a small method to invoke the event.

But here's the cool part. I put this method inside the setter of the resource integer. So now my mission manager checks which resource it needs to listen to, and then registers for the resources event to a simple method that updates the mission text. So everytime the resource count is changed, we automatically update the on screen mission text that the player sees. No update needed.

I really like these types of solutions. The mission system is ready, the dialogue system is ready, and the building system is ready. Time to polish with animations and fill our databases with assets.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement