コード例 #1
0
ファイル: BaseTouchItem.cs プロジェクト: jonntd/Xbl
        protected virtual void TouchEvent()
        {
            if (_CanTouch && TouchManager.Instance.IsTouchValid(0))
            {
                TouchPhaseEnum touchPhase = TouchManager.Instance.GetTouchPhase(0);
                if (touchPhase == TouchPhaseEnum.BEGAN)
                {
                    TouchManager.Instance.GetTouchPos(0, out _StartTouchpos);
                    RaycastHit hit;
                    C_DebugHelper.Log("TouchManager begin..");

                    Ray ray = GetCurrentCamera().ScreenPointToRay(_StartTouchpos);
                    if (Physics.Raycast(ray, out hit, _TouchDistance))
                    {
                        C_DebugHelper.Log("book is touch" + hit.collider.name);

                        if (hit.collider.gameObject == gameObject)
                        {
                            C_DebugHelper.Log("book is touch in:" + hit.collider.name);
                            //播放动画
                            _IsTouch = true;
                            TouchHandle();
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: TouchManager.cs プロジェクト: tornadory/ARFight
    /// <summary>
    /// Gets the touch phase.
    /// </summary>
    /// <returns>
    /// The touch phase.
    /// </returns>
    /// <param name='id'>
    /// Touch id.
    /// </param>
    /// <param name='phase'>
    /// Set to the touch phase.
    /// </param>
    public static bool GetTouchPhase(int id, out TouchPhaseEnum phase)
    {
        phase = TouchPhaseEnum.CANCELED;

        bool retVal = IsTouchValid(id);

        if (retVal == true)
        {
            phase = touchCache[id].phase;
        }

        return(retVal);
    }
コード例 #3
0
ファイル: TouchManager.cs プロジェクト: xdegtyarev/ld23
    /// <summary>
    /// Gets the touch phase.
    /// </summary>
    /// <returns>
    /// The touch phase.
    /// </returns>
    /// <param name='id'>
    /// Touch id.
    /// </param>
    /// <param name='phase'>
    /// Set to the touch phase.
    /// </param>
    public static bool GetTouchPhase(int id, out TouchPhaseEnum phase)
    {
        phase = TouchPhaseEnum.CANCELED;

        bool retVal = IsTouchValid(id);

        //    Debug.Log("GetTouchPhase: id=" + id +"  IsTouchValid(id)=" + retVal);

        if (retVal == true)
        {
            phase = touchCache[id].phase;
        }

        return(retVal);
    }
コード例 #4
0
ファイル: WindowSliderControl.cs プロジェクト: jonntd/Xbl
 public void UpdateRotate()
 {
     if (TouchManager.Instance.IsTouchValid(0))
     {
         TouchPhaseEnum phase = (TouchPhaseEnum)TouchManager.Instance.GetTouchPhase(0);
         if (phase == TouchPhaseEnum.BEGAN)
         {
             TouchManager.Instance.GetTouchPos(0, out startTouchpos);
         }
         else if (phase == TouchPhaseEnum.MOVED)
         {
             NormalRotate();
         }
         else if (phase == TouchPhaseEnum.ENDED)
         {
             AutoRotateBack();
         }
     }
 }
コード例 #5
0
        public bool GetFingerMoving()
        {
            if (Application.isEditor)
            {
                Vector2        pos;
                TouchPhaseEnum touch = GetTouchPhase(0);
                if (touch == TouchPhaseEnum.MOVED)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (Input.touches.Length > 2)
                {
                    return(false);
                }
                else
                {
                    movingCount = 0;
                    for (int i = 0; i < Input.touches.Length; i++)
                    {
                        if (Input.touches[i].phase == TouchPhase.Moved)
                        {
                            movingCount++;
                        }
                    }

                    if (movingCount > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
コード例 #6
0
ファイル: TouchManager.cs プロジェクト: verneh/ARFight
    /// <summary>
    /// Gets the touch phase.
    /// </summary>
    /// <returns>
    /// The touch phase.
    /// </returns>
    /// <param name='id'>
    /// Touch id.
    /// </param>
    /// <param name='phase'>
    /// Set to the touch phase.
    /// </param>
    public static bool GetTouchPhase(int id, out TouchPhaseEnum phase)
    {
        phase = TouchPhaseEnum.CANCELED;

        bool retVal = IsTouchValid(id);

        if (retVal == true)
        {
            phase = touchCache[id].phase;
        }

        return retVal;
    }
コード例 #7
0
ファイル: WindowSliderControl.cs プロジェクト: jonntd/Xbl
    /// <summary>
    /// 检测相机移动
    /// </summary>
    void Update_DetectCameraMove()
    {
        Vector2 deltaPos = Vector2.zero;

        if (_Camera == null)
        {
            return;
        }
        if (TouchManager.Instance.IsTouchValid(0))
        {
            TouchPhaseEnum phase = (TouchPhaseEnum)TouchManager.Instance.GetTouchPhase(0);
            if (phase == TouchPhaseEnum.BEGAN)
            {
                ReInit();
                TouchManager.Instance.GetTouchPos(0, out startTouchpos);
                startTime            = Time.realtimeSinceStartup;
                isTouchingMoveCamera = true;
                overTween.Pause();
                if (_Camera.transform.position.x <= -16f)
                {
                    isBoundaryRight = true;
                }
                else if (_Camera.transform.position.x >= 16f)
                {
                    isBoundaryLeft = true;
                }
                else
                {
                    isBoundaryRight = false;
                    isBoundaryLeft  = false;
                }
            }
            else if (phase == TouchPhaseEnum.MOVED)
            {
                TouchManager.Instance.GetTouchDeltaPos(0, out movingTouchpos);
                if (isBoundaryRight)
                {
                    if (movingTouchpos.x < 0)
                    {
                        wdBundary.MoveBoundaryRight();
                    }
                    else
                    {
                        NormalMove();
                    }
                }
                else if (isBoundaryLeft)
                {
                    if (movingTouchpos.x > 0)
                    {
                        wdBundary.MoveBoundaryLeft();
                    }
                    else
                    {
                        NormalMove();
                    }
                }
                else
                {
                    NormalMove();
                }
            }

            else if (phase == TouchPhaseEnum.ENDED)
            {
                endTime = Time.realtimeSinceStartup;
                isTouchingMoveCamera = false;
                getInitPos           = false;
                if (Mathf.Abs(_Camera.transform.position.x) > 16)
                {
                    wdBundary.AutoBack();
                }
                else
                {
                    BufferMove();
                }
            }
        }
    }