To fully implement the loss condition, we need to update the manager class.
Open up GameBehavior and add the following code. Then, get the Enemy prefab to collide with you three times:
public class GameBehavior : MonoBehaviour
{
public string labelText = "Collect all 4 items and win your
freedom!";
public int maxItems = 4;
public bool showWinScreen = false;
// 1
public bool showLossScreen = false;
private int _itemsCollected = 0;
public int Items
{
// ... No changes needed ...
}
private int _playerHP = 3;
public int HP
{
get { return _playerHP; }
set {
_playerHP = value;
// 2
if(_playerHP <= 0)
{
labelText = "You want another life with that?";
showLossScreen = true;
Time.timeScale = 0;
}
else
...