Advertisement
kadyr

Untitled

Oct 16th, 2021
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3.  
  4. public class PlayerController : MonoBehaviour
  5. {
  6. [SerializeField] Text HpText;
  7. int health;
  8.  
  9. [SerializeField] GameObject bullet;
  10. [SerializeField] GameObject rifleStart;
  11. [SerializeField] GameObject gameOver;
  12. [SerializeField] GameObject pauseUI;
  13.  
  14. bool pause = false;
  15.  
  16. public void ChangeHealth(int count)
  17. {
  18. health = health + count;
  19. if (health <= 0)
  20. {
  21. gameOver.SetActive(true);
  22. GetComponent<PlayerLook>().enabled = false;
  23. Cursor.lockState = CursorLockMode.None;
  24. }
  25. HpText.text = health.ToString();
  26. }
  27.  
  28. public int GetHealth()
  29. {
  30. return health;
  31. }
  32.  
  33. // Start is called before the first frame update
  34. void Start()
  35. {
  36. //+++++++++++++++++++++++
  37. ChangeHealth(100);
  38. MenuManager.instance.CallMenu();
  39. //++++++++++++++++++++++++++++
  40. }
  41.  
  42. // Update is called once per frame
  43. void Update()
  44. {
  45. if (Input.GetKeyDown(KeyCode.Escape))
  46. {
  47. if (pause)
  48. {
  49. pause = false;
  50. GetComponent<PlayerLook>().enabled = true;
  51. GetComponent<PlayerMove>().enabled = true;
  52. Cursor.lockState = CursorLockMode.Locked;
  53. pauseUI.SetActive(false);
  54. }
  55. else
  56. {
  57. pause = true;
  58. GetComponent<PlayerLook>().enabled = false;
  59. GetComponent<PlayerMove>().enabled = false;
  60. Cursor.lockState = CursorLockMode.None;
  61. pauseUI.SetActive(true);
  62. }
  63. }
  64. }
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement