void FixedUpdate()
    {
        float         dt     = Time.fixedDeltaTime;
        Transform     camera = Camera.main.transform;
        CharacterMove mover  = GetComponent <CharacterMove>();

        mover.SetFaceAimRotation(Input.GetButton("Fire1") || Input.GetButton("Fire2"));
        mover.SetAimRotation(camera.rotation);
        mover.SetMoveDirection(new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")));
        if (Input.GetButton("Jump"))
        {
            mover.Jump();
        }
        mover.DoMove();

        camVel              = (camVel + new Vector3(-Input.GetAxis("Mouse Y") * 50f * dt, Input.GetAxis("Mouse X") * 50f * dt, 0f)) * 0.8f;
        camera.eulerAngles += camVel;
        float camx = camera.eulerAngles.x;

        if (camx < 180f)
        {
            camx = Mathf.Min(camx, 60f);
        }
        else
        {
            camx = Mathf.Max(camx, 300f);
        }

        camera.eulerAngles = new Vector3(camx, camera.eulerAngles.y, camera.eulerAngles.z);
        camera.position    = Vector3.Lerp(camera.position, transform.position + new Vector3(0f, 3f, 0f) - camera.rotation * Vector3.forward * 6f, 0.5f);
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (turningpoint == 0)
        {
            isTurn = false;
        }

        if (ObjEat.Invincible)
        {
            ThisTurn = GetWhichTurnInUI();
            SwipeToTurn();
        }
        // 일시정지이거나 클리어 했을 경우 터치 안되게 조절
        if (!UIManager.isPause && !CharacterAnimation.Win)
        {
            CanMove = !ObjEat.unityChanDie && !ObjEat.HitInvincible && !ObjEat.Invincible;
            if (Input.GetMouseButtonDown(0))
            {
                //if (Input.mousePosition.y > (height / 2.5))
                //마우스 클릭시 포지션 저장
                ButtonDownMousePos = Input.mousePosition;
                TapCount           = 1;
            }
            // 마우스 클릭 유지시
            if (Input.GetMouseButton(0))
            {
                MousePosX = Input.mousePosition.x;
                MousePosY = Input.mousePosition.y;
                ////하단 부분 클릭 했을 경우
                //if (TapCount == 0 && CanMove) { if (MousePosY < (height / 2.5)) {
                //        //좌측으로 이동
                //        if (MousePosX < (width / 2)) { cMove.turningPoint = false; cMove.Move(true); }
                //        //우측으로 이동
                //        else { cMove.turningPoint = false; cMove.Move(false); } }
                //}
            }
            //마우스 클릭 종료시
            else if (Input.GetMouseButtonUp(0))
            {
                if (TapCount == 1 && CanMove)
                {
                    float MoveXLength = ButtonDownMousePos.x - MousePosX;
                    float MoveYLength = ButtonDownMousePos.y - MousePosY;

                    //위로 스와이프
                    if (-MoveYLength > (height / 10))
                    {
                        cMove.Jump();
                    }
                    //아래로 스와이프
                    else if (MoveYLength > (height / 10))
                    {
                        cMove.SlideDown();
                    }

                    //좌로 스와이프
                    if (MoveXLength > (width / 5))
                    {
                        ThisTurn = E_WhichTurn.LEFT;
                        SwipeToTurn();
                    }
                    //우로 스와이프
                    else if (-MoveXLength > (width / 5))
                    {
                        ThisTurn = E_WhichTurn.RIGHT;
                        SwipeToTurn();
                    }

                    TapCount = 0;
                }
            }
        }
    }