示例#1
0
        // Called every frame
        protected override void InputUpdate()
        {
            if (hudController != null)
            {
                hudController.SetPrompts("PRESS " + enterExitInput.GetInputAsString() + " TO ENTER",
                                         "PRESS " + enterExitInput.GetInputAsString() + " TO EXIT");
            }

            if (vehicleEnterExitManager.EnterableVehicles.Count > 0)
            {
                // Check for input
                if (enterExitInput.Down())
                {
                    Vehicle parent = vehicleEnterExitManager.EnterableVehicles[0].Vehicle;
                    vehicleEnterExitManager.EnterParent(0);
                    gameAgent.EnterVehicle(parent);
                }
            }
            else if (vehicleEnterExitManager.CanExitToChild())
            {
                // Check for input
                if (enterExitInput.Down())
                {
                    Vehicle child = vehicleEnterExitManager.Child.Vehicle;
                    vehicleEnterExitManager.ExitToChild();
                    gameAgent.EnterVehicle(child);
                }
            }
        }
示例#2
0
        protected override void InputUpdate()
        {
            if (hudShipLander != null)
            {
                hudShipLander.SetPrompts("PRESS " + landingInput.GetInputAsString() + " TO LAUNCH", "PRESS " + landingInput.GetInputAsString() + " TO LAND");
            }

            switch (shipLander.CurrentState)
            {
            case (ShipLander.ShipLanderState.Launched):

                if (landingInput.Down())
                {
                    shipLander.Land();
                }

                break;

            case (ShipLander.ShipLanderState.Landed):

                if (landingInput.Down())
                {
                    shipLander.Launch();
                }

                break;
            }
        }
示例#3
0
        protected override void InputUpdate()
        {
            // Cycle forward input
            if (cycleForwardInput.Down())
            {
                Cycle(true);
            }

            // Cycle backward input
            if (cycleBackwardInput.Down())
            {
                Cycle(false);
            }

            // Select modules
            for (int i = 0; i < moduleSelectionInputs.Count; ++i)
            {
                if (moduleSelectionInputs[i].input.Down())
                {
                    for (int j = 0; j < vehicle.ModuleMounts.Count; ++j)
                    {
                        if (vehicle.ModuleMounts[j].ID == moduleMountID)
                        {
                            vehicle.ModuleMounts[j].MountModule(moduleSelectionInputs[i].moduleIndex);
                        }
                    }
                }
            }
        }
示例#4
0
        // Do movement
        protected virtual void MovementUpdate()
        {
            // Forward / backward movement
            translationInputs = spaceVehicleEngines.TranslationThrottleValues;
            if (throttleUpInput.Pressed())
            {
                translationInputs.z += throttleSensitivity.z * Time.deltaTime;
            }
            else if (throttleDownInput.Pressed())
            {
                translationInputs.z -= throttleSensitivity.z * Time.deltaTime;
            }

            // Left / right movement
            translationInputs.x = strafeHorizontalInput.FloatValue();

            // Up / down movement
            translationInputs.y = strafeVerticalInput.FloatValue();

            // Boost
            if (boostInput.Down())
            {
                boostInputs = new Vector3(0f, 0f, 1f);
            }
            else if (boostInput.Up())
            {
                boostInputs = Vector3.zero;
            }
        }
        protected override void InputUpdate()
        {
            // Select next target
            if (nextTargetInput.Down())
            {
                weaponTargetSelector.Cycle(true);
            }

            // Select previous target
            if (previousTargetInput.Down())
            {
                weaponTargetSelector.Cycle(false);
            }

            // Select nearest target
            if (nearestTargetInput.Down())
            {
                weaponTargetSelector.SelectNearest();
            }

            // Select front target
            if (frontTargetInput.Down())
            {
                weaponTargetSelector.SelectFront();
            }
        }
        // Set the control values for the vehicle
        void SetControlValues()
        {
            // Values to be passed to the ship
            float pitch = 0;
            float yaw   = 0;
            float roll  = 0;

            Vector3 flattenedForward = new Vector3(engines.transform.forward.x, 0f, engines.transform.forward.z).normalized;

            Maneuvring.TurnToward(engines.transform, engines.transform.position + flattenedForward, new Vector3(0f, 360f, 0f), shipPIDController.steeringPIDController);

            pitch = shipPIDController.steeringPIDController.GetControlValue(PIDController3D.Axis.X);
            roll  = shipPIDController.steeringPIDController.GetControlValue(PIDController3D.Axis.Z);

            yaw = -yawInput.FloatValue();


            // ************************** Throttle ******************************

            Vector3 nextTranslationInputs = engines.TranslationThrottleValues;

            if (throttleUpInput.Pressed())
            {
                nextTranslationInputs.z += throttleSensitivity.z * Time.deltaTime;
            }
            else if (throttleDownInput.Pressed())
            {
                nextTranslationInputs.z -= throttleSensitivity.z * Time.deltaTime;
            }

            // Left / right movement
            nextTranslationInputs.x = strafeHorizontalInput.FloatValue();

            // Up / down movement
            nextTranslationInputs.y = strafeVerticalInput.FloatValue();
            engines.SetTranslationThrottleValues(nextTranslationInputs);


            if (boostInput.Down())
            {
                engines.SetBoostThrottleValues(new Vector3(0f, 0f, 1f));
            }
            else if (boostInput.Up())
            {
                engines.SetBoostThrottleValues(Vector3.zero);
            }

            engines.SetRotationThrottleValues(new Vector3(pitch, yaw, roll));
        }
示例#7
0
        // Update is called once per frame
        protected override void InputUpdate()
        {
            // Moving
            float horizontal = strafeHorizontalAxisInput.FloatValue();
            float vertical   = walkForwardBackwardAxisInput.FloatValue();

            characterController.SetMovementInputs(horizontal, 0, vertical);

            // Jumping
            if (jumpInput.Down())
            {
                characterController.Jump();
            }

#if !MOBILE_INPUT
            characterController.SetRunning(runInput.Pressed());
#endif
        }
示例#8
0
 // Called every frame if the conditions for the General Input class are satisfied.
 protected override void InputUpdate()
 {
     base.InputUpdate();
     if (openMenuInput.Down())
     {
         // Check the focused game agent exists
         if (GameAgentManager.Instance.FocusedGameAgent != null)
         {
             // Check the focused game agent is in a vehicle
             if (GameAgentManager.Instance.FocusedGameAgent.IsInVehicle)
             {
                 // Check the focused game agent is in a vehicle with a Power component
                 if (GameAgentManager.Instance.FocusedGameAgent.Vehicle.GetComponent <Power>() != null)
                 {
                     // Enter the game state
                     GameStateManager.Instance.EnterGameState(targetGameState);
                 }
             }
         }
     }
 }
示例#9
0
        protected override void InputUpdate()
        {
            if (vehicleCamera != null)
            {
                if (cycleViewForwardInput.Down())
                {
                    vehicleCamera.CycleCameraView(true);
                    if (cameraGimbal != null)
                    {
                        cameraGimbal.ResetGimbal();
                    }
                }
                else if (cycleViewBackwardInput.Down())
                {
                    vehicleCamera.CycleCameraView(false);
                    if (cameraGimbal != null)
                    {
                        cameraGimbal.ResetGimbal();
                    }
                }
            }

            if (vehicleCamera.HasCameraViewTarget && vehicleCamera.SelectedCameraViewTarget.CameraView == VehicleCameraView.Interior)
            {
                if (cameraGimbal != null)
                {
                    if (enableLookAroundInput.Pressed())
                    {
                        // Look around
                        cameraGimbal.Rotate(new Vector2(cameraGimbalRotationSpeed * horizontalRotationAxisInput.FloatValue(),
                                                        cameraGimbalRotationSpeed * -verticalRotationAxisInput.FloatValue()));
                    }

                    if (enableLookAroundInput.Up())
                    {
                        cameraGimbal.ResetGimbal();
                    }
                }
            }
        }
示例#10
0
        protected override void InputUpdate()
        {
            // Cycle camera view
            if (cameraEntity != null)
            {
                if (cycleViewForwardInput.Down())
                {
                    cameraEntity.CycleCameraView(true);
                }
                else if (cycleViewBackwardInput.Down())
                {
                    cameraEntity.CycleCameraView(false);
                }
            }

            // Select camera view
            for (int i = 0; i < cameraViewInputs.Count; ++i)
            {
                if (cameraViewInputs[i].input.Down())
                {
                    cameraEntity.SetView(cameraViewInputs[i].view);
                }
            }

            // Free look mode
            if (cameraGimbalController != null)
            {
                if (freeLookModeInput.Pressed())
                {
                    cameraGimbalController.Rotate(lookHorizontalInput.FloatValue() * freeLookSpeed,
                                                  -lookVerticalInput.FloatValue() * freeLookSpeed);
                }
                else if (freeLookModeInput.Up())
                {
                    cameraGimbalController.ResetGimbal(true);
                }
            }
        }
示例#11
0
        public virtual void ProcessEvents()
        {
            switch (customInput.inputType)
            {
            case CustomInputType.Axis:

                onInputAxis.Invoke(customInput.FloatValue());

                break;

            default:

                if (customInput.Down())
                {
                    onInputDown.Invoke();
                }
                if (customInput.Up())
                {
                    onInputUp.Invoke();
                }
                break;
            }
        }