|
@@ -8,12 +8,17 @@ public class BowCamera : MonoBehaviour
|
|
|
Camera cameraComp;
|
|
Camera cameraComp;
|
|
|
//本地欧拉角记录值
|
|
//本地欧拉角记录值
|
|
|
Vector3 localEulerAngles;
|
|
Vector3 localEulerAngles;
|
|
|
|
|
+ //控制的手臂弓
|
|
|
|
|
+ ArmBow armBow;
|
|
|
|
|
+ //触摸模式开关
|
|
|
|
|
+ bool isTouchMode = true;
|
|
|
public static BowCamera ins;
|
|
public static BowCamera ins;
|
|
|
|
|
|
|
|
void Awake() {
|
|
void Awake() {
|
|
|
ins = this;
|
|
ins = this;
|
|
|
cameraComp = GetComponent<Camera>();
|
|
cameraComp = GetComponent<Camera>();
|
|
|
localEulerAngles = transform.localEulerAngles;
|
|
localEulerAngles = transform.localEulerAngles;
|
|
|
|
|
+ armBow = GetComponentInChildren<ArmBow>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Update()
|
|
void Update()
|
|
@@ -38,39 +43,39 @@ public class BowCamera : MonoBehaviour
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (Input.GetMouseButtonDown(0)) {
|
|
if (Input.GetMouseButtonDown(0)) {
|
|
|
- ArmBow.ins.mouseDown();
|
|
|
|
|
|
|
+ armBow.mouseDown();
|
|
|
}
|
|
}
|
|
|
else if (Input.GetMouseButtonUp(0)) {
|
|
else if (Input.GetMouseButtonUp(0)) {
|
|
|
- ArmBow.ins.mouseUp();
|
|
|
|
|
|
|
+ armBow.mouseUp();
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- //镜头看向九轴姿态虚拟节点
|
|
|
|
|
- this.transform.LookAt(GameObject.Find("CameraToLook/Point").transform);
|
|
|
|
|
-
|
|
|
|
|
- //触摸控制镜头和拉弓射箭
|
|
|
|
|
- #region
|
|
|
|
|
- if (Input.touches.Length == 1 && Input.touches[0].phase == TouchPhase.Moved)
|
|
|
|
|
- {
|
|
|
|
|
- if (!EventSystem.current.IsPointerOverGameObject(Input.touches[0].fingerId))
|
|
|
|
|
|
|
+ if (isTouchMode) {
|
|
|
|
|
+ //触摸控制镜头和拉弓射箭
|
|
|
|
|
+ if (Input.touches.Length == 1 && Input.touches[0].phase == TouchPhase.Moved)
|
|
|
{
|
|
{
|
|
|
- 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;
|
|
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- if (Input.touches.Length > 0)
|
|
|
|
|
- {
|
|
|
|
|
- foreach (Touch touch in Input.touches)
|
|
|
|
|
|
|
+ if (Input.touches.Length > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach (Touch touch in Input.touches)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) return;
|
|
|
|
|
+ }
|
|
|
|
|
+ armBow.mouseDown();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Input.touches.Length == 0)
|
|
|
{
|
|
{
|
|
|
- if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) return;
|
|
|
|
|
|
|
+ armBow.mouseUp();
|
|
|
}
|
|
}
|
|
|
- ArmBow.ins.mouseDown();
|
|
|
|
|
- }
|
|
|
|
|
- if (Input.touches.Length == 0)
|
|
|
|
|
- {
|
|
|
|
|
- ArmBow.ins.mouseUp();
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //镜头看向九轴姿态虚拟节点
|
|
|
|
|
+ this.transform.LookAt(GameObject.Find("CameraToLook/Point").transform);
|
|
|
}
|
|
}
|
|
|
- #endregion
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|