Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class PlayerLook : MonoBehaviour
- {
- RaycastHit hit;
- [HideInInspector]
- public float rotX, rotY, mouseX, mouseY;
- public float clampAngle;
- public Transform PlayerT;
- bool interacting;
- [HideInInspector]
- public int Seeds;
- [HideInInspector]
- public Image InteractIndicator, BloodBar;
- private void Start()
- {
- BloodBar = GameObject.Find("PlayerBloodBar").GetComponent<Image>();
- InteractIndicator = GameObject.Find("InteractIndicator").GetComponent<Image>();
- Cursor.lockState = CursorLockMode.Locked;
- }
- void Update()
- {
- if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 3, 1 << 0))
- {
- if(hit.transform.tag == "Pumpkin")
- {
- if(hit.transform.GetComponent<Pumpkin>().ReadyToHarvest)
- {
- //interacting = true;
- InteractIndicator.enabled = true;
- InteractIndicator.sprite = hit.transform.GetComponent<Pumpkin>().MyIndicator;
- if (Input.GetKeyDown(KeyCode.E))
- {
- hit.transform.GetComponent<Pumpkin>().HarvestMe();
- }
- }
- else
- {
- if(Seeds >= 10)
- {
- if (Input.GetKeyDown(KeyCode.E))
- {
- Seeds -= 10;
- hit.transform.GetComponent<Pumpkin>().HealPumpkin();
- }
- }
- else
- {
- InteractIndicator.enabled = false;
- }
- }
- }
- else
- {
- if(hit.transform.tag == "Interact")
- {
- //interacting = true;
- InteractIndicator.enabled = true;
- InteractIndicator.sprite = hit.transform.GetComponent<Interactable>().MyIndicator;
- if (Input.GetKeyDown(KeyCode.E))
- {
- hit.transform.GetComponent<Interactable>().Invoke(hit.transform.GetComponent<Interactable>().Interact, 0);
- }
- }
- else
- {
- InteractIndicator.enabled = false;
- }
- }
- }
- else
- {
- InteractIndicator.enabled = false;
- //if (interacting)
- //{
- // interacting = false;
- // InteractIndicator.enabled = false;
- //}
- }
- mouseX = Input.GetAxis("Mouse X") * Time.deltaTime * 35f;
- mouseY = Input.GetAxis("Mouse Y") * Time.deltaTime * 35f;
- rotX += mouseY;
- rotY += mouseX;
- rotX = Mathf.Clamp(rotX, -clampAngle, clampAngle);
- //Quaternion localRotation = Quaternion.Euler(-rotX, 0, 0);
- transform.rotation = Quaternion.Euler(-rotX, PlayerT.transform.localEulerAngles.y, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement