TeHArGiS10

Untitled

Aug 22nd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3.  
  4. public class Shop : MonoBehaviour {
  5.  
  6. public GameObject pressText2;
  7. public GameObject LabAll;
  8. public Behaviour controller;
  9. public GameObject crosshair;
  10.  
  11. public GameObject moneyText;
  12. public int moneyCount;
  13.  
  14. public int maxDistance;
  15. public bool isLabOpen;
  16. RaycastHit hit;
  17. public LayerMask mask = 1 << 9;
  18. Rigidbody rb;
  19.  
  20. void Start ()
  21. {
  22. isLabOpen = false;
  23. pressText2.gameObject.SetActive(false);
  24. LabAll.gameObject.SetActive(false);
  25.  
  26. if (GetComponent <Rigidbody>())
  27. {
  28. rb = GetComponent<Rigidbody>();
  29. }
  30. }
  31.  
  32. void Update ()
  33. {
  34. moneyText.GetComponent<Text>().text = moneyCount.ToString();
  35.  
  36. if (Physics.Raycast(transform.position, Camera.main.transform.forward, out hit, maxDistance, mask.value))
  37. {
  38. pressText2.gameObject.SetActive(true);
  39.  
  40. if (Input.GetKeyDown(KeyCode.E))
  41. {
  42. isLabOpen = true;
  43. }
  44. }
  45. else
  46. {
  47. pressText2.gameObject.SetActive(false);
  48. }
  49.  
  50. if (isLabOpen)
  51. {
  52. LabOpen();
  53. } else
  54. {
  55. LabClosed();
  56. }
  57. }
  58.  
  59. public void ShopClose ()
  60. {
  61. isLabOpen = false;
  62. }
  63.  
  64. void TakeMoney ()
  65. {
  66. moneyCount += Random.Range(10, 30);
  67. }
  68.  
  69. void LabOpen ()
  70. {
  71. LabAll.gameObject.SetActive(true);
  72. rb.useGravity = false;
  73. rb.isKinematic = true;
  74. controller.enabled = false;
  75. crosshair.gameObject.SetActive(false);
  76. }
  77.  
  78. void LabClosed ()
  79. {
  80. LabAll.gameObject.SetActive(false);
  81. rb.useGravity = true;
  82. rb.isKinematic = false;
  83. controller.enabled = true;
  84. crosshair.gameObject.SetActive(true);
  85. }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment