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; } } }