Implemented a Level Handler

levelhandlereinspector

Implemented a LevelHandler
What?
The most recent implementation that I did was a so called “Level Handler” which is an object that you pull into a game scene, that lets you decide how this entire scene should behave during gameplay.
It has the possibility to easily manage the behavior of the entire level, changing spawn positions and change scenes and the different graphical user interfaces that we might need such during pause functions, cutscenes and so on.
It also keeps track of win and lose conditions and all the variables are changeable from the inspector so that the game designer can easily change them during play testing to see what works.
A note is that after its varibles in the inspector has been assigned, it automatically handles everything for the behavior of the game.
How?
I started off by creating a simple statemachine that the current scene could be in. I used “enums” for declaring what these would be and an example could be the pause state, running the game state or a cutscene state. This would let me easily see what would happen when it is in one certain state at one time since each state had its own function. An example is that when pressing a button for the pause function, it would switch state to the “Pause State” from that only certain things would work as well as displaying a GUI element on top of the screen that you could press and also pausing the game while in this state.
The entire handler would have as many variables public as possible for being easily changed by the game designer, and also using objects that are needed for the handler such as the player object, all the different scenes as well as GUI elements appropriate for this specific scene that the handler has been added to.
Since the handler got all the specific objects needed from the inspector, I could grab the components needed within the handler to check whether a state was true such as if the health of the playerobject had been depleted or if it had been killed by the mob that constantly chases the player. These would then call for either a scene or a cutscene depending on if there is a cutscene applied to the handler or not.
Basically, the handler just uses the other game objects within a scene and checks for conditions and do stuff if something is true or false, such as changing the scene.s

Why?
At one point in our game development, we felt that we needed a clear goal instead of aiming for small parts of it. That’s where we discussed how to handle all the behavior of a scene and found that creating such a manager would suit us well.
We wanted it to have all the possibilities of changing and playtesting different win and lose conditions. Since our game is quite short, predeclaring different states was appropriate of this manager so that testing the different conditions was beneficial and easily changeable.
The game designer needed to see what works the best and just by switching one of two variables in the inspector, the entire winning state could change.
Switching scenes and levels was also a big question for us, so this manager would also switch to cutscenes, change scene and also pause the game.

What else needs to be fixed?

– Fix a state for killing a certain amount of enemies, even though it is implemented, it recently got some bug.
– Being able to manager the other managers such as the enemymanager, depending on game state(Though this might be included in an upcoming “Event Handler”

About Christian Edberg

2016 Programming