| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class BowCamera : MonoBehaviour
- {
- private Vector3 eualrAngles = new Vector3();
- private float mouseSensitivity = 2f;
- public Camera cameraComp;
- public bool debugInEditor = false;
- void Start() {
- if (this.debugInEditor) {
- // Cursor.lockState = CursorLockMode.Locked;
- }
- }
- void Update()
- {
- if (GameMgr.ins.gameOver) {
- return;
- }
- if (debugInEditor) {
- this.eualrAngles.x = Mathf.Clamp(this.eualrAngles.x - this.mouseSensitivity * Input.GetAxis("Mouse Y"), -36, 36);
- this.eualrAngles.y = Mathf.Clamp(this.eualrAngles.y + this.mouseSensitivity * Input.GetAxis("Mouse X"), -20, 20);
- this.transform.eulerAngles = this.eualrAngles;
- // if (EventSystem.current.IsPointerOverGameObject())
- // {
- // return;
- // }
- // if (Input.GetMouseButtonDown(0)) {
- // ArmBow.ins.mouseDown();
- // }
- // else if (Input.GetMouseButtonUp(0)) {
- // ArmBow.ins.mouseUp();
- // }
- } else {
- this.transform.LookAt(GameObject.Find("CameraToLook/Point").transform);
- // if (Input.touches.Length == 1 && Input.touches[0].phase == TouchPhase.Moved)
- // {
- // if (!EventSystem.current.IsPointerOverGameObject(Input.touches[0].fingerId))
- // {
- // this.eualrAngles.x = Mathf.Clamp(this.eualrAngles.x - Input.touches[0].deltaPosition.y * Time.deltaTime * 5, -36, 36);
- // this.eualrAngles.y = Mathf.Clamp(this.eualrAngles.y + Input.touches[0].deltaPosition.x * Time.deltaTime * 5, -25, 25);
- // this.transform.eulerAngles = this.eualrAngles;
- // }
- // }
- // if (Input.touches.Length > 0)
- // {
- // foreach (Touch touch in Input.touches)
- // {
- // if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) return;
- // }
- // ArmBow.ins.mouseDown();
- // }
- // if (Input.touches.Length == 0)
- // {
- // ArmBow.ins.mouseUp();
- // }
-
- }
- }
- public void setFieldOfView(float value, bool isPlus) {
- cameraComp.fieldOfView = isPlus ? cameraComp.fieldOfView + value : value;
- }
- public void resumeFieldOfView() {
- cameraComp.fieldOfView = 60;
- }
- public void updateFollowPullBow() {
- if (cameraComp.fieldOfView > 40) {
- cameraComp.fieldOfView -= 20 * Time.deltaTime;
- } else {
- cameraComp.fieldOfView = 40;
- }
- }
- public void updateGiveUpPullBow() {
- if (cameraComp.fieldOfView < 60) {
- cameraComp.fieldOfView += 20 * Time.deltaTime;
- } else {
- cameraComp.fieldOfView = 60;
- }
- }
- }
|