Hi. Here is a recap of yesterday, Day 49 of my 60 day challenge to become a Unity Game Developer!
Most of the day was spent in team meetings where we merged all of our pieces together, got on the same page regarding what our 2nd sprint will look like, pulled our new baseline from the repo, and did a retrospective for our 1st sprint.
After pulling everyone’s code in, here is what the game looks like:
Another thing that we did yesterday was a session on abstract class. Abstract classes are a great way to optimize code by allowing for properties and functions to be inherited from a base class rather than having to write the same code over and over again. This is especially helpful when wanting to create different versions of the same thing. Let’s say for example you wanted to make a human abstract class. All humans eat, breathe, have an age, etc. so these are all properties and functions that you could put in your base abstract class, from there you can create all the different people you want by inheriting from your base human class and changing the properties and functions for each person you create.
We decided that this would be great for our enemies. We knew that there were things that all of our enemies would need i.e. speed, animators, weapons, etc. so we worked together to create an abstract class that we could inherit from.
Here’s how we approached this:
First we needed to come to an agreement on variables.
We decided that the best thing to do would be to set up our health (hp), speed, animator, colliders, and fire rate. All of our enemies will have these inherited and now all we will need to do is go in and set the values for each of our enemies. Also included on here are variables to handle the damage taken by the laser beam as this is set up to be handled in a slightly different way from the way the other weapons damage will be taken.
We then set up the functions:
Because we are using this base class for our generic enemies, we decided to keep the movement very simple. Our generic enemy will just move to the side.
This instantiate a weapon as well as creates a fire delay.
Our damage method takes in a parameter of _damageTaken and is public so that it can be called from the player’s fire class (i.e. laser, fireball, etc) this is likely where we will set the damage. We also destroy the object in this method once it’s hp is less than 0.
This deals with the laser behavior which sets a specified amount of damage for the laser as well as a delay while the damage is being taken.
Today I will be working on a new enemy!! Should be fun :-)
Will touch base soon.