Project Rogue Dev Blog 3

Minor Bug Fixes, Game Over, and Loading Screen

Minor Bug Fixes

To begin, I was notified of a small bug in my code for the function that cleaned up the scene. When I go through the scene to destroy any weapons, I ended up destroying the player's weapon as well. This had not been obvious, as when I had previously tested, I had only checked to see if the next level loaded. I ended up checking the the parents of the weapon to see if it belonged to the player, and deleting it if not so. This took around 2 hours.




Game Over Screen

The next task I was assigned was creating a game over screen. The screen would display what enemy the player had died to, and when clicked, would send the player back to the main menu. This was fairly difficult as I had to find a way of getting the name of the enemy that had killed the player, and as the scripts are currently written, everything is very compartmentalized, and I had to look for a workaround. I first had to familizarize myself with how the enemies, projectiles, and player health management worked, as I needed to know how each interacted so I would be able to pull the name of the enemy all the way through to the GameManger. This took around 5 hours. After many, many attempts, what I ended up doing was adding an event listener to the player section of the EntityHealth script, and checking for when the player died. I also added a variable that held the name of the last entity that hit the player, and a function that updated that whenever the player was hit. I then added a function to the GameManager that would get the name of the killer from the player, and pass it to the canvas that would display the game over screen, alongside other things like unlocking the mouse and stopping the time. The canvas would then set itself to active, and the text on the screen would be changed to say the name of the entity that killed the player. Unfortunately, due to the fact that the enemies do not actually store their name anywhere, I was forced to just go with the name of the prefabs themselves, so if a prefab is not named correctly, or is a temp prefab, it will just display the name of the prefab, so the enemies will have to be named their actual names. This took around 12 hours.




Loading Screen

To begin, I moved the loading text to the bottom left corner as requested. I then tried to find a way to get a random image to load into the panel. After some research and tested, I decided manually adding all the images to an array in the prefab itself would be too difficult, and I instead opted to use Resources.LoadAll. After some tweaking, I was able to get it to work, and I also fixed the aspect ratio so the images would not stretch. I also added in a white background to cover the rest of the screen if the aspect ratio was different from the game. This took around 5 hours.

Limitations and Future Tasks

I spent a significant amount of time trying to find a way to find all the enemy drops without manually searching for them. This was because using FindGameObjectsWithTag was very inefficient and is even mentioned in the comments of the code that destroys enemy bodies. After reviewing the code, I should have realized that it would not be feasible to do so without significantly altering the enemy code, and the inefficiency would be ok since the function itself would only be called at the end of a level, but I spent far too much time trying to find a workaround, and ended up giving up in the end. I learned that I should quickly try to figure out if a specific aspect of a task is worth spending time on before using so much time on something that only slightly affects the game.