Thursday 4 May 2017

Outside the Box Project Beta Work - Enemy Wave Counter

As there was no Round or indication of the Waves of enemies spawning I decided to code a counter for how many enemies would be spawning and for a parallel number to be reduced as the enemies are killed to showcase the Player's progress. 

Figure 1.

Figure 2.
To do this I simply gained access to the list that informed the game of the number of enemies that would be spawning each wave (for example 5 Grunt's in wave 1 and 15 in wave 2). This list is within the Spawn Enemy script. Then I had to convert that numerical value from an int/float to a String (int's and float's being numbers and String's are words/letters).

Figure 3.

Figure 4.
The GruntChecker and the HunterChecker were scripts placed on the prefabs of The Grunt and Hunter respectively. All they had to manage was reference the numerical value in the EnemyCountScript that would be reduced when a contextual enemy was killed (as there is a counter for both The Grunt's in scene and The Hunter's in scene) and then using OnDestroy (when the gameObject this script is attached to is destroyed) reduced that value by 1, short hand is --

Figure 5.
Figure 5. is how the counter looks in scene.

No comments:

Post a Comment