Advertisement
kadyr

Untitled

Oct 16th, 2021
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 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. VolumeController.instance.DisableVolume();
  40. //++++++++++++++++++++++++++++
  41. }
  42.  
  43. // Update is called once per frame
  44. void Update()
  45. {
  46. if (Input.GetKeyDown(KeyCode.Escape))
  47. {
  48. if (pause)
  49. {
  50. pause = false;
  51. GetComponent<PlayerLook>().enabled = true;
  52. GetComponent<PlayerMove>().enabled = true;
  53. Cursor.lockState = CursorLockMode.Locked;
  54. pauseUI.SetActive(false);
  55. }
  56. else
  57. {
  58. pause = true;
  59. GetComponent<PlayerLook>().enabled = false;
  60. GetComponent<PlayerMove>().enabled = false;
  61. Cursor.lockState = CursorLockMode.None;
  62. pauseUI.SetActive(true);
  63. }
  64. }
  65. }
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement