Exemple #1
0
    // Update is called once per frame
    public override void GameUpdate()
    {
        float horizontalMovement;
        float verticalMovement;

        // Do mouse input or use joystick
        // not both
        if (Input.GetMouseButton(2))
        {
            horizontalMovement = Input.GetAxis("Mouse X") * -1;
            verticalMovement   = Input.GetAxis("Mouse Y") * -1;
        }
        else
        {
            horizontalMovement = Input.GetAxis("Horizontal");
            verticalMovement   = Input.GetAxis("Vertical");
        }

        if (Input.GetAxis("Mouse ScrollWheel") != 0)
        {
            var zoomMovement = Input.GetAxis("Mouse ScrollWheel") > 0
                                    ? ScrollSensitivity * Time.deltaTime
                                        : ScrollSensitivity * Time.deltaTime * -1;
            if (ZoomController.Zoom < MaxZoom &&
                ZoomController.Zoom > MinZoom)
            {
                ZoomController.SetCameraZoom(ZoomController.Zoom + zoomMovement);
            }
        }

        transform.Translate(horizontalMovement, verticalMovement, 0);
    }