Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- public class Shop : MonoBehaviour {
- public GameObject pressText2;
- public GameObject LabAll;
- public Behaviour controller;
- public GameObject crosshair;
- public GameObject moneyText;
- public int moneyCount;
- public int maxDistance;
- public bool isLabOpen;
- RaycastHit hit;
- public LayerMask mask = 1 << 9;
- Rigidbody rb;
- void Start ()
- {
- isLabOpen = false;
- pressText2.gameObject.SetActive(false);
- LabAll.gameObject.SetActive(false);
- if (GetComponent <Rigidbody>())
- {
- rb = GetComponent<Rigidbody>();
- }
- }
- void Update ()
- {
- moneyText.GetComponent<Text>().text = moneyCount.ToString();
- if (Physics.Raycast(transform.position, Camera.main.transform.forward, out hit, maxDistance, mask.value))
- {
- pressText2.gameObject.SetActive(true);
- if (Input.GetKeyDown(KeyCode.E))
- {
- isLabOpen = true;
- }
- }
- else
- {
- pressText2.gameObject.SetActive(false);
- }
- if (isLabOpen)
- {
- LabOpen();
- } else
- {
- LabClosed();
- }
- }
- public void ShopClose ()
- {
- isLabOpen = false;
- }
- void TakeMoney ()
- {
- moneyCount += Random.Range(10, 30);
- }
- void LabOpen ()
- {
- LabAll.gameObject.SetActive(true);
- rb.useGravity = false;
- rb.isKinematic = true;
- controller.enabled = false;
- crosshair.gameObject.SetActive(false);
- }
- void LabClosed ()
- {
- LabAll.gameObject.SetActive(false);
- rb.useGravity = true;
- rb.isKinematic = false;
- controller.enabled = true;
- crosshair.gameObject.SetActive(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment