Ejemplo n.º 1
0
    private void HandleFreeMode(ref IExtendedHeroesController inputs)
    {
        // Camera Movement Sticks
        _heroesController.MoveForward(inputs.LeftStickY * -1);
        _heroesController.MoveLeft(inputs.LeftStickX * -1);

        // Camera Rotation Sticks
        var vector = new Vector3(inputs.RightStickX * -1, inputs.RightStickY * -1, 0);

        _heroesController.Rotate(vector);

        // Camera Roll Triggers
        // Note: The game sets Camera L/R button flags if the pressure is above 0.
        // We disallow bumpers if rotating with triggers.
        if (inputs.LeftTriggerPressure > 0)
        {
            _heroesController.Rotate(new Vector3(0, 0, inputs.LeftTriggerPressure / (float)byte.MaxValue));
        }
        else
        {
            // Lift Camera Down (LB)
            if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.CameraL))
            {
                _heroesController.MoveUp(-1F);
            }
        }

        if (inputs.RightTriggerPressure > 0)
        {
            _heroesController.Rotate(new Vector3(0, 0, (inputs.RightTriggerPressure / (float)byte.MaxValue) * -1F));
        }
        else
        {
            // Lift Camera Up (RB)
            if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.CameraR))
            {
                _heroesController.MoveUp(1F);
            }
        }

        // Modify Move Speed (DPAD UD)
        if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.DpadUp))
        {
            _heroesController.MoveSpeed += (_heroesController.MoveSpeed * 0.011619440F); // Calculated using Geometric Progression; Approx 1 second for 2x increase.
        }
        if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.DpadDown))
        {
            _heroesController.MoveSpeed -= (_heroesController.MoveSpeed * 0.011619440F); // Calculated using Geometric Progression; Approx 1 second for 2x increase.
        }
        // Modify Rotate Speed (DPAD LR)
        if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.DpadRight))
        {
            _heroesController.RotateSpeed += (_heroesController.RotateSpeed * 0.011619440F);
        }

        if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.DpadLeft))
        {
            _heroesController.RotateSpeed -= (_heroesController.RotateSpeed * 0.011619440F);
        }

        // Ignore if modifier key is held.
        if (!ButtonPressed(inputs.ButtonFlags, ButtonFlags.TeamBlast))
        {
            // Toggle HUD (B)
            if (ButtonPressed(inputs.OneFramePressButtonFlag, ButtonFlags.FormationR))
            {
                _heroesController.EnableHud = !_heroesController.EnableHud;
            }

            // Teleport Character (A)
            if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.Jump))
            {
                _heroesController.TeleportCharacterToCamera();
            }
        }

        // Reset Camera (X)
        if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.Action))
        {
            _heroesController.ResetCamera();
        }

        // Reset Roll (Y)
        if (ButtonPressed(inputs.ButtonFlags, ButtonFlags.FormationL))
        {
            _heroesController.ResetCameraRoll();
        }
    }