Implementing victory
In this section, we will implement the victory condition for the Cucumber Man. The only victory condition for the Cucumber Man is when the number of Cucumber Beetles is zero. Our BeetleManager
script already provides functionality for counting Cucumber Beetles. As you will recall, that is how we update our Cucumber Beetle count on our HUD. We will make some modifications to that script and create a new script in this section.
Let's start by creating an onscreen text component to display You Won!
when the number of Cucumber Beetles reaches zero. Here are the steps:
- Right-click an empty area of the
Hierarchy
panel. - Select
Create Empty
. - In the
Inspector
panel, rename the new GameObject toEndofGame
. We will use this as a container for our victory and defeat text labels. - In the
Hierarchy
panel, drag theEndofGame
GameObject to subordinate it to ourHUD_Canvas
. - With the
EndofGame
GameObject selected, in theInspector
panel, select theTransform
dropdown and clickReset
. This resets...