Game Development Reference
In-Depth Information
5.
Open the SpawnBunnies script.
Change the canReproduce line as follows:
6.
internal bool canReproduce = true; // flag to control reproduction of zombie bunnies
7.
Save the script.
The SpawnBunnies script lives on the Zombie Spawn Manager object.
8.
Drag the Zombie Spawn Manager object onto the ScoreKeeper's new
Spawner parameter.
9.
Click Play, and test the new means of zombie bunny birth control.
You may have noticed that if the timer was already running, you got one more batch of zombie
bunnies before they stopped reproducing. The flag is used before the timer is reset. You can easily
add a return clause to the PopulateGardenBunnies() function.
In the SpawnBunnies script, at the top of the PopulateGardenBunnies
function, add the following:
10.
if (!canReproduce) return; // cancel the latest population explosion
11.
Save the script.
12.
Click Play, and test the result.
Finally, the garden is free of the zombie bunny pests (Figure 9-3 ).
Figure 9-3. Invaders eradicated!
Search WWH ::




Custom Search