Game Development Reference
In-Depth Information
6.
Save the script.
In the LevelManager script, change the batteryRemaining variable to
7.
internal int percentRemaining; // % of battery remaining
In the ManageLevels function, move the Find("Battery Life") line to just
below the GameObject.Find("Gnomatic Garden Defender") line
8.
9.
Below that, add the following:
// update full battery value, use inverse, add offset
float newBattery = (150f * difficulty * .1f) + 25f;
batteryHealth.UpdateBatteryLife(newBattery,percentRemaining);
The player can change the battery life before the game has started running, so the code identifying
the Battery Health component is moved earlier in the function so it is useful in both places where
the component is accessed. The equation that calculates the new battery life value uses the base
amount, 150, times the difficulty, multiplies it to get the percent, and then adds the 25-second offset.
The batteryRemaining value will now be recalculated in the function, so you must comment out or
remove the original line.
Under the // manage battery HUD line, comment out or remove the
batteryRemaining line:
1.
// batteryHealth.batteryRemaining = batteryRemaining;
2.
Save the script, and save the scene.
3.
Click Play from the Start menu, and then increase the difficulty to the full
amount.
4.
Enter the garden, and watch the battery charge drop quickly.
5.
Press the F1 key to access the Main menu, select the Settings menu, and set
the Difficulty to the lowest setting.
6.
Get back into the game.
The battery life remaining should be the same, but the rate at which it drops should now be
much slower.
7.
Play again from the start, and set the Difficulty to the easiest setting.
8.
Go into the garden, and wait for the first zombie-bunny drop.
The time, completing the task may take longer, but the zombie bunnies multiply just as quickly as
they did before. There's several things you could do to make the game easier. You could decrease
the number of zombie bunnies that can appear, increase the time between drops, or increase the
time before the first drop. The most noticeable option would be to use the difficulty value to adjust
the time between drops.
Search WWH ::




Custom Search