using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class GameM : MonoBehaviour {
  private int itemsCollected = 0;
  private int playerHealth = 5;
  public int MaxItems = 1;
  public TMP_Text HealthText;
  public TMP_Text ItemsText;
  public Button WinB;
  public Button LosB;

  public int Items {
    get { return itemsCollected; }
    set {
      itemsCollected = value;
      ItemsText.text = "Items: " + itemsCollected;
      if (itemsCollected >= MaxItems) {
        WinB.gameObject.SetActive(true);
        Time.timeScale = 0f;
      }
    }
  }

  public int Health {
    get { return playerHealth; }
    set {
      playerHealth = value;
      HealthText.text = "Health: " + playerHealth;
      if (playerHealth <= 0) {
        LosB.gameObject.SetActive(true);
        Time.timeScale = 0;
      }
    }
  }
  void Start() {
    ItemsText.text += itemsCollected;
    HealthText.text += playerHealth;
    WinB.gameObject.SetActive(false);
    LosB.gameObject.SetActive(false);
  }
  public void RestartScene() {
    SceneManager.LoadScene(0);
    Time.timeScale = 1f;
  }
}