コード例 #1
0
 void HandleSwipe(TouchInformation pTouchInfo)
 {
     if (OnSwipeEvent != null)
     {
         OnSwipeEvent(pTouchInfo);
     }
 }
コード例 #2
0
    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;
        }
    }
コード例 #3
0
    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;
            }
        }
    }
コード例 #4
0
 void HandleTap(TouchInformation touchInfo)
 {
     if (TapEvent != null)
     {
         TapEvent(touchInfo);
     }
 }
コード例 #5
0
    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);
        }
    }
コード例 #6
0
    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;
            }
        }
    }
コード例 #7
0
 void HandleSwipe(TouchInformation touchInfo)
 {
     if (SwipeEvent != null)
     {
         SwipeEvent(touchInfo);
     }
 }
コード例 #8
0
 void HandleTap(TouchInformation pTouchInfo)
 {
     if (OnTapEvent != null)
     {
         OnTapEvent(pTouchInfo);
     }
 }
コード例 #9
0
    void CreateTouch(Touch pTouch)
    {
        mTouchCnt = mTouchCnt + 1;

        TouchInformation ti = new TouchInformation(pTouch, mTouchCnt);

        CreateTouch(ti);
    }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
        void DestroyTouch(TouchInformation touchInfo)
        {
            if (TouchEnd != null)
            {
                TouchEnd(touchInfo);
            }

            touches.Remove(touchInfo);
        }
コード例 #12
0
    void CreateTouch(TouchInformation pTouchInfo)
    {
        mTouches.Add(pTouchInfo);

        if (OnTouchStart != null)
        {
            OnTouchStart(pTouchInfo);
        }
    }
コード例 #13
0
    void DestroyTouch(TouchInformation pTouchInfo)
    {
        if (OnTouchEnd != null)
        {
            OnTouchEnd(pTouchInfo);
        }

        mTouches.Remove(pTouchInfo);
    }
コード例 #14
0
 void OnTap(TouchInformation _pTouchInfo)
 {
     if (mHidden && mHiddenTriggerRect.Contains(_pTouchInfo.screenPosition))
     {
         mHidden = false;
     }
     if (!mHidden && !mVisibleTriggerRect.Contains(_pTouchInfo.screenPosition))
     {
         mHidden = true;
     }
 }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
    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;
    }
コード例 #17
0
        void CreateTouch(TouchInformation touchInfo)
        {
            // we don't create any touches if input is disabled.
            if (InputEnabled)
            {
                touches.Add(touchInfo);

                if (TouchStart != null)
                {
                    TouchStart(touchInfo);
                }
            }
        }
コード例 #18
0
 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);
         }
     }
 }
コード例 #19
0
        void HandleTouchEnd(TouchInformation touchInfo)
        {
            if (KeyUp == null)
            {
                return;
            }

            foreach (KeyMapping km in keyMappings)
            {
                if (km.touchId == touchInfo.id)
                {
                    KeyUp(km.name);
                }
            }
        }
コード例 #20
0
    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;
        }
    }
コード例 #21
0
        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;
            }
        }
コード例 #22
0
ファイル: GameInput.cs プロジェクト: Outlaw1123/Trial-Project
    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
    }
コード例 #23
0
    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);
        }
    }
コード例 #24
0
    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);
        }
    }
コード例 #25
0
ファイル: GameInput.cs プロジェクト: Outlaw1123/Trial-Project
    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
    }
コード例 #26
0
        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);
                    }
                }
            }
        }
コード例 #27
0
ファイル: GameInput.cs プロジェクト: Outlaw1123/Trial-Project
    /// <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
    }
コード例 #28
0
        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;
        }
コード例 #29
0
    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;
        }
    }
コード例 #30
0
        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;
                }
            }
        }
コード例 #31
0
        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;
        }
コード例 #32
0
        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);
            }
        }
コード例 #33
0
        void CreateTouch(TouchInformation touchInfo)
        {
            // we don't create any touches if input is disabled.
            if (InputEnabled)
            {

                touches.Add(touchInfo);

                if (TouchStart != null)
                {
                    TouchStart(touchInfo);
                }
            }
        }
コード例 #34
0
        void DestroyTouch(TouchInformation touchInfo)
        {
            if (TouchEnd != null)
            {
                TouchEnd(touchInfo);
            }

            touches.Remove(touchInfo);
        }
コード例 #35
0
 void HandleSwipe(TouchInformation touchInfo)
 {
     if (SwipeEvent != null)
     {
         SwipeEvent(touchInfo);
     }
 }
コード例 #36
0
 void HandleTap(TouchInformation touchInfo)
 {
     if (TapEvent != null)
     {
         TapEvent(touchInfo);
     }
 }
コード例 #37
0
        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);
                    }
                }
            }
        }
コード例 #38
0
        void HandleTouchEnd(TouchInformation touchInfo)
        {
            if(KeyUp == null)
                return;

            foreach(KeyMapping km in keyMappings)
            {
                if(km.touchId == touchInfo.id)
                {
                    KeyUp(km.name);
                }
            }
        }
コード例 #39
0
 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);
         }
     }
 }
コード例 #40
0
        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;
                }
            }
        }