Game Development Reference
In-Depth Information
At the bottom of the SpawnBunnies script's StartReproducing function,
change the StartCoroutine(StartReproducing(reproRate)) line to the
following:
1.
if (levelManager) StartCoroutine(StartReproducing(reproRate +
levelManager.difficulty));
else StartCoroutine(StartReproducing(reproRate));
Once again, you are checking for the LevelManager before accessing it. The else clause allows you
to test the level directly without going through the Start menu. You will, of course, have to find and
assign the LevelManager before you can test the code.
2.
Add the variable:
LevelManager levelManager; // the script that holds the data between levels
Find it in the Start function:
3.
if(GameObject.Find("Level Manager")) {
levelManager = GameObject.Find("Level Manager").GetComponent<LevelManager>();
}
4.
Save the script, and test from the StartMenu scene.
The zombie-bunny drops may be a bit too fast yet for the “easy” setting because of the
randomization of the time between drops. This is another place where you can use the difficulty
value to affect game play.
At the top of the StartReproducing function, change the float adjustedTime
= Random.Range line to the following:
5.
// wait for this much time before going on
float adjustedTime;
if (levelManager) adjustedTime = Random.Range(minTime, minTime +
levelManager.difficulty);
else adjustedTime = Random.Range(minTime, minTime + 5f);
6.
Save the script, and play through from the StartMenu level.
The zombie-bunny drops are better behaved for the different difficulty settings.
The last little task is to re-instate is the occlusion culling. Any object with the HideAtStart script will
require its state to be saved and handled by the LevelManager any time the player is entering or
leaving the garden level. The LevelManager only has to store a Boolean value.
7.
Open the GardenLevel1 scene.
8.
In the GameMisc script, add the following variable:
public GameObject[] hideShows; // the objects that are affected by occlusion culling
Search WWH ::




Custom Search