Game
Hensen Hopper
5 months ago

Alright! Got that message system put together!


The message hub script itself looks a lot more complicated than it actually is. I'll explain how it works:

image.png

To put it to words, any script can send a message to the message hub by calling Messages.Send to be saved for the remainder of the frame in a C# List. All a List is, by the way, is a script in the C# standard library that enhances arrays by allowing you to add/remove items from an array during runtime, they're useful in cases where you do not know how big an array will need to be.

Since Lists are typically a lot larger than an array of their count (among a few other reasons I made this decision) rather than having the list be the primary source from which messages are read, at the end of the frame, all messages stored in the list are copied to an array of "recieved" messages that may be read during the next frame update via the value returned by Messages. Read (sorry for the space, Game Jolt was auto-link-ifying that for some reason) and the list is deleted and a brand new one created for the next frame.

This is a lot better for my quest system than what I had before because now, rather than messages being sent directly to the quest manager (which I disliked as it creates a dependency between potentially many scripts and the quest manager), any script can just send messages into the wind and that information may or may not be utilized by other scripts. The only weakness this system has is other scripts aren't technically reading messages sent during the same frame but the ones sent during the PREVIOUS frame (because the list is copied over in the LateUpdate method). Granted, for the purposes of the quest manager, this doesn't particularly matter.

image.png

The quest manager itself is relatively unchanged, I simply replaced the ReportAction method with the code shown in the screenshot above. On Start we create a dictionary mapping whatever messages are relavent to todays quests to integers in order to keep track locally of how many times a quest-relevant message has been recieved by the message hub, this information is updated once per frame.

This is a much cleaner way to handle the quest event reporting than the previous approach because now, rather than every enemy script sending messages directly to the quest manager, whenever a soldier enemy is defeated, a message reading "defeated_soldier" is sent to the message hub and it, of course, matters not to the message hub whether this information is utlized because it does it's thing either way.

Whenever there IS a quest manager in the scene, this message will, of course, mean something as the quest manager will read the messages from the message hub and use this information for it's purposes. Say the user has a quest to defeat a certain number of soldiers, then this message will be checked by the quest manager and the value paired to it there is incremented every time the message is found in the array returned by Messages. Read.



0 comments

Loading...

Next up

Here's a short video showing off the improved gameplay loop and "stage complete" screen. The updated artwork for Hensen and his gun and the honey bullets can also be seen.

Very unfinished but the backdrop image, as it is in this video, is already leagues better than what I had last weekend! I'm going to work on it incrementally over the coming weeks as I work on implementing the stages idea I talked about before!

This is just about the only situation in which I'll ever do this. I almost never put multiple calls to methods on the same line but here I've logged a warning to remind furure me to do something I didn't have time to do today in a glaringly obvious way.

Doki Doki Literature Club is celebrating Monika's birthday and the 8th anniversary of DDLC with exclusive stickers, avatar frames and backgrounds on Game Jolt! 

Head over to the shop to collect yours 👉 https://gamejolt.com/#shop

I've been working on the backdrop today! Among other things I've done, I made a bush! I know, SOOOO impressive lol.

Play @pm-studios ' Bandit Trap Open Beta!

Grab your rocket chairs, vacuums, and toilet tornadoes! Report one more time for our final beta! Live through March 23rd 6 am CET.

Complete quests based on the game!

Play the beta: https://bit.ly/BanditTrapBeta

I've worked out a process for drawing bushes that I'm using for the backdrop! First I draw the branches, then "paint" where the bush texture will be, copy it's alpha to a new layer in white, then draw it's shadows in a layer over the bush layer.

Been working on the artwork for the "stage complete" screen all morning! Right now I'm improving the shadows/shading for Hensen because he is a part of that screen. I do need to work out the contrast between the text and the backdrop image, I know.

This week's Fan Art Friday celebrates Bandit Trap! Accept the quest in your quest log to get started.

Defend your home or steal treasure in the open beta: https://bit.ly/BanditTrapBeta

Okay, so the stages and score saving are both more or less working. Your score and high score will be saved throughout the lifetime of the application. Currently nothing saves when the game is closed, though, I'll be working on that next weekend.