private protected void OnTouchesBegan(List <CCTouch> touches, CCEvent touchEvent) { Pressed = true; switch (touches.Count) { case 1: { var now = DateTime.Now; if ((now - TimeLastTap).TotalSeconds < DoubleTapInterval) { DoubleTapEvent?.Invoke(this, new SingleTouchEventArgs(touches[0])); } // stop all scrolling if (Scroller != null) { Scroller.OnTouchesBegan(touches, touchEvent); } TimeLastTap = now; } break; default: break; } }
private void OnDoubleTapEvent(DoubleTapEvent evt) { if (PlayerManager.IsLocalPlayer(mDMono.gameObject)) { if (AllianceUtil.IsInTransferDart) { return; } SelectionLogic.MaxTouches = SelectionLogic.DEFAULT_MAX_TOUCHES; } }
private void DoDoubleTap(DoubleTapEvent doubleTapEvent) { StopCoroutine("QueueSingleTap"); _didDoubleTap = true; RaiseEvent(doubleTapEvent); }
private void EndSingleTouch(TouchWrapper touch, Transform target, Vector3 location, Vector3 direction, Vector3 groundPosition, bool hasValidNavPoint) { float singleTouchDuration = Time.time - _singleTouchStartTime; if (singleTouchDuration < TapLength) { if (Time.time - _lastTapTime > DoubleTapLength) { TapEvent tapEvent = (null != target) ? new TapEvent(touch.position, target, location) : new TapEvent(touch.position, location); tapEvent.direction = direction; tapEvent.groundPosition = groundPosition; tapEvent.hasValidNavPoint = hasValidNavPoint; #if BUFFER_SINGLE_TAPS StartCoroutine(QueueSingleTap(tapEvent)); #else _lastTapTime = Time.time; _didDoubleTap = false; RaiseEvent(tapEvent); #endif } else { DoubleTapEvent doubleTapEvent = (null != target) ? new DoubleTapEvent(touch.position, target, location) : new DoubleTapEvent(touch.position, location); doubleTapEvent.direction = direction; DoDoubleTap(doubleTapEvent); } } else if (_touchStartedOnPlayer) { DragFromPlayerGestureEndEvent evt = null; if (target) { evt = new DragFromPlayerGestureEndEvent(touch.position, target); } else { evt = new DragFromPlayerGestureEndEvent(touch.position, location); } evt.direction = direction; evt.groundPosition = groundPosition; RaiseEvent(evt); _touchStartedOnPlayer = false; } TouchEndEvent endEvent = (TouchEndEvent)CodeObjectManager.GetEventManager(typeof(TouchEndEvent)).GetNext();; if (target != null) { endEvent.Initialize(touch.position, target, location); } else { endEvent.Initialize(touch.position, location); } endEvent.direction = direction; endEvent.groundPosition = groundPosition; RaiseEvent(endEvent); CodeObjectManager.GetEventManager(typeof(TouchEndEvent)).Destroy(endEvent); //check for flick gesture float flick_history_check = 1.5f; float time_look_back = 0.0f; int i = 0; int touch_index = m_touch_history_index - 1 > 0 ? m_touch_history_index - 1: TOUCH_HISTORY_LENGTH - 1; Vector3 flick_vel = Vector3.zero; float last_time = _touchHistory[touch_index]._time; Vector3 last_flick = touch.position; while (time_look_back < flick_history_check && i < TOUCH_HISTORY_LENGTH - 1) { if (_touchHistory[touch_index]._time == 0.0f) { break; } float time = last_time - _touchHistory[touch_index]._time; last_time = _touchHistory[touch_index]._time; time_look_back += time; flick_vel += _touchHistory[touch_index]._position - last_flick; last_flick = _touchHistory[touch_index]._position; i++; touch_index = touch_index - 1 > 0 ? touch_index - 1 : TOUCH_HISTORY_LENGTH - 1; } //EB.Debug.Log (i); if (time_look_back > 0.0f) { flick_vel *= time_look_back; if (flick_vel.magnitude > 0.2f) { FlickEvent flickEvent = new FlickEvent(); flickEvent.Initialize(touch.position, flick_vel); RaiseEvent(flickEvent); } else { //EB.Debug.Log ("VEL FAIL"); } } else { //EB.Debug.Log ("TIME FAIL"); } ResetTouchHistory(); }