Apr 2021 – Jul 2021 (12 weeks, University Project)
Cyberspace Liberation is a top-down, roguelite game with procedurally generated levels. Shoot and dodge through Cyberspace to stop the entity Triankolos from taking over.
Team size: 10
Game Engine: Unity
Tasks: Design, Programming, Writing
Player Character Controller
Implementation-wise my main work on this project consisted of designing and implementing the player controller, which included processing player inputs and reacting to them accordingly by moving the player character and camera, executing abilities, or shooting and triggering the accompanying sounds and visual effects.
The player character controller was implemented using the reactive framework Uni.Rx. Unity’s input system was wrapped with the PlayerCharacterControllerInput class using reactive properties. This allowed the PlayerCharacterController class to subscribe to the inputs and then wait for an event to come in rather than checking whether an input event occurred every frame. The PlayerCharacterController then processes the inputs and reacts accordingly.
The player also has several abilities that they could use. These are mostly implemented as their own classes that the PlayerCharacterController then calls through composition.
Unfortunately, the reactive nature of the PlayerCharacterController made the code harder to debug. The code was also hard to maintain as I did not always extract functionality into corresponding functions.
You can can find code samples for the PlayerCharacterController and input wrapper here and for the Abilities here.
Projectiles
I implemented a base class for projectiles that was used for the player character’s projectiles, and one of the player’s abilities. I also refactored the enemy projectiles to be based on this projectile class.
A projectile is shot by the ProjectileLauncher class which determines how quickly an entity can shoot how much ammunition it has, and what type of projectile it shoots. It also deals with the logic of spawning the projectile and making sure is oriented correctly. The Projectile class itself deals with moving the projectile object and how much damage it deals.
Since the game was partially inspired by bullet hell games we knew that we would most likely spawn a large number of projectiles throughout the game, so I implemented object pooling for the projectiles within the ProjectileLauncher. In hindsight I realized that my implementation would have had a lot more impact had I pooled projectiles globally rather than for each entity individually. While this might have worked for the player character who was active for the duration of the full gameplay loop, the enemy characters were only alive until the player destroyed them. At that point, the characters and their projectile pool were destroyed. New enemies then each spawned their own projectile pool rather than reusing the projectiles already used by previous enemies.
The code for the projectile system is spread across these four classes: ProjectileLauncher, Projectile, SlowProjectile, and Bullet for the enemy projectiles.