void OnTouchUpdateEvent(TouchUpdateEvent evt) { Vector3 pos_diff = m_initial_touch - evt.screenPosition; m_initial_touch = evt.screenPosition; m_camera_velocity = pos_diff; //m_flick_timer = 0.0f; }
private void OnTouchUpdateEvent(TouchUpdateEvent evt) { if (PlayerManager.IsLocalPlayer(mDMono.gameObject)) { if (AllianceUtil.IsInTransferDart) { return; } SelectionLogic.MaxTouches = 1; selectingTarget = false; OnTouchUpdateOrTap(evt.target, evt.groundPosition, evt.hasValidNavPoint, true); } }
private void UpdateSingleTouch(TouchWrapper touch, Transform target, Vector3 location, Vector3 direction, Vector3 groundPosition, bool hasValidNavPoint) { float touchDuration = Time.time - _singleTouchStartTime; float selfSelectRadiusSq = GlobalBalanceData.Instance.selfSelectRadius; selfSelectRadiusSq *= selfSelectRadiusSq; if (touchDuration < TapLength) { // Do nothing yet } else if (!_longPressStarted) { // This press is longer than a tap _longPressStarted = true; TouchStartEvent startEvent = (TouchStartEvent)CodeObjectManager.GetEventManager(typeof(TouchStartEvent)).GetNext(); if (target) { startEvent.Initialize(touch.position, target, location); } else { startEvent.Initialize(touch.position, location); } startEvent.direction = direction; startEvent.groundPosition = groundPosition; startEvent.deltaPosition = touch.deltaPosition; RaiseEvent(startEvent); CodeObjectManager.GetEventManager(typeof(TouchStartEvent)).Destroy(startEvent); } else if (_touchStartedOnPlayer) { if (!_playerLongPressStarted) { if (GameUtils.GetDistSqXZ(groundPosition, _playerTransform.position) > selfSelectRadiusSq) { DragFromPlayerGestureStartEvent evt = null; if (target) { evt = new DragFromPlayerGestureStartEvent(touch.position, target); } else { evt = new DragFromPlayerGestureStartEvent(touch.position, location); } evt.direction = direction; evt.groundPosition = groundPosition; RaiseEvent(evt); _playerLongPressStarted = true; } } else { DragFromPlayerGestureUpdateEvent evt = null; if (target) { evt = new DragFromPlayerGestureUpdateEvent(touch.position, target); } else { evt = new DragFromPlayerGestureUpdateEvent(touch.position, location); } evt.direction = direction; evt.groundPosition = groundPosition; RaiseEvent(evt); } } else { TouchUpdateEvent updateEvent = (TouchUpdateEvent)CodeObjectManager.GetEventManager(typeof(TouchUpdateEvent)).GetNext();; if (target != null) { updateEvent.Initialize(touch.position, target, location); } else { updateEvent.Initialize(touch.position, location); } updateEvent.direction = direction; updateEvent.groundPosition = groundPosition; updateEvent.hasValidNavPoint = hasValidNavPoint; RaiseEvent(updateEvent); CodeObjectManager.GetEventManager(typeof(TouchUpdateEvent)).Destroy(updateEvent); } //add the touch to the touch history for gesture checking on end _touchHistory[m_touch_history_index]._time = Time.realtimeSinceStartup; _touchHistory[m_touch_history_index]._position = touch.position; m_touch_history_index = (m_touch_history_index + 1) % TOUCH_HISTORY_LENGTH; }