private void OnTapEvent(TapEvent evt) { if (PlayerManager.IsLocalPlayer(mDMono.gameObject)) { if (AllianceUtil.IsInTransferDart) { return; } SelectionLogic.MaxTouches = SelectionLogic.DEFAULT_MAX_TOUCHES; if (evt.hasValidNavPoint) { playerController.CharacterComponent.LocomotionComponent.TouchTap(); } selectingTarget = true; OnTouchUpdateOrTap(evt.target, evt.groundPosition, evt.hasValidNavPoint); if (evt.target == mDMono.transform) { AutoPickupLoot(); playerController.TargetingComponent.SetMovementTarget(Vector3.zero, true); } //HideSelfSelection(); } }
private void Update() { if (UnityEngine.Input.GetMouseButtonDown(0)) { TapEvent?.Invoke(UnityEngine.Input.mousePosition); } }
void OnTapEvent(TapEvent evt) { if (evt.target != null) { MeshClick mesh_click = evt.target.gameObject.GetComponent <MeshClick>(); if (mesh_click != null) { mesh_click.OnMeshClick(evt.target.gameObject); } } }
private IEnumerator QueueSingleTap(TapEvent tapEvent) { _lastTapTime = Time.time; _didDoubleTap = false; do { yield return(null); }while (Time.time - _lastTapTime < DoubleTapLength); if (!_didDoubleTap) { RaiseEvent(tapEvent); } }
public void Add(GameObject go, int x, int y) { if(Taps.Count == 0) { sw.Reset(); sw.Start(); } var names = new List<string>(); var t = go.transform; while(t != null) { names.Add(t.name); t = t.parent; } var name = string.Join("/", names.ToArray()); var tap = new TapEvent(name, x, y, sw.Elapsed.TotalSeconds); Taps.Add(tap); }
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(); }
private void OnTap() { TapEvent?.Invoke(_touchMovement); }
/// <summary> /// Gets the inputs /// </summary> private void Update() { bool tap = false; #region Standalone Inputs if (Input.GetMouseButtonDown(0)) { tap = true; startTouch = Input.mousePosition; } else if (Input.GetMouseButtonUp(0)) { startTouch = swipeDelta = Vector2.zero; return; } if (Input.GetKeyUp(KeyCode.LeftArrow)) { SwipeEvent?.Invoke(Enums.Direction.Left); } else if (Input.GetKeyUp(KeyCode.RightArrow)) { SwipeEvent?.Invoke(Enums.Direction.Right); return; } else if (Input.GetKeyUp(KeyCode.UpArrow)) { SwipeEvent?.Invoke(Enums.Direction.Up); return; } else if (Input.GetKeyUp(KeyCode.DownArrow)) { SwipeEvent?.Invoke(Enums.Direction.Down); return; } else { if (tap) { TapEvent?.Invoke(); } } #endregion #region Mobile Inputs tap = false; if (Input.touches.Length != 0) { if (Input.touches[0].phase == TouchPhase.Began) { tap = true; startTouch = Input.mousePosition; } else if (Input.touches[0].phase == TouchPhase.Ended || Input.touches[0].phase == TouchPhase.Canceled) { startTouch = swipeDelta = Vector2.zero; } } #endregion //Calculate distance swipeDelta = Vector2.zero; if (startTouch != Vector2.zero) { //Check with mobile if (Input.touches.Length != 0) { swipeDelta = Input.touches[0].position - startTouch; } //Check with standalone else if (Input.GetMouseButton(0)) { swipeDelta = (Vector2)(Input.mousePosition) - startTouch; } } //Check if we're beyong the deadzone if (swipeDelta.magnitude > DEADZONE) { //This is a confirmed swipe float x = swipeDelta.x; float y = swipeDelta.y; if (Mathf.Abs(x) > Mathf.Abs(y)) { //Left or Right if (x < 0) {//Left SwipeEvent?.Invoke(Enums.Direction.Left); } else {//Right SwipeEvent?.Invoke(Enums.Direction.Right); } } else { //Up or Down if (y < 0) {//Down SwipeEvent?.Invoke(Enums.Direction.Down); } else {//Up SwipeEvent?.Invoke(Enums.Direction.Up); } } startTouch = swipeDelta = Vector2.zero; } else { if (tap) { TapEvent?.Invoke(); } } }
private void Tap() { lastTouchDetected = Time.time; TapEvent?.Invoke(GetTouchPosition(0)); }
public virtual bool OnTap(TapEvent e) { return(false); }
public override bool OnTap(TapEvent e) { return(onTap != null && onTap(e)); }
void OnTap() { TapEvent?.Invoke(m_touchStartPosition); }