Cast spells to defeat the candy monsters and journey to the top of Choco Mountain! Collect the keys from defeated enemies to unlock the lollipop gates along the way.
This was the first game I ever finished in Unity. On a team of three (one other coder and one artist), we explored for the first time things like sprite animation, an updating HUD, and a 2.5D world. My job was to write the code for the player character's interactions and animations, in addition to the smarties enemy.
I got a lot of experience with Unity's Mecanim animation state machine, but it was far from my favorite part of the project. What I enjoyed more was adding little bits of flair, like making the characters flash red when they take damage, making the player's spells travel up and down slopes, making collectibles explode outward when an enemy is destroyed, and making sure the enemy sprites are always facing the correct direction as they move towards the player.
To code the smarties enemy, I needed to make a few things work together. First, I detect when the player comes into the enemy's shooting range using a simple OnTriggerEnter() statement. Then I use a coroutine to fire off each of the individual discs, one by one, with a delay in between. I create a vector from the enemy's position to the player and set the disc's velocity in that direction; it doesn't update over time, so the player could potentially dodge the attack. Each individual disc needed to be able to damage the player, as well as to be able to be destroyed by the player's attacks, but hitting the column needed to destroy all of them at once, also. So I stored all of the discs under a parent GameObject (the one that controls the shooting), and gave it the enemy destruction code as well. When this GameObject detects that it has shot all of its children, it destroys itself automatically.
Besides the problem with spells and slopes, another issue we had with the map was its sheer size. At last count, the game had 19 areas, each densely populated with constantly moving and animating enemies. This resulted in a major performance problem. To solve it, we grouped all of the enemies in each area into its own GameObject, and added code to the Door script to turn them on and off whenever the player went through. By only ever loading the few areas ahead and behind the player at once, we were able to return to a normal framerate.