private void Update() { if (m_autoDetectControlsMode) { if (Input.GetJoystickNames().Length > 0 && Input.GetJoystickNames()[0].Contains("Controller")) { controlsMode = ControlsMode.Controller; } else { controlsMode = ControlsMode.KeyboardMouse; } } if (Time.timeScale < float.Epsilon) { return; } if (m_character.CanMove() && m_shootPeanuts && Input.GetButtonDown("Shoot")) { m_shootPeanuts.Fire(); } if (Input.GetButtonDown("Interact") && CanInteract()) { m_interactor.InteractionRequest(); } }
public static IEnumerator BlockInput(ControlsMode original) { controlsMode = ControlsMode.Disabled; yield return(new WaitForSeconds(0.15f)); controlsMode = original; }
public bool ChangeControllers(ControlsMode _m, bool _isBanController) { switch (_m) { // Change scheme and devices to a Keyboard use case ControlsMode.Keyboard: inputBan.SwitchCurrentControlScheme("Keyboard", Keyboard.current); inputLux.SwitchCurrentControlScheme("Keyboard", Keyboard.current); return(true); // Change scheme and devices to a Keyboard and Gamepad use case ControlsMode.ControllerKeyboard: // If Ban will play with the only controller and there is enough controller if (_isBanController && Gamepad.all.Count > 0) { inputBan.SwitchCurrentControlScheme("Controller 1", Gamepad.all[0].device); inputLux.SwitchCurrentControlScheme("Keyboard", Keyboard.current); return(true); } // If Lux will play with the only controller and there is enough controller else if (Gamepad.all.Count > 0) { inputLux.SwitchCurrentControlScheme("Controller 2", Gamepad.all[0].device); inputBan.SwitchCurrentControlScheme("Keyboard", Keyboard.current); return(true); } return(false); // Change scheme and devices to 2 Gamepads case ControlsMode.Controller: // If there's not enough controller return false if (Gamepad.all.Count < 2) { return(false); } inputBan.SwitchCurrentControlScheme("Controller 1", Gamepad.all[0].device); inputLux.SwitchCurrentControlScheme("Controller 2", Gamepad.all[1].device); return(true); default: return(false); } }
public int SetInput(ControlsMode mode, int id = -1, Gamepad gamepad = null) { switch (id) { case -1: for (int i = 0; i < 2; ++i) { if (playerInput[i].controlMode == ControlsMode.None) { playerInput[i].controlMode = mode; if (gamepad != null) { playerInput[i].gamepad = gamepad; } return(i); } else if (playerInput[i].gamepad == gamepad && gamepad != null) { return(-1); } } break; case 0: case 1: if (playerInput[id].controlMode == ControlsMode.None) { playerInput[id].controlMode = mode; return(id); } break; } return(-2); }
public static void RestoreLastControlMode() { controlsMode = lastCmode; }
public static void SetControlMode(ControlsMode newMode) { lastCmode = controlsMode; controlsMode = newMode; }