Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Temp_OBJ != null && NewOBJ)
        {
//            float a = CRLuo.mainMeshRender.renderer.bounds.center.y
//                + CRLuo.mainMeshRender.renderer.bounds.extents.y + CRLuo.OneShow_Height;

            CameraOBJ.transform.localPosition = new Vector3(CRLuo.ScaleplateOffset.x, CRLuo.mainMeshRender.renderer.bounds.center.y + CRLuo.ScaleplateOffset.y, cameraPosz + CRLuo.ScaleplateOffset.z);
//            a = a * Screen.height / Screen.width + CameraAdd;
//			float b = Mathf.Abs( CameraOBJ.transform.localPosition.z);
//
//			float TempFOV = (Mathf.Atan (a / b) * 180 / Mathf.PI * 2);
//			CameraOBJ.fieldOfView = TempFOV;
            NewOBJ = false;
        }

        if (Input.GetMouseButtonDown(0))
        {
            MiniItween.DeleteType(StageOBJ, MiniItween.Type.Rotate);

            Touch_O = Input.mousePosition;

            NowRotation = StageOBJ.transform.rotation.eulerAngles;

            if (Temp_OBJ != null)
            {
                if (CRLuo.GetCurAnim() == "Idle")
                {
                    if (AW.Utils.UnityUtils.inScreenRect(CRLuo.mainMeshRender, CameraOBJ, Input.mousePosition))
                    {
                        lastBtnDown = Time.realtimeSinceStartup;
                        playAnim();
                    }
                }
            }
        }
        else if (Input.GetMouseButton(0))
        {
            MiniItween.DeleteType(StageOBJ, MiniItween.Type.Rotate);

            Vector2 NewPos = Input.mousePosition;

            float NowLong = NewPos.x - Touch_O.x;

            NowLong *= RotSheepScale;

            StageOBJ.transform.rotation = Quaternion.Euler(new Vector3(0, NowRotation.y - NowLong, 0));
        }

        if ((Time.realtimeSinceStartup - lastBtnDown) >= AUTO_TIME)
        {
            lastBtnDown = Time.realtimeSinceStartup;
            playAnim();
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (OpenTouch)
        {
            Now_Pos_V3 = this.gameObject.transform.localRotation.eulerAngles;
            if (Now_Pos_V3.z - Default_Rot.z < -L_Max || Now_Pos_V3.z - Default_Rot.z > R_Max || Now_Pos_V3.x - Default_Rot.x < -U_Max || Now_Pos_V3.x - Default_Rot.x > D_Max)
            {
                OpenTouch  = false;
                TouchInput = false;
                Return_Rot();
                Invoke("Touch_OK", BakeTime);
                return;
            }

            if (Input.GetMouseButtonDown(0))
            {
                TouchInput = true;

                //结束旋转任务
                MiniItween.DeleteType(this.gameObject, MiniItween.Type.Rotate);

                Old_Pos_V2 = Input.mousePosition;
                Old_Pos_V3 = this.gameObject.transform.localRotation.eulerAngles;
            }
            else if (Input.GetMouseButton(0) && TouchInput)
            {
                Vector2 tempMousePos = Input.mousePosition;
                //if (tempMousePos != New_Pos_V2)
                //{
                Vector3 Temp_Rot = Vector3.zero;
                Temp_Rot.x = (tempMousePos.y - Old_Pos_V2.y) * Time.deltaTime * MoveSpeed + Old_Pos_V3.x;
                Temp_Rot.y = 0;
                Temp_Rot.z = -(tempMousePos.x - Old_Pos_V2.x) * Time.deltaTime * MoveSpeed + Old_Pos_V3.z;

                this.gameObject.transform.localRotation = Quaternion.Euler(Temp_Rot);
                //}
            }
            else if (Input.GetMouseButtonUp(0))
            {
                TouchInput = true;
            }
        }
    }
Exemplo n.º 3
0
    void Return_Rot()
    {
        Vector3 Go_pos;

        if (Now_Pos_V3.z - Default_Rot.z < -L_Max)
        {
            Go_pos    = Now_Pos_V3;
            Go_pos.z += BakeDistance;
            //结束旋转任务
            MiniItween.DeleteType(this.gameObject, MiniItween.Type.Rotate);
            MiniItween.RotateTo(this.gameObject, Go_pos, BakeTime, MiniItween.EasingType.EaseInOutCubic);
        }
        else if (Now_Pos_V3.z - Default_Rot.z > R_Max)
        {
            Go_pos    = Now_Pos_V3;
            Go_pos.z -= BakeDistance;
            //结束旋转任务
            MiniItween.DeleteType(this.gameObject, MiniItween.Type.Rotate);
            MiniItween.RotateTo(this.gameObject, Go_pos, BakeTime, MiniItween.EasingType.EaseInOutCubic);
        }
        else if (Now_Pos_V3.x - Default_Rot.x < -U_Max)
        {
            Go_pos    = Now_Pos_V3;
            Go_pos.x += BakeDistance;
            //结束旋转任务
            MiniItween.DeleteType(this.gameObject, MiniItween.Type.Rotate);
            MiniItween.RotateTo(this.gameObject, Go_pos, BakeTime, MiniItween.EasingType.EaseInOutCubic);
        }
        else if (Now_Pos_V3.x - Default_Rot.x > D_Max)
        {
            Go_pos    = Now_Pos_V3;
            Go_pos.x -= BakeDistance;
            //结束旋转任务
            MiniItween.DeleteType(this.gameObject, MiniItween.Type.Rotate);
            MiniItween.RotateTo(this.gameObject, Go_pos, BakeTime, MiniItween.EasingType.EaseInOutCubic);
        }
    }
Exemplo n.º 4
0
    private void SingleTouch()
    {
        //single touch
        if (Input.GetMouseButtonDown(0))
        {
            isTouchEnd = false;
            //RaycastHit hit;
            hitted = UICamera.Raycast(Input.mousePosition);
            if (hitted)
            {
                return;
            }

            if (TouchState != null)
            {
                TouchState(AllenTouchState.Donw);
            }

            clearAutoStatus();
            MiniItween.DeleteType(gameObject, MiniItween.Type.Rotate);
            Touch_O = Input.mousePosition;
            //NowRotation = transform.rotation.eulerAngles;
            Touch_Old = GetWorldPos(Touch_O);
        }
        else if (Input.GetMouseButton(0))
        {
            if (hitted)
            {
                return;
            }

            if (TouchState != null)
            {
                TouchState(AllenTouchState.Continue);
            }

            MiniItween.DeleteType(gameObject, MiniItween.Type.Rotate);
            Vector3 NewPos = Input.mousePosition;
            NewPos = GetWorldPos(NewPos);


            float differenceX = NewPos.x - Touch_Old.x;
            float differenceY = NewPos.y - Touch_Old.y;

            float targetX = transform.localRotation.eulerAngles.x;
            float targetZ = transform.localRotation.eulerAngles.z;


            targetZ += -differenceX * 6.0f;
            targetX += differenceY * 6.0f;

            //if(differenceX == 0) return;

            TouchFrameCount++;
            Distance.x += Mathf.Abs(differenceX);
            Distance.y += Mathf.Abs(differenceY);

            MoveDir.x = differenceX > 0 ? -1:1;
            MoveDir.y = differenceY > 0 ? 1:-1;

            if (targetX < MIN_X)
            {
                targetX = MIN_X;
            }
            if (targetX > MAX_X)
            {
                targetX = MAX_X;
            }
            if (targetZ < MIN_Z)
            {
                targetZ = MIN_Z;
            }
            if (targetZ > MAX_Z)
            {
                targetZ = MAX_Z;
            }

            transform.rotation = Quaternion.Euler(new Vector3(targetX, 0, targetZ));

            Touch_Old = NewPos;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (TouchState != null)
            {
                TouchState(AllenTouchState.Up);
            }
            if (TouchFrameCount > 0)
            {
                Speed.x = Distance.x / (float)TouchFrameCount;
                Speed.y = Distance.y / (float)TouchFrameCount;
                //isTouchEnd = true;
            }
            else
            {
                Speed = Vector2.zero;
            }

            TouchFrameCount = 0;
            Distance        = Vector2.zero;
//            hitted = false;
//            Auto = true;

//            if( SwipToMin() )
//			{
//				NGUIDebug.Log(" I CAN MOVE IT!!!!");
            isTouchEnd = true;
            //}
        }
    }
Exemplo n.º 5
0
    private void SingleTouch()
    {
        if (Input.GetMouseButtonDown(0))
        {
            isTouchEnd = false;
            RaycastHit hit;
            hitted = UICamera.Raycast(Input.mousePosition);
            if (hitted)
            {
                return;
            }

            if (TouchState != null)
            {
                TouchState(AllenTouchState.Donw);
            }

            MiniItween.DeleteType(gameObject, MiniItween.Type.Rotate);
            Touch_O   = Input.mousePosition;
            Touch_Old = GetWorldPos(Touch_O);
        }
        else if (Input.GetMouseButton(0))
        {
            if (hitted)
            {
                return;
            }

            if (TouchState != null)
            {
                TouchState(AllenTouchState.Continue);
            }

            MiniItween.DeleteType(gameObject, MiniItween.Type.Rotate);
            Vector3 NewPos = Input.mousePosition;
            NewPos = GetWorldPos(NewPos);


            float differenceX = NewPos.x - Touch_Old.x;

//            float targetX = transform.localRotation.eulerAngles.x;
//            float targetZ = transform.localRotation.eulerAngles.z;
            Vector3 movepos = transform.localPosition;

            movepos.x += differenceX * 6.0f;


            TouchFrameCount++;
            Distance.x += Mathf.Abs(differenceX);


            MoveDir.x = differenceX > 0 ? -1:1;

            if (movepos.x > MIN_Z)
            {
                movepos.x = MIN_Z;
            }
            else if (movepos.x < MAX_Z)
            {
                movepos.x = MAX_Z;
            }
            //Debug.LogError(movepos.x.ToString());
            //transform.rotation = Quaternion.Euler(new Vector3(targetX, 0, targetZ ));
            transform.localPosition = movepos;

            Touch_Old = NewPos;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (TouchState != null)
            {
                TouchState(AllenTouchState.Up);
            }
            if (TouchFrameCount > 0)
            {
                Speed.x = Distance.x / (float)TouchFrameCount;
            }
            else
            {
                Speed = Vector2.zero;
            }

            TouchFrameCount = 0;
            Distance        = Vector2.zero;

            isTouchEnd = true;
        }
    }