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
Hierarchypanel. - Select
Create Empty. - In the
Inspectorpanel, rename the new GameObject toEndofGame. We will use this as a container for our victory and defeat text labels. - In the
Hierarchypanel, drag theEndofGameGameObject to subordinate it to ourHUD_Canvas. - With the
EndofGameGameObject selected, in theInspectorpanel, select theTransformdropdown and clickReset. This resets...