예제 #1
0
        private static void Update()
        {
            RaycastHit hit;

            if (TouchConst.TouchBegin())
            {
                TouchConst.times = DateTime.Now;
                mRay             = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (IsAllow(out hit))
                {
                    mClickName = hit.collider.name;
                }
            }
            if (TouchConst.TouchEnd())
            {
                if (IsAllow(out hit))
                {
                    if (hit.collider.name.Contains(mClickName))
                    {
                        mClickName = string.Empty;
                        Debug.Log(hit.point);
                    }
                }
            }
            else if (TouchConst.TouchIng())
            {
            }
            else if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
            {
            }
        }
예제 #2
0
        // Update is called once per frame
        private void TouchUpdate()
        {
            if (TouchConst.TouchEnd())
            {
                RaycastHit hit;
                Ray        ray = mCamera.ScreenPointToRay(TouchConst.TouchPosition());
                Debug.DrawLine(ray.origin, mTrans.position, Color.red, 2);
                if (Physics.Raycast(ray, out hit))//射线发出并碰撞到外壳,那么手臂就应该朝向碰撞点
                {
                    GameObject gameObject = hit.collider.gameObject;
                    Debug.DrawLine(ray.origin, new Vector3(Input.mousePosition.x, Input.mousePosition.y, 100), Color.red, 2);
                    DispatchTouchEvent(gameObject.transform);
                }

                /**
                 * RaycastHit objhit;
                 * //Ray ray = _uiCamera.ScreenPointToRay(Input.mousePosition);
                 * Vector3 originPos = mTrans.position;
                 * originPos.z -= 1;
                 * Ray ray = new Ray(originPos, Vector3.forward);
                 * Debug.DrawLine(ray.origin, Vector3.forward, Color.red, 2);
                 * if (Physics.Raycast(ray, out objhit) == true)
                 * {
                 *  GameObject gameObject = objhit.collider.gameObject;
                 *  Debug.DrawLine(ray.origin, new Vector3(Input.mousePosition.x, Input.mousePosition.y, 100), Color.red, 2);
                 *  DispatchTouchEvent(gameObject.transform);
                 * }
                 */
            }
        }
예제 #3
0
        private void OnUpate()
        {
            if (!mLArea)
            {
                return;
            }
            if (!mAreaBg)
            {
                return;
            }
            if (!mCircle)
            {
                return;
            }
            Vector2 inputPos = TouchConst.TouchPosition();

            if (!mIsClickArea && TouchConst.TouchBegin())
            {
                if (inputPos.x >= 0 && inputPos.x < Offset.x * 2 && inputPos.y > 0 && inputPos.y < Offset.y * 2)
                {
                    mIsClickArea = true;
                }
            }
            if (!mIsClickArea)
            {
                return;
            }
            if (TouchConst.TouchIng())
            {
                KeyboardControl.IsRestrict = true;
                if (!mLArea.gameObject.activeSelf)
                {
                    mLArea.gameObject.SetActive(true);
                }
                UpdateAreaBgPos(inputPos);
                UpdateCirclePos(inputPos);
                //UnitMgr.Instance.SetPlayerMove(true);
                //if (mPlayer != null)
                //    RemoteControl.Instance.ExecuteMove(mPlayer.CTemp.id);
            }
            else if (TouchConst.TouchEnd())
            {
                //if(mPlayer != null)
                //    RemoteControl.Instance.UndoMove(mPlayer.CTemp.id);
                //UnitMgr.Instance.SetPlayerMove(false);
                mIsFixedPos  = false;
                mIsClickArea = false;
                if (mLArea.gameObject.activeSelf)
                {
                    mLArea.gameObject.SetActive(false);
                }
                KeyboardControl.IsRestrict = false;
            }
        }