/// <summary> /// Sets control scheme used by player to one given, modifying /// inputs and updating layout to display. /// </summary> /// <param name="newScheme">new scheme used by player</param> public static void SetControlScheme(ControlSchemes newScheme) { // update current scheme currScheme = newScheme; // according to new scheme adjust input axes switch (newScheme) { case ControlSchemes.Standard: // set mouse buttons for right hand CustomInputManager.SetMouseButtonMap("Fire", 0); CustomInputManager.SetMouseButtonMap("ShowHideCraftingMenu", 1); break; case ControlSchemes.Specialist: // set mouse buttons for right hand CustomInputManager.SetMouseButtonMap("Fire", 0); CustomInputManager.SetMouseButtonMap("ShowHideCraftingMenu", 1); // set weapon select key mappings CustomInputManager.SetKeyMap("SelectWeapon1", KeyCode.A); CustomInputManager.SetKeyMap("SelectWeapon2", KeyCode.S); CustomInputManager.SetKeyMap("SelectWeapon3", KeyCode.D); CustomInputManager.SetKeyMap("SelectWeapon4", KeyCode.F); break; case ControlSchemes.LeftHanded: // set mouse buttons for left hand CustomInputManager.SetMouseButtonMap("Fire", 1); CustomInputManager.SetMouseButtonMap("ShowHideCraftingMenu", 0); break; case ControlSchemes.LeftySpecialist: // set mouse buttons for left hand CustomInputManager.SetMouseButtonMap("Fire", 1); CustomInputManager.SetMouseButtonMap("ShowHideCraftingMenu", 0); // set weapon select key mappings CustomInputManager.SetKeyMap("SelectWeapon1", KeyCode.H); CustomInputManager.SetKeyMap("SelectWeapon2", KeyCode.J); CustomInputManager.SetKeyMap("SelectWeapon3", KeyCode.K); CustomInputManager.SetKeyMap("SelectWeapon4", KeyCode.L); break; // if default case occurs, simply map inputs to standard scheme default: Debug.Log("Warning: Attempted to set controls to unknown configuration. Using standard control scheme."); currScheme = ControlSchemes.Standard; // set mouse buttons for right hand CustomInputManager.SetMouseButtonMap("Fire", 0); CustomInputManager.SetMouseButtonMap("ShowHideCraftingMenu", 1); break; } }
// This is done this way in case we add more control schemes in the future ControlSchemes CSCycle(ControlSchemes v) { switch (v) { case ControlSchemes.FLIGHTSIM: return(ControlSchemes.MARIOKART); case ControlSchemes.MARIOKART: return(ControlSchemes.FLIGHTSIM); } return(ControlSchemes.MARIOKART); }
public void MouseMode() { TwoJoyRig.SetActive(false); MinimapRig.SetActive(false); OneJoyRig.SetActive(false); MouseRig.SetActive(true); MoveJoy.SetActive(false); LookJoy.SetActive(false); HeightSlider.SetActive(true); uiLabel.GetComponent <Text>().text = "W A S D"; scheme = ControlSchemes.Mouse; }
private void LoadControls() { var k = this.Keycosystem.GetController <StandardKeyboard>(1); var m = this.Keycosystem.GetController <StandardMouse>(1); this.Keycosystem.AddControlScheme("DebugNav", ControlSchemes.DebugNavigation(this.DebugLogger, k)); var context = new ControlScheme() .AddControl(() => k.ArrowKeys.IsPressed, () => { var p = this.Player; if ((k.ArrowKeys.Direction & Direction2d.Up) > 0) { p.Speed.X = 2; p.Speed.Y = -1; p.Facing.Direction = Direction2d.Up; } if ((k.ArrowKeys.Direction & Direction2d.Right) > 0) { p.Speed.X = 2; p.Speed.Y = 1; p.Facing.Direction = Direction2d.Right; } if ((k.ArrowKeys.Direction & Direction2d.Down) > 0) { p.Speed.X = -2; p.Speed.Y = 1; p.Facing.Direction = Direction2d.Down; } if ((k.ArrowKeys.Direction & Direction2d.Left) > 0) { p.Speed.X = -2; p.Speed.Y = -1; p.Facing.Direction = Direction2d.Left; } }) .AddControl(() => !k.ArrowKeys.IsPressed, () => { var speed = this.Player.Speed; speed.X = 0; speed.Y = 0; }) .AddControl(() => k.WASD.IsPressed, () => ControlSchemes.PanCamera(this.Camera, k.WASD)) .AddControl(() => m.Scroll.Y.JustMoved, () => { var zoom = m.Scroll.Y.PositionDelta > 0 ? 0.25f : -0.25f; this.Camera.Zoom += zoom; }) .AddControl(() => m.MiddleClick.JustPressed, () => this.Camera.Zoom = 1.000f) .AddControl(() => k.F.JustPressed, () => this.Camera.Focus = () => this.Player.Space.GetOriginPosition()) .AddControl(() => k.G.JustPressed, () => this.Camera.Focus = null) .AddControl(() => k.LeftShift.DurationPressed > TimeSpan.FromSeconds(1).Ticks&& k.Z.DurationPressed > TimeSpan.FromSeconds(1).Ticks, () => { this.Director.LoadScene(Scenes.SceneSelect); }); var pauseContext = new ControlScheme(); pauseContext .AddControl(() => k.P.JustPressed, () => { context.Enabled = !context.Enabled; }); this.Keycosystem .AddControlScheme("TestMapScene", context) .AddControlScheme("Paused", pauseContext); }
/// <summary> /// Retrieves diagram corresponding to given control scheme /// </summary> /// <param name="scheme">scheme to retrieve</param> public static Sprite GetControlSchemeDiagram(ControlSchemes scheme) { return(controlLayouts[scheme]); }