private void OnTwoFingerTouchUpdateEvent(TwoFingerTouchUpdateEvent evt) { Vector3 currentPinch = evt.screenPosition2 - evt.screenPosition1; float pinchRatio = currentPinch.magnitude / _initialPinch.magnitude; UpdatePinch(pinchRatio); }
private void OnTwoFingerTouchUpdateEvent(TwoFingerTouchUpdateEvent evt) { if (PlayerManager.IsLocalPlayer(mDMono.gameObject)) { SelectionLogic.MaxTouches = 2; } }
private void EndDoubleTouch(TouchWrapper firstTouch, TouchWrapper secondTouch, Transform target1, Vector3 position1, Vector3 direction1, Vector3 groundPosition1, bool isFindFirstTarget, Transform target2, Vector3 position2, Vector3 direction2, Vector3 groundPosition2, bool isFindSecondTarget, TwoFingerTouchUpdateEvent evt, bool isFindCenterTarget, Transform targetCenter, Vector3 positionCenter, Vector3 directionCenter, Vector3 groundPositionCenter) { if (isFindFirstTarget) { if (target1 != null) { evt.target1 = target1; evt.position1 = target1.position; } else { evt.position1 = position1; } } evt.direction1 = direction1; evt.groundPosition1 = groundPosition1; if (isFindSecondTarget) { if (target2 != null) { evt.target2 = target2; evt.position2 = target2.position; } else { evt.position2 = position2; } } evt.direction2 = direction2; evt.groundPosition2 = groundPosition2; if (isFindCenterTarget) { if (targetCenter != null) { evt.targetCenter = targetCenter; evt.positionCenter = targetCenter.position; } else { evt.positionCenter = positionCenter; } } evt.direction2 = direction2; evt.groundPosition2 = groundPosition2; RaiseEvent(evt); }
void Update() { if (!GameEngine.Instance.IsTimeToRootScene) { return; } //如果是副本中则不能进入rvo /*if (LTInstanceMapModel.Instance.IsInstanceMap()) * { * return; * }*/ if (!AreControlsEnabled) { return; } if (GameVars.paused || TouchController.Instance == null) { return; } int numTouches = System.Math.Min(TouchController.Instance.ActiveTouches.Count, MaxTouches); if (_touchStartOverUI) { for (int i = 0; i < numTouches; i++) { TouchWrapper touch = TouchController.Instance.ActiveTouches[i]; if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) { _touchStartOverUI = false; } } return; } // make sure our events aren't being handled by NGUI if (UICamera.IsOverUIByRoot(mRoot)) { for (int i = 0; i < numTouches; i++) { if (TouchController.Instance.ActiveTouches[i].phase == TouchPhase.Began) { _touchStartOverUI = true; return; } } } if (numTouches == 1) { if (!_areSingleTouchEnabled) { return; } TouchWrapper touch = TouchController.Instance.ActiveTouches[0]; Transform target = null; Vector3 location = Vector3.zero; Vector3 groundPosition = Vector3.zero; Vector3 direction = Vector3.zero; bool isFindTarget = false; if (IsShowJoystick) { isFindTarget = true; } else { isFindTarget = FindTargetAndLocation(touch, out target, out location, out groundPosition, out direction); } if (touch.phase == TouchPhase.Began) { _firstFingerID = touch.fingerId; StartSingleTouch(groundPosition, isFindTarget); } if (touch.phase == TouchPhase.Began || (touch.fingerId == _firstFingerID && touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)) { UpdateSingleTouch(touch, target, location, direction, groundPosition, isFindTarget); } if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) { EndSingleTouch(touch, target, location, direction, groundPosition, isFindTarget); _touchStartOverUI = false; } } else if (numTouches > 1) { TouchWrapper firstTouch = TouchController.Instance.ActiveTouches[0]; TouchWrapper secondTouch = TouchController.Instance.ActiveTouches[1]; Transform target1 = null; Vector3 position1 = Vector3.zero; Vector3 direction1 = Vector3.zero; Vector3 groundPosition1 = Vector3.zero; bool isFindFirstTarget = false; if (IsShowJoystick) { isFindFirstTarget = true; } else { isFindFirstTarget = FindTargetAndLocation(firstTouch, out target1, out position1, out groundPosition1, out direction1); } Transform target2 = null; Vector3 position2 = Vector3.zero; Vector3 direction2 = Vector3.zero; Vector3 groundPosition2 = Vector3.zero; bool isFindSecondTarget = false; if (IsShowJoystick) { isFindSecondTarget = true; } else { isFindSecondTarget = FindTargetAndLocation(secondTouch, out target2, out position2, out groundPosition2, out direction2); } Transform targetCenter = null; Vector3 positionCenter = Vector3.zero; Vector3 directionCenter = Vector3.zero; Vector3 groundPositionCenter = Vector3.zero; TwoFingerTouchUpdateEvent evt = new TwoFingerTouchUpdateEvent(firstTouch.position, secondTouch.position); bool isFindCenterTarget = false; if (IsShowJoystick) { isFindCenterTarget = true; } else { isFindCenterTarget = FindTargetAndLocation(new TouchWrapper(0, TouchPhase.Moved, evt.screenPositionCenter), out targetCenter, out positionCenter, out groundPositionCenter, out directionCenter); } if (firstTouch.phase == TouchPhase.Began || secondTouch.phase == TouchPhase.Began) { StartDoubleTouch(firstTouch, secondTouch, target1, position1, direction1, groundPosition1, isFindFirstTarget, target2, position2, direction2, groundPosition2, isFindSecondTarget); } if (firstTouch.phase != TouchPhase.Ended && firstTouch.phase != TouchPhase.Canceled && secondTouch.phase != TouchPhase.Ended && secondTouch.phase != TouchPhase.Canceled) { UpdateDoubleTouch(firstTouch, secondTouch, target1, position1, direction1, groundPosition1, isFindFirstTarget, target2, position2, direction2, groundPosition2, isFindSecondTarget, evt, isFindCenterTarget, targetCenter, positionCenter, directionCenter, groundPositionCenter); } if (firstTouch.phase == TouchPhase.Ended || secondTouch.phase == TouchPhase.Ended || firstTouch.phase == TouchPhase.Canceled || secondTouch.phase == TouchPhase.Canceled) { EndDoubleTouch(firstTouch, secondTouch, target1, position1, direction1, groundPosition1, isFindFirstTarget, target2, position2, direction2, groundPosition2, isFindSecondTarget, evt, isFindCenterTarget, targetCenter, positionCenter, directionCenter, groundPositionCenter); _touchStartOverUI = false; } } }