using System; 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 banRotate = false; public bool banCameraFieldOfView = false; public static BowCamera ins; void Awake() { ins = this; } void Update() { if (cameraComp && !banCameraFieldOfView) { cameraComp.fieldOfView = cameraFieldOfView; } if (GameMgr.ins.gameOver || banRotate) { return; } if (GameMgr.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.eualrAngles.x = this.eualrAngles.x - this.mouseSensitivity * Input.GetAxis("Mouse Y"); this.eualrAngles.y = this.eualrAngles.y + this.mouseSensitivity * Input.GetAxis("Mouse X"); 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(); // } } } float cameraFieldOfView = 60; public void SetCameraFieldOfView(float value) { cameraComp.fieldOfView = value; } public void setFieldOfView(float value, bool isPlus) { cameraFieldOfView = isPlus ? cameraFieldOfView + value : value; } public void updateFollowPullBow() { if (cameraFieldOfView > 40) { cameraFieldOfView -= 20 * Time.deltaTime; } else { cameraFieldOfView = 40; } } public void updateGiveUpPullBow() { if (cameraFieldOfView < 60) { cameraFieldOfView += 20 * Time.deltaTime; } else { cameraFieldOfView = 60; } } }