|
|
@@ -53,9 +53,6 @@ public class SB_EventSystem : MonoBehaviour
|
|
|
[System.NonSerialized] public bool simulateMouseIsAwaked;
|
|
|
public void AwakenSimulateMouse() {
|
|
|
simulateMouseIsAwaked = !simulateMouse.gameObject.activeSelf;
|
|
|
- if (simulateMouseIsAwaked && AimHandler.ins) {
|
|
|
- MakeMouseToScreenCenter(AimHandler.ins.newRotation);
|
|
|
- }
|
|
|
simulateMouse.gameObject.SetActive(simulateMouseIsAwaked);
|
|
|
try {
|
|
|
GlobalEventCenter.ins.onSimulateMouseAwakeChanged?.Invoke(simulateMouseIsAwaked);
|
|
|
@@ -64,17 +61,10 @@ public class SB_EventSystem : MonoBehaviour
|
|
|
#endregion 鼠标激活/关闭
|
|
|
|
|
|
#region 模拟鼠标移动
|
|
|
- Vector3 identityEulerAngles;
|
|
|
- Quaternion nowAxisQuat;
|
|
|
+ Quaternion nowAxisQuat = Quaternion.identity;
|
|
|
Quaternion newAxisQuat;
|
|
|
Vector2 mousePointerPosition;
|
|
|
- bool hasDoIdentity = false; //用于一开始会自当校准一次
|
|
|
public void MoveSimulateMouse(Quaternion axisQuat) {
|
|
|
- if (!hasDoIdentity) {
|
|
|
- hasDoIdentity = true;
|
|
|
- AimHandler.ins.DoIdentity();
|
|
|
- MakeMouseToScreenCenter(AimHandler.ins.newRotation);
|
|
|
- }
|
|
|
if (IsClickMouseCooling()) { //点击就是射出,射出会产生抖动,防止接收抖动后的数据
|
|
|
return;
|
|
|
}
|
|
|
@@ -83,7 +73,7 @@ public class SB_EventSystem : MonoBehaviour
|
|
|
void UpdateMoveSimulateMouse() {
|
|
|
if (!simulateMouseIsAwaked) return;
|
|
|
nowAxisQuat = Quaternion.Lerp(nowAxisQuat, newAxisQuat, 0.033f * 8);
|
|
|
- Vector3 resEulerAngles = FormatQuat(nowAxisQuat).eulerAngles - identityEulerAngles;
|
|
|
+ Vector3 resEulerAngles = FormatQuat(nowAxisQuat).eulerAngles;
|
|
|
resEulerAngles.x = Mathf.Clamp(resEulerAngles.x > 180 ? resEulerAngles.x - 360 : resEulerAngles.x, -12.5f, 12.5f);
|
|
|
resEulerAngles.y = Mathf.Clamp(resEulerAngles.y > 180 ? resEulerAngles.y - 360 : resEulerAngles.y, -22.2f, 22.2f);
|
|
|
mousePointerPosition.x = (resEulerAngles.y + 22.2f) / 44.4f * Screen.width;
|
|
|
@@ -96,12 +86,6 @@ public class SB_EventSystem : MonoBehaviour
|
|
|
}
|
|
|
#endregion 模拟鼠标移动
|
|
|
|
|
|
- //鼠标居中
|
|
|
- public void MakeMouseToScreenCenter(Quaternion identityQuaternion) {
|
|
|
- identityEulerAngles = FormatQuat(identityQuaternion).eulerAngles;
|
|
|
- nowAxisQuat = identityQuaternion;
|
|
|
- }
|
|
|
-
|
|
|
//点击鼠标
|
|
|
float _lastClickMouseTime = -100;
|
|
|
void RecordClickMouseTime() {
|