|
|
@@ -48,47 +48,61 @@ public class BowCamera : MonoBehaviour
|
|
|
this.localEulerAngles.x = Mathf.Clamp(this.localEulerAngles.x - 2f * Input.GetAxis("Mouse Y"), -36, 36);
|
|
|
this.localEulerAngles.y = Mathf.Clamp(this.localEulerAngles.y + 2f * Input.GetAxis("Mouse X"), -180, 180);
|
|
|
this.transform.localEulerAngles = this.localEulerAngles;
|
|
|
- if (EventSystem.current.IsPointerOverGameObject())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
|
if (Input.GetMouseButtonDown(0)) {
|
|
|
- armBow.mouseDown();
|
|
|
- }
|
|
|
- else if (Input.GetMouseButtonUp(0)) {
|
|
|
- armBow.mouseUp();
|
|
|
+ armBow.ADS_fire();
|
|
|
}
|
|
|
- } else {
|
|
|
- if (isTouchMode) {
|
|
|
- //触摸控制镜头和拉弓射箭
|
|
|
- if (Input.touches.Length == 1 && Input.touches[0].phase == TouchPhase.Moved)
|
|
|
- {
|
|
|
- if (!EventSystem.current.IsPointerOverGameObject(Input.touches[0].fingerId))
|
|
|
- {
|
|
|
- this.localEulerAngles.x = Mathf.Clamp(this.localEulerAngles.x - Input.touches[0].deltaPosition.y * Time.deltaTime * 5, -36, 36);
|
|
|
- this.localEulerAngles.y = Mathf.Clamp(this.localEulerAngles.y + Input.touches[0].deltaPosition.x * Time.deltaTime * 5, -180, 180);
|
|
|
- this.transform.localEulerAngles = this.localEulerAngles;
|
|
|
+ }
|
|
|
+ else if (isTouchMode) {
|
|
|
+ if (Input.touchCount > 0) {
|
|
|
+ if (!hasTouch) {
|
|
|
+ Touch touch = Input.GetTouch(0);
|
|
|
+ if (touch.phase == TouchPhase.Began) {
|
|
|
+ hasTouch = true;
|
|
|
+ touchID = touch.fingerId;
|
|
|
}
|
|
|
}
|
|
|
- if (Input.touches.Length > 0)
|
|
|
- {
|
|
|
- foreach (Touch touch in Input.touches)
|
|
|
+ if (hasTouch) {
|
|
|
+ Touch touch = default;
|
|
|
+ foreach (var t in Input.touches)
|
|
|
{
|
|
|
- if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) return;
|
|
|
+ if (t.fingerId == touchID) touch = t;
|
|
|
+ }
|
|
|
+ bool isOverUI = EventSystem.current.IsPointerOverGameObject(touchID);
|
|
|
+ if (touch.phase == TouchPhase.Began) {
|
|
|
+ touchOnUI = isOverUI;
|
|
|
+ }
|
|
|
+ else if (touch.phase == TouchPhase.Moved) {
|
|
|
+ touchOnUI = isOverUI;
|
|
|
+ if (!isOverUI) {
|
|
|
+ //触摸控制镜头和拉弓射箭
|
|
|
+ this.localEulerAngles.x = Mathf.Clamp(this.localEulerAngles.x - Input.touches[0].deltaPosition.y * Time.deltaTime * 5, -36, 36);
|
|
|
+ this.localEulerAngles.y = Mathf.Clamp(this.localEulerAngles.y + Input.touches[0].deltaPosition.x * Time.deltaTime * 5, -180, 180);
|
|
|
+ this.transform.localEulerAngles = this.localEulerAngles;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (touch.phase == TouchPhase.Ended) {
|
|
|
+ hasTouch = false;
|
|
|
+ //UnityBug,Ended阶段isOverUI总是返回false,因此通过新增变量touchOnUI来辅助识别触点是否在UI上
|
|
|
+ if (touchOnUI) touchOnUI = false;
|
|
|
+ else armBow.ADS_fire();
|
|
|
}
|
|
|
- armBow.mouseDown();
|
|
|
- }
|
|
|
- if (Input.touches.Length == 0)
|
|
|
- {
|
|
|
- armBow.mouseUp();
|
|
|
}
|
|
|
} else {
|
|
|
- //镜头看向九轴姿态虚拟节点
|
|
|
- this.transform.LookAt(CameraToLook.ins.point);
|
|
|
+ hasTouch = false;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ hasTouch = false;
|
|
|
+ //镜头看向九轴姿态虚拟节点
|
|
|
+ this.transform.LookAt(CameraToLook.ins.point);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //触摸模式下的有效触点信息记录
|
|
|
+ int touchID;
|
|
|
+ bool hasTouch;
|
|
|
+ bool touchOnUI;
|
|
|
+
|
|
|
//---------------相机视野的相关操作---------------------
|
|
|
|
|
|
//视野值记录
|
|
|
@@ -96,9 +110,12 @@ public class BowCamera : MonoBehaviour
|
|
|
//禁止相机视野改变
|
|
|
[NonSerialized] public bool banCameraFieldOfView = false;
|
|
|
|
|
|
- //立马改变相机视野值
|
|
|
public void SetCameraFieldOfView(float value) {
|
|
|
- cameraComp.fieldOfView = cameraFieldOfView = value;
|
|
|
+ cameraComp.fieldOfView = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetCameraFieldOfViewRecord(float value) {
|
|
|
+ cameraFieldOfView = value;
|
|
|
}
|
|
|
|
|
|
//拉弓时的相机视野值变化
|