Our CucumberManager script already keeps track of the number of cucumbers in the game, so we merely need to give that script's currentCucumberCount class variable the static modifier and then update our VictoryManager script. Here are the steps.
-
Edit the CucumberManager script so the currentCucumberCount variable declaration is as follows:
public static int currentCucumberCount;
- In the Awake() method, change currentCucumberCount = 0; to currentCucumberCount = 1;. This will help ensure the game does not think there are no cucumbers when the game starts.
- Add the following statement at the end of the Update() method, currentCucumberCount = cucumbers.Length;. This will keep the counter updated ...