In Chapter 10, Scripting Our Points System, we designed, scripted, and implemented our game's point system. We made changes to the appropriate GameObjects and wrote several scripts to manage the point system. We ensured the points were updated on our Head's-Up Display (HUD) for each frame of the game. In addition, we added the ability for the Cucumber Man to collect cherries from the cherry trees and use them as weapons against the Cucumber Beetles.
In this chapter, we will design and script our game's victory and defeat conditions. We will update the scripts we created in other chapters to manage the Cucumber Man's health, providing frame-by-frame onscreen updates and ensuring a player life is lost when the health runs out. We will manage, through scripts, the lives remaining. We will also design and script the respawning of our player character.
Specifically, we will cover the following in this chapter:
- Designing the defeat and victory conditions