We have a working combat and level generation system so now we need something for the players to do within those levels to complete them other than the placeholder method of stepping on a button. I currently have 4 objective types listed on the GDD
Assassination: Kill the boss enemy/enemies
Annihilation: Kill all enemies.
Collection: Find X number of key items.
Survival: Enemies know where you are and will constantly spawn, stay alive for a set time.
Of these, the simplest are Assassination and Annihilation as they don't require the creation of new things like timers and keys, only modifications to the character and level manager scripts. As such, these are the two objectives I have decided to implement in time for the upcoming interim report.
I began by adding a start function to the level manager which gets reference to the game manager and calls its own turn function. I also removed the functionality for the game manager and level manager to turn other levels they spawn as it simply makes more sense for the levels to turn themselves on spawn rather than have something else turn them.
I added a direction selected bool and target rotation quaternion which are set in the turn level function.
This is then used in a new update function to set a new rotation done bool to true and call a spawn enemies function. This ensures enemies don't spawn until the level has finished rotating so that they don't end up spawning in odd places as they were previously.
The spawn enemies function simply calls the spawn function in each of the enemy spawners in the level as they have all been added to a new enemy spawner script list variable. Previously these spawners just instantiated the enemy in their start function but they now do so in this spawn function instead which is only called here.
Over in the enemy controller's start function, we now get a reference to the level and game manager and call an enemy ready function in the level manager at the end, indicating the enemy is fully set up.
The active level variable of the game manager is set by itself when it spawns the starting level.
The level manager increments their enemies ready int and adds the enemy to the list. Once all 10 enemies are ready, the start objective function is called.
The start objective function begins by setting the current level as the active level and getting a reference to a new objective text UI object. It then sets a local int to a random value between 0 and the number of objective types. Currently, a roll of 0 will result in the objective being set to Annihilation and the objective text being changed to reflect that alongside how many enemies remain. The only other option at the moment is 1, which makes the objective Assassination and changes the objective text to reflect this. Assassination also then selects a random enemy in the enemy list and calls their new promote to boss function.
Before we get into the promote function, lets look at the new level up function in the base character. Previously, leveling up was done in the gain xp function and it buffed all stats. Now the gain xp function calls the level up function when you reach max xp and it buffs a single random stat.
When the promote to boss function is called in the enemy controller, the base character's new boss bool is set to true, they are levelled up 10 times and doubled in size
The base character death function now tells the level manager when an enemy is killed when the objective is annihilation and sets the objective to complete if the boss is killed when the objective is assassination.
The the update annihilation function in the level manager tracks the number of enemies remaining, displays that in the UI and calls complete objective once they are all gone.
Here is a video of both objectives working as intended with some added info on a few last minute changes I made to fix a few bugs within the level generation and setup systems:
Kommentare