Ejemplo n.º 1
0
    void FixedUpdate()
    {
        cam.transform.position = offset;
        cam.transform.rotation = Quaternion.Euler(rotation);
        HandleCamMovement();

        if (!manager.getPlayerEnum().Equals(PlayerStatEnum.PAUSED))
        {
            transform.position = move.moveDirection_z(transform.position);
            if (move.getMotion())
            {
                transform.position = move.moveToFinalPosition(transform.position);
            }

            if (Input.GetKey("a") || Input.GetKey("d"))
            {
                float dirct = Input.GetAxisRaw("Horizontal");
                move.firstMotion(transform.position, (dirct * floorTransform.localScale.x));
            }
            else if (Input.GetKey(KeyCode.Space) && transform.position.y <= 1)
            {
                rb.velocity = (new Vector3(0, 6, 0));
            }
            else if (Input.touchCount > 0)
            {
                Touch touch = Input.touches[0];
                if (touch.phase.Equals(TouchPhase.Began) && !blocked)
                {
                    blocked    = true;
                    startPoint = touch.position;
                }
                else if (touch.phase.Equals(TouchPhase.Ended) && blocked)
                {
                    blocked  = true;
                    endPoint = touch.position;
                    //directionRaw = touch.position - startPoint;
                    Vector2 test = JoyStick.CalculateInput(startPoint, endPoint);
                    //float temp = directionRaw.x / Mathf.Abs(directionRaw.x);
                    move.firstMotion(transform.position, (test.x * floorTransform.localScale.x));
                    Debug.Log(test);
                    rb.velocity = (new Vector3(0, test.y * 6, 0));
                }
            }
        }
        else
        {
            manager.playerEnum = PlayerStatEnum.DEAD;
        }
    }