Example #1
0
    private void Update()
    {
        CurrentAimPosition = GetCurrentAimPosition();

        if (Input.GetKeyDown(InputManager.PauseGameKey) && canPause)
        {
            GameStateUtils.TogglePause();
            return;
        }

        if (!inputAllowed || ship == null)
        {
            return;
        }

        #region movement
        if (Input.GetKey(InputManager.ThrottleUpKey) || Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            ship.engine.ThrottleUp();
        }

        else if (Input.GetKeyUp(InputManager.ThrottleUpKey))
        {
            Action <bool> action = ship.engine.Blink;
            StartCoroutine(DoubleTap(InputManager.ThrottleUpKey, action, true));
        }

        if (Input.GetKey(InputManager.ThrottleDownKey) || Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            ship.engine.ThrottleDown();
        }

        if (Input.GetKey(InputManager.StrafeLeftKey))
        {
            ship.engine.Strafe = -1;
        }
        else if (Input.GetKeyUp(InputManager.StrafeLeftKey))
        {
            Action action = ship.engine.SidestepLeft;
            StartCoroutine(DoubleTap(InputManager.StrafeLeftKey, action));
        }

        if (Input.GetKey(InputManager.StrafeRightKey))
        {
            ship.engine.Strafe = 1;
        }
        else if (Input.GetKeyUp(InputManager.StrafeRightKey))
        {
            Action action = ship.engine.SidestepRight;
            StartCoroutine(DoubleTap(InputManager.StrafeRightKey, action));
        }

        // If neither strafe key is pressed, reset the ship's strafing
        if (!Input.GetKey(InputManager.StrafeRightKey) && !Input.GetKey(InputManager.StrafeLeftKey))
        {
            ship.engine.Strafe = 0;
        }

        if (Input.GetKeyDown(InputManager.ToggleMouseFlightKey))
        {
            ToggleMouseFlight();
        }

        if (Input.GetKeyDown(InputManager.AfterburnerKey))
        {
            ship.ToggleAfterburner(true);
        }

        else if (Input.GetKeyUp(InputManager.AfterburnerKey))
        {
            ship.ToggleAfterburner(false);
        }

        if (Input.GetKeyDown(InputManager.ManualMouseFlightKey))
        {
            if (MouseState == MouseState.Off)
            {
                StartCoroutine("ManualMouseFlightCoroutine");
            }
        }

        if (Input.GetKeyUp(InputManager.ManualMouseFlightKey))
        {
            StopAllCoroutines();

            if (MouseState == MouseState.Held)
            {
                MouseState = MouseState.Off;
            }
        }

        if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(InputManager.ThrottleUpKey))
        {
            ship.cruiseEngine.ToggleCruiseEngines();
        }

        if (Input.GetKeyDown(InputManager.KillEnginesKey))
        {
            ship.engine.Drifting = !ship.engine.Drifting;
        }

        #endregion

        #region hardpoints
        if (Input.GetKey(InputManager.Hardpoint1Key))
        {
            ship.guns[0].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint2Key))
        {
            ship.guns[1].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint3Key))
        {
            ship.guns[2].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint4Key))
        {
            ship.guns[3].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint5Key))
        {
            ship.guns[4].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint6Key))
        {
            ship.guns[5].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint7Key))
        {
            ship.guns[6].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint8Key))
        {
            ship.guns[7].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint9Key))
        {
            ship.guns[8].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.Hardpoint10Key))
        {
            ship.guns[9].Fire(CurrentAimPosition);
        }

        if (Input.GetKey(InputManager.FireKey))
        {
            ship.FireActiveWeapons(CurrentAimPosition);
        }

        #endregion
    }
Example #2
0
 static void Pause(CommandArg[] args)
 {
     GameStateUtils.TogglePause();
 }