void HandleSwipe(TouchInformation pTouchInfo) { if (OnSwipeEvent != null) { OnSwipeEvent(pTouchInfo); } }
void OnTouchStart(TouchInformation _pTouchInfo) { if (mCurrentPinch != null) { mCurrentPinch.mTouchTwo = _pTouchInfo; mCurrentPinch.mStartDistance = mCurrentPinch.GetCurrentDistance(); mPinchGestures.Add(mCurrentPinch); try { if (OnPinchStart != null) { OnPinchStart(mCurrentPinch); } } catch (Exception e) { Debug.LogException(e); } mCurrentPinch = null; } else { mCurrentPinch = new PinchGestureEvent(); mCurrentPinch.mTouchOne = _pTouchInfo; } }
protected void UpdateMouse() { if (Input.GetMouseButtonDown(0)) { CreateTouch(Input.mousePosition, 0); } if (mMouseTouch != null) { mMouseTouch.Update(Input.mousePosition, Input.GetMouseButtonUp(0)); if (OnTouchUpdate != null) { OnTouchUpdate(mMouseTouch); } if (mMouseTouch.isTap) { HandleTap(mMouseTouch); } if (mMouseTouch.isSwipe) { HandleSwipe(mMouseTouch); } if (mMouseTouch.isDead) { DestroyTouch(mMouseTouch); mMouseTouch = null; return; } } }
void HandleTap(TouchInformation touchInfo) { if (TapEvent != null) { TapEvent(touchInfo); } }
void OnPress(bool isPressed) { this.m_CamareManager.OnPress(isPressed); if (isPressed) { TouchInformation information = new TouchInformation() { IsMoveOutSide = false, PressedFrameCount = this.m_CurrentFrame }; this.m_Touches.Add(UICamera.currentTouchID, information); } else { int fingerID = UICamera.currentTouchID; TouchInformation information = this.m_Touches[fingerID]; if (!information.IsMoveOutSide && this.m_CurrentFrame - information.PressedFrameCount < this.m_GenerateArmyVectorThreshold) { this.m_CharacterFactory.Construct(UICamera.currentTouch.pos); } else if (information.IsMoveOutSide) { this.m_CamareManager.OnClick(); } this.m_Touches.Remove(fingerID); } }
void OnTouchEnd(TouchInformation _pTouchInfo) { if (mCurrentPinch == null) { return; } if (mCurrentPinch.mTouchOne == _pTouchInfo) { mCurrentPinch = null; return; } foreach (var p in mPinchGestures) { if (p.mTouchOne == _pTouchInfo || p.mTouchTwo == _pTouchInfo) { mPinchGestures.Remove(p); p.mIsDead = true; try { if (OnPinchEnd != null) { OnPinchEnd(p); } }catch (Exception e) { Debug.LogException(e); } break; } } }
void HandleSwipe(TouchInformation touchInfo) { if (SwipeEvent != null) { SwipeEvent(touchInfo); } }
void HandleTap(TouchInformation pTouchInfo) { if (OnTapEvent != null) { OnTapEvent(pTouchInfo); } }
void CreateTouch(Touch pTouch) { mTouchCnt = mTouchCnt + 1; TouchInformation ti = new TouchInformation(pTouch, mTouchCnt); CreateTouch(ti); }
void Tap(TouchInformation touchInfo) { if (Time.time > nextFire) { nextFire = Time.time + FireRate; GameObject bullet = Instantiate(Shot, GetComponent <Transform>().position, Quaternion.identity) as GameObject; Destroy(bullet, 0.2f); } }
void DestroyTouch(TouchInformation touchInfo) { if (TouchEnd != null) { TouchEnd(touchInfo); } touches.Remove(touchInfo); }
void CreateTouch(TouchInformation pTouchInfo) { mTouches.Add(pTouchInfo); if (OnTouchStart != null) { OnTouchStart(pTouchInfo); } }
void DestroyTouch(TouchInformation pTouchInfo) { if (OnTouchEnd != null) { OnTouchEnd(pTouchInfo); } mTouches.Remove(pTouchInfo); }
void OnTap(TouchInformation _pTouchInfo) { if (mHidden && mHiddenTriggerRect.Contains(_pTouchInfo.screenPosition)) { mHidden = false; } if (!mHidden && !mVisibleTriggerRect.Contains(_pTouchInfo.screenPosition)) { mHidden = true; } }
void CreateTouch(Touch touch) { // we don't create any touches if input is disabled. if (InputEnabled) { touchCount++; TouchInformation ti = new TouchInformation(touch, touchCount); CreateTouch(ti); } }
void CreateTouch(Vector2 pPosition, int pBtnId) { mTouchCnt = mTouchCnt + 1; TouchInformation ti = new TouchInformation(pPosition, mTouchCnt, pBtnId); CreateTouch(ti); if (mMouseTouch != null) { DestroyTouch(mMouseTouch); } mMouseTouch = ti; }
void CreateTouch(TouchInformation touchInfo) { // we don't create any touches if input is disabled. if (InputEnabled) { touches.Add(touchInfo); if (TouchStart != null) { TouchStart(touchInfo); } } }
void HandleTouchStart(TouchInformation touchInfo) { if (KeyDown == null) { return; } foreach (KeyMapping km in keyMappings) { if (km.relativeScreenRect.Contains(touchInfo.RelativeScreenPosition)) { km.touchId = touchInfo.id; KeyDown(km.name); } } }
void HandleTouchEnd(TouchInformation touchInfo) { if (KeyUp == null) { return; } foreach (KeyMapping km in keyMappings) { if (km.touchId == touchInfo.id) { KeyUp(km.name); } } }
private void MoveInputs(TouchInformation touchInfo) { string info = touchInfo.GetSwipeDirection().ToString(); switch (info) { case "Left": direction = 1f; break; case "Right": direction = -1f; break; case "None": direction = 0f; Fire(); break; default: break; } }
protected void UpdateTouch(Touch touchInfo) { TouchInformation ti = GetTouch(touchInfo); if (touchInfo.phase == TouchPhase.Began) { if (ti != null) { // Touch was started twice; weird! Bug? ti.phase = TouchPhase.Canceled; DestroyTouch(ti); } CreateTouch(touchInfo); return; } if (ti != null) { ti.Update(touchInfo); if (!inputEnabled) { ti.phase = TouchPhase.Canceled; } if (TouchUpdate != null) { TouchUpdate(ti); } } if (ti.IsTap) { HandleTap(ti); } if (ti.IsSwipe) { HandleSwipe(ti); } if (ti.IsDead) { DestroyTouch(ti); return; } }
void HandleOnTouchStart(TouchInformation pTouchInfo) { #if UNITY_ANDROID || UNITY_IOS || UNITY_BB10 foreach (KeyMapping km in mKeyMappings) { if (km.mRelativeScreenRect.Contains(pTouchInfo.relativeScreenPosition)) { km.SetTouchId(pTouchInfo.mId); if (OnKeyDown != null) { OnKeyDown(km.mName); } } } #endif }
void gameInput_SwipeEvent(TouchInformation touchInfo) { TouchInformation.ESwipeDirection swipeDirection = touchInfo.GetSwipeDirection(); if (swipeDirection == TouchInformation.ESwipeDirection.Right) { ICommand moveCommand = new MoveCommand(Direction.right); moveCommand.Execute(toControl); } if (swipeDirection == TouchInformation.ESwipeDirection.Left) { ICommand moveCommand = new MoveCommand(Direction.left); moveCommand.Execute(toControl); } }
void OnDrag(Vector2 deltaVector) { TouchInformation touchInfo = this.m_Touches[UICamera.currentTouchID]; if (this.m_CurrentFrame - touchInfo.PressedFrameCount < this.m_GenerateArmyFrameThreshold) { if (UICamera.currentTouch.totalDelta.magnitude > this.m_GenerateArmyVectorThreshold) { touchInfo.IsMoveOutSide = true; } } if (touchInfo.IsMoveOutSide || this.m_CurrentFrame - touchInfo.PressedFrameCount < this.m_GenerateArmyFrameThreshold) { this.m_CamareManager.OnDrag(deltaVector); } }
void HandleOnTouchEnd(TouchInformation pTouchInfo) { #if UNITY_ANDROID || UNITY_IOS || UNITY_BB10 if (OnKeyUp == null) { return; } foreach (KeyMapping km in mKeyMappings) { if (km.GetTouchId() == pTouchInfo.mId) { OnKeyUp(km.mName); } } #endif }
void HandleOnTapEvent(TouchInformation pTouchInfo) { if (KeyMappingTriggered == null) { return; } foreach (KeyMapping km in keyMappings) { if (km.isTap && km.swipeDirection == TouchInformation.ESwipeDirection.None) { if (km.relativeScreenRect.Contains(pTouchInfo.RelativeScreenPosition)) { KeyMappingTriggered(km.name); } } } }
/// <summary> /// Handles the on swipe event. and calls keymapping delegates /// </summary> /// <param name='pTouchInfo'> /// _ti. /// </param> void HandleOnSwipeEvent(TouchInformation pTouchInfo) { #if UNITY_ANDROID || UNITY_IOS || UNITY_BB10 foreach (KeyMapping km in mKeyMappings) { if (km.mIsTap && km.mSwipeDirection == pTouchInfo.GetSwipeDirection()) { if (km.mRelativeScreenRect.Contains(pTouchInfo.relativeScreenPosition)) { if (OnKeyMappingTriggered != null) { OnKeyMappingTriggered(km.mName); } } } } #endif }
void CreateTouch(Vector2 position, int btnId) { TouchInformation ti = null; // we don't create any touches if input is disabled. if (InputEnabled) { touchCount++; ti = new TouchInformation(position, touchCount, btnId); CreateTouch(ti); } if (mouseTouch != null) { DestroyTouch(mouseTouch); } mouseTouch = ti; }
private void SetupPerTouchInformation(ref Touch theTouch, ref TouchInformation touchInformation) { touchInformation.m_touchDelta -= theTouch.deltaPosition; touchInformation.m_touchPosition = theTouch.position; TouchPhase TheTouchPhase = theTouch.phase; if (TheTouchPhase == TouchPhase.Began) { touchInformation.m_type = TOUCH_EVENT_TYPE.PRESS; m_firstTouch = true; } else if (TheTouchPhase == TouchPhase.Ended) { touchInformation.m_type = TOUCH_EVENT_TYPE.RELEASE; m_firstTouch = false; } else if (TheTouchPhase == TouchPhase.Moved) { touchInformation.m_type = TOUCH_EVENT_TYPE.MOVE; } }
protected void UpdateMouse() { if (inputEnabled && UnityEngine.Input.GetMouseButtonDown(0)) { CreateTouch(UnityEngine.Input.mousePosition, 0); } if (mouseTouch != null) { if (!inputEnabled) { mouseTouch.Update(UnityEngine.Input.mousePosition, true); } else { mouseTouch.Update(UnityEngine.Input.mousePosition, UnityEngine.Input.GetMouseButtonUp(0)); } if (TouchUpdate != null) { TouchUpdate(mouseTouch); } if (mouseTouch.IsTap) { HandleTap(mouseTouch); } if (mouseTouch.IsSwipe) { HandleSwipe(mouseTouch); } if (mouseTouch.IsDead) { DestroyTouch(mouseTouch); mouseTouch = null; return; } } }
void HandleSwipeEvent(TouchInformation pTouchInfo) { if(KeyMappingTriggered == null) return; foreach(KeyMapping km in keyMappings) { if(km.isTap && km.swipeDirection == pTouchInfo.GetSwipeDirection()) { if(km.relativeScreenRect.Contains(pTouchInfo.RelativeScreenPosition)) { KeyMappingTriggered(km.name); } } } }
void HandleTouchEnd(TouchInformation touchInfo) { if(KeyUp == null) return; foreach(KeyMapping km in keyMappings) { if(km.touchId == touchInfo.id) { KeyUp(km.name); } } }
void HandleTouchStart(TouchInformation touchInfo) { if(KeyDown == null) return; foreach(KeyMapping km in keyMappings) { if(km.relativeScreenRect.Contains(touchInfo.RelativeScreenPosition)) { km.touchId = touchInfo.id; KeyDown(km.name); } } }