WinOrLose.cs 869 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WinOrLose : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private UnityEngine.UI.Text textfield;
  8. [SerializeField]
  9. private GameObject disAndEnableObject;
  10. [SerializeField]
  11. private Station winningStation;
  12. [SerializeField]
  13. private Player player;
  14. // Use this for initialization
  15. void Start ()
  16. {
  17. disAndEnableObject.SetActive(false);
  18. }
  19. // Update is called once per frame
  20. void Update ()
  21. {
  22. if (winningStation.powerLevel >= 99)
  23. {
  24. textfield.text = "You won by uploading 1000 power!";
  25. disAndEnableObject.SetActive(true);
  26. }
  27. else if (player.PowerLevel <= 0)
  28. {
  29. textfield.text = "You ran out of power!";
  30. disAndEnableObject.SetActive(true);
  31. }
  32. }
  33. }