|
|
@@ -62,6 +62,9 @@ namespace WildAttack
|
|
|
private ParticleSystem failParticle;
|
|
|
private ParticleSystem victoryParticle;
|
|
|
|
|
|
+ //触摸检测器
|
|
|
+ JCUnityLib.TouchChecker touchChecker = new JCUnityLib.TouchChecker();
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region Function
|
|
|
@@ -95,18 +98,7 @@ namespace WildAttack
|
|
|
|
|
|
Physics.autoSyncTransforms = true;
|
|
|
InitForLimitBound();
|
|
|
- RegisterSDK();
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 注册SDK相关
|
|
|
- /// </summary>
|
|
|
- private void RegisterSDK()
|
|
|
- {
|
|
|
- //SmartBowHelper.GetInstance().OnBluetoothError += OnBluetoothError;
|
|
|
- //SmartBowHelper.GetInstance().OnBluetoothModuleInited += OnBluetoothModuleInited;
|
|
|
- //SmartBowHelper.GetInstance().OnFunctionKeyPress += OnFunctionKeyPress;
|
|
|
- //SmartBowHelper.GetInstance().OnFunctionKeyLongPress += OnFunctionKeyLongPress;
|
|
|
+ InitTouchChecker();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -264,16 +256,9 @@ namespace WildAttack
|
|
|
UpdateBowUnityEditor();
|
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
|
{
|
|
|
- if (CheckCrossHairOverUI())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- bow.Shoot(testSpeed);
|
|
|
+ if (!isOver) bow.Shoot(testSpeed);
|
|
|
}
|
|
|
#endregion
|
|
|
-
|
|
|
-#else
|
|
|
- UpdateBowAndriod();
|
|
|
#endif
|
|
|
|
|
|
// 游戏结束后相机移动到对应位置
|
|
|
@@ -295,39 +280,39 @@ namespace WildAttack
|
|
|
/// ui检测
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- private bool CheckCrossHairOverUI()
|
|
|
- {
|
|
|
- if (!isOver) return false;
|
|
|
-
|
|
|
- EventSystem eventSystem = EventSystem.current;
|
|
|
- PointerEventData pointerEventData = new PointerEventData(eventSystem);
|
|
|
- // 获取准星pos 通过eventsystem检测下方是否有按钮
|
|
|
- pointerEventData.position = new Vector3(UIManager.GetInstance().GetCrossHairPos().x, UIManager.GetInstance().GetCrossHairPos().y, 0);
|
|
|
- //射线检测ui
|
|
|
- List<RaycastResult> uiRaycastResultCache = new List<RaycastResult>();
|
|
|
- eventSystem.RaycastAll(pointerEventData, uiRaycastResultCache);
|
|
|
- if (uiRaycastResultCache.Count > 0)
|
|
|
- {
|
|
|
- // 是否有button
|
|
|
- Button btn = uiRaycastResultCache[0].gameObject.GetComponent<Button>();
|
|
|
- if (btn == null)
|
|
|
- {
|
|
|
- // 防止检测到button下的text (ui注意设置 button下text不要勾选raycast
|
|
|
- btn = uiRaycastResultCache[0].gameObject.transform.GetComponentInParent<Button>();
|
|
|
- if (btn == null)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- btn.onClick.Invoke();
|
|
|
- //Debug.Log("eventsystem 触发 + " + uiRaycastResultCache[0].gameObject.name);
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
+ //private bool CheckCrossHairOverUI()
|
|
|
+ //{
|
|
|
+ // if (!isOver) return false;
|
|
|
+
|
|
|
+ // EventSystem eventSystem = EventSystem.current;
|
|
|
+ // PointerEventData pointerEventData = new PointerEventData(eventSystem);
|
|
|
+ // // 获取准星pos 通过eventsystem检测下方是否有按钮
|
|
|
+ // pointerEventData.position = new Vector3(UIManager.GetInstance().GetCrossHairPos().x, UIManager.GetInstance().GetCrossHairPos().y, 0);
|
|
|
+ // //射线检测ui
|
|
|
+ // List<RaycastResult> uiRaycastResultCache = new List<RaycastResult>();
|
|
|
+ // eventSystem.RaycastAll(pointerEventData, uiRaycastResultCache);
|
|
|
+ // if (uiRaycastResultCache.Count > 0)
|
|
|
+ // {
|
|
|
+ // // 是否有button
|
|
|
+ // Button btn = uiRaycastResultCache[0].gameObject.GetComponent<Button>();
|
|
|
+ // if (btn == null)
|
|
|
+ // {
|
|
|
+ // // 防止检测到button下的text (ui注意设置 button下text不要勾选raycast
|
|
|
+ // btn = uiRaycastResultCache[0].gameObject.transform.GetComponentInParent<Button>();
|
|
|
+ // if (btn == null)
|
|
|
+ // {
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // btn.onClick.Invoke();
|
|
|
+ // //Debug.Log("eventsystem 触发 + " + uiRaycastResultCache[0].gameObject.name);
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化相机等
|
|
|
@@ -377,47 +362,35 @@ namespace WildAttack
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
- /// android端旋转弓
|
|
|
+ /// 移动端用户触屏监听
|
|
|
/// </summary>
|
|
|
- private void UpdateBowAndriod()
|
|
|
+ private void InitTouchChecker()
|
|
|
{
|
|
|
- if (Input.touchCount == 1)
|
|
|
+ touchChecker.onMoved += delegate (Touch t, bool isOnUI)
|
|
|
{
|
|
|
- Touch touch = Input.GetTouch(0);
|
|
|
- if (touch.phase == TouchPhase.Began)
|
|
|
- {
|
|
|
+ if (isOnUI) return;
|
|
|
+ if (shootSpawn <= GameModule.GetInstance().GetData("downTime") && shootSpawn > 0) return;
|
|
|
|
|
|
- }
|
|
|
- else if (touch.phase == TouchPhase.Moved)
|
|
|
- {
|
|
|
- if (shootSpawn <= GameModule.GetInstance().GetData("downTime") && shootSpawn > 0) return;
|
|
|
-
|
|
|
- Vector3 dis = touch.rawPosition - touch.deltaPosition;
|
|
|
- if (dis.x != 0 || dis.y != 0)
|
|
|
- {
|
|
|
- if (isOver)
|
|
|
- {
|
|
|
- CrossHairTrans.eulerAngles = LimitCrossHair(new Vector3(CrossHairTrans.eulerAngles.x - (touch.deltaPosition.y * Time.deltaTime), CrossHairTrans.eulerAngles.y + (touch.deltaPosition.x * Time.deltaTime), 0));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CrossHairTrans.eulerAngles = LimitAngles(new Vector3(CrossHairTrans.eulerAngles.x - (touch.deltaPosition.y * Time.deltaTime), CrossHairTrans.eulerAngles.y + (touch.deltaPosition.x * Time.deltaTime), 0));
|
|
|
- CrossHairTransRaycast();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else if (touch.phase == TouchPhase.Ended)
|
|
|
+ Vector3 dis = t.rawPosition - t.deltaPosition;
|
|
|
+ if (dis.x != 0 || dis.y != 0)
|
|
|
{
|
|
|
- if (CheckCrossHairOverUI())
|
|
|
+ if (isOver)
|
|
|
{
|
|
|
- return;
|
|
|
+ CrossHairTrans.eulerAngles = LimitCrossHair(new Vector3(CrossHairTrans.eulerAngles.x - (t.deltaPosition.y * Time.deltaTime), CrossHairTrans.eulerAngles.y + (t.deltaPosition.x * Time.deltaTime), 0));
|
|
|
}
|
|
|
- if (!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
|
|
|
+ else
|
|
|
{
|
|
|
- bow.Shoot(testSpeed);
|
|
|
+ CrossHairTrans.eulerAngles = LimitAngles(new Vector3(CrossHairTrans.eulerAngles.x - (t.deltaPosition.y * Time.deltaTime), CrossHairTrans.eulerAngles.y + (t.deltaPosition.x * Time.deltaTime), 0));
|
|
|
+ CrossHairTransRaycast();
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
+ touchChecker.onEnded += delegate (Touch t, bool isOnUI)
|
|
|
+ {
|
|
|
+ if (isOnUI) return;
|
|
|
+ if (isOver) return;
|
|
|
+ bow.Shoot(testSpeed);
|
|
|
+ };
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 归位
|
|
|
@@ -429,7 +402,7 @@ namespace WildAttack
|
|
|
{
|
|
|
CrossHairTrans.localRotation = Quaternion.Euler(Vector3.zero);
|
|
|
bow.transform.localRotation = CrossHairTrans.localRotation;
|
|
|
- SmartBowController.Instance.ResetAim();
|
|
|
+ AimHandler.ins?.DoIdentity();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -563,13 +536,9 @@ namespace WildAttack
|
|
|
// speed区间 7~20?
|
|
|
// 在这里判断是否和ui交互? 优先判断ui 不是ui再射箭
|
|
|
|
|
|
- if (CheckCrossHairOverUI())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ if (isOver) return;
|
|
|
bow.Shoot(speed * smartBowSpeed);
|
|
|
- TipText.Show((speed * smartBowSpeed).ToString());
|
|
|
+ //TipText.Show((speed * smartBowSpeed).ToString());
|
|
|
// 角度 OnRotationUpdate
|
|
|
}
|
|
|
|
|
|
@@ -577,18 +546,6 @@ namespace WildAttack
|
|
|
{
|
|
|
shootSpawn = spawn;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- void OnFunctionKeyPress()
|
|
|
- {
|
|
|
- ResetAim();
|
|
|
- }
|
|
|
-
|
|
|
- void OnFunctionKeyLongPress()
|
|
|
- {
|
|
|
- TipText.Show(smartBowSpeed.ToString());
|
|
|
- }
|
|
|
-
|
|
|
#endregion
|
|
|
|
|
|
#region 限制其显示范围不超出屏幕
|