Week 9 Crystal Movement Refactor and Week 10 Supercharge Implementation

Published March 24, 2024
Advertisement

Over Spring Break, I worked with another programmer to refactor our painful system for crystal movement. The system involved three different scripts that did not work together very well and was not built with Unity’s input system in mind at all. Thankfully, the other programmer was able to parse the mess to set up a good system that he wanted help with integrating our CrystalManagement script and debugging.

Start of a long list of conditionals comparing what is selected to what is hovered over

My work on this was focused on the implementation of CrystalManagement methods into the new home for the input system for crystal movement, UIManager. The other programmer wrote the basic layout here, and I was tasked with making it work with CrystalManagement. A lot of stuff we were able to copy and paste over with minimal tweaking. However, there were a few times that strenuous bugs popped up or rewrites needed to happen. This included our method ProcessQueue that is meant to process the current item at the head of the queue and deal with what happens after.

Method that process our queue and acts accordingly depending on the state of the queue

This is much cleaner than before. It empties a list of currently spawned items, as well as dequeues the item that was just interacted with. If the queue is empty, the gameplay resumes, otherwise we peek at the next item and instantiate the appropriate object.

This past week, after the refactor was done, I still needed to reimplement the code I had written for Supercharging our crystals. Before this process included applying another new script to an object and adding a buff type object of type Supercharge to the front of our queue. The new script would then call another CrystalManagement method to supercharge if the object was clicked. This was overly complicated. Now the prompt or method for supercharging is called in our UIManager.

SuperchargeCrystal method called by buttons or the discarding of enough crystals
UIManager conditional checking for Supercharge object

The bulk of this implementation came from ensuring no problems were encountered through the implementation of the code in UIManager above and adding new code to our ProcessQueue method to account for a Supercharge type buff object.

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