Welcome to my next work update for my work on 310Games’ The Krilling! This week I will be continuing and hopefully finishing most of the system I was working on last week which was the scenario menu screen.
Getting right into it, from last week I made a blueprint of what types of tools I was going to use for the system to start displaying information within this menu. I did some work and here is where I have initially landed now:
You will notice most notably that the script is no longer practically empty! I have set it up currently so now whenever a scenario is changed it will display all the information for the next scenario right off the bat. You may notice, however, that right now it will only display ALL of the information for a scenario if that scenario only has 1 requirement, as there are no loops to iterate through multiple requirements. This is something I am going to handle next. I also made sure that any unused text boxes will stay inactive until they have information that needs to be populated. Here’s what all of those additions look like:
And when I play the game…
It works! There are usually 2 starting text boxes on the left and 1 of them get disabled, and the first scenario (for testing purposes) has 2 requirements that both get filled in. This should encompass base functionality of each individual chunk for now, so it is time to move onto the encompassing system that will add more chunks as the player passes certain milestones. Luckily, that functionality should look very similar to this one, just at a more zoomed out scale. I’ll keep a list of all of the chunks, set them to inactive when it isn’t their turn yet, and then set them active when it is their time to shine! Before I do that however, as I finished this portion of my work I was discussing how it worked with one of my teammates and they suggested that I should make a prefab of the text objects I am using here instead of manually adding all of them and then setting them inactive (it saves memory in the long run). So, I made two prefabs, one for the requirement texts, and one for the ingredient texts. The prefab is simply just a textbox, I only made it a prefab so I could use Instantiate on it, so I will just show you how the code changes here:
You will notice that now I am able to just instantiate each object 1 at a time, so I could change the requirements and not need to come and change anything within this menu and it will still function properly. I also store all of the instantiated text for later if we choose to somehow change the text displayed to reflect completion of the task. Now that this is done, I can go back to how I am doing the overall menu code which will reflect more closely how the chunks used to work. Here is that code:
And when I tested it, it… sort of worked!
The next chunk did show up… but no information was populated. This is because we are creating a race condition when we enable the chunk and also subscribe it when it gets enabled, so it misses the game event that triggers the population. To fix this, I made public methods for enable and disable that lets me turn off the visuals of the chunks while allowing it to stay enabled and subscribed to the game event. This also fixes the issue of a single chunk stretching to fix the whole screen which was something I was going to handle later but now I don’t have to. Here are the methods:
Here is the change to the Menu script:
And it all works together!
So, the images no longer stretch to weird proportions which was something on my list I got to fix as a byproduct from this and the information populated properly! Base functionality of this system is now complete, and it is time to put in art assets to make it look prettier.
I had to do some cropping and it is far from perfect right now, but we have a little more fine tuning to do anyways so this is a good place to have it for now.