示例#1
0
        private void Turn(TurnSide turnSide)
        {
            if (IsActive && _isAlive)
            {
                if (turnSide == TurnSide.Left)
                {
                    _turnSpread = Mathf.Lerp(0, _turnRatio * -1, Time.deltaTime * _turnSpeed);
                    //transform.rotation = new Quaternion(transform.rotation.x, Mathf.Lerp(transform.rotation.y, transform.rotation.y - _turnRatio*5, Time.deltaTime / _turnSpeed), transform.rotation.z, transform.rotation.w);
                }

                if (turnSide == TurnSide.Right)
                {
                    _turnSpread = Mathf.Lerp(0, _turnRatio, Time.deltaTime / _turnSpeed);
                    //transform.rotation = new Quaternion(transform.rotation.x, Mathf.Lerp(transform.rotation.y, transform.rotation.y + _turnRatio*5, Time.deltaTime / _turnSpeed), transform.rotation.z, transform.rotation.w);
                }

                if (turnSide == TurnSide.Center)
                {
                    transform.rotation = _initialRotation;
                    //_turnSpread = 0;
                }
            }

            //print("I'm turning to the " + turnSide + " and my pos is " + transform.position);
        }
示例#2
0
    void Update()
    {
        if (!takeInput)
        {
            return;
        }

        if (Input.GetKey(KeyCode.K) || isLeftButtonHeld)
        {
            turnSide = TurnSide.left;
        }
        else if (Input.GetKey(KeyCode.L) || isRightButtonHeld)
        {
            turnSide = TurnSide.right;
        }
        else
        {
            turnSide = TurnSide.none;
        }



        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            startMousePosition = Input.mousePosition;
        }

        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            if (Vector2.Distance(startMousePosition, Input.mousePosition) < 10)
            {
                doubleTap = true;
            }
        }

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            doubleTap = true;
        }

        if (Input.touchCount > 0 && Input.GetTouch(0).tapCount > 1)
        {
            doubleTap = true;
        }

        // to generate new
        if (Time.timeSinceLevelLoad - lastThrowTime > 0.3f && (doubleTap))
        {
            doubleTap     = false;
            lastThrowTime = Time.timeSinceLevelLoad;
            attackScript.Shoot();
        }

        // to slide or roll the player
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            RollPlayer();
        }    //...................................

        // to Jump the player
        SpaceBar_Pressed();
        //.................................
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            playerScript.RightSideMoving();
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            playerScript.LeftSideMoving();
        }

        // for Swipe Control ..........................

        if (Input.GetKeyDown(KeyCode.Mouse0) && touchCount == 0)
        {
            swipe_Initial_X = Input.mousePosition.x;
            swipe_Initial_Y = Input.mousePosition.y;

            touchCount = 1;
        }
        if (touchCount == 1)
        {
            swipe_Final_X = Input.mousePosition.x;
            swipe_Final_Y = Input.mousePosition.y;
        }
        swipeDirection();

        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            touchCount = 0;
        }
        //.........................................
    }