| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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 {
- 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;
- }
- }
- // Transform transform = GameObject.Find("CameraRoot/Rotate/Sphere").transform;
- // this.transform.LookAt(transform);
- // 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;
- }
- }
- }
|