Since our game will need to be paused and restarted when a player wins or loses, this is a good time to use a namespace that isn't included in new C# scripts by default.
Add the following code to GameBehavior and play:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 1
using UnityEngine.SceneManagement;
public class GameBehavior : MonoBehaviour
{
// ... No changes needed ...
private int _itemsCollected = 0;
public int Items
{
get { return _itemsCollected; }
set {
_itemsCollected = value;
if (_itemsCollected >= maxItems)
{
labelText = "You've found all the items!";
showWinScreen = true;
// 2
Time.timeScale = 0f;
}
else
{
labelText = "Item found, only " + (maxItems -
...