static KeyCode buttonToKeyCode(XbButton btn) { switch(btn) { case XbButton.A: return m.A; case XbButton.B: return m.B; case XbButton.X: return m.X; case XbButton.Y: return m.Y; case XbButton.LB: return m.LB; case XbButton.RB: return m.RB; case XbButton.Back: return m.Back; case XbButton.Start: return m.Start; case XbButton.LStickClick: return m.LStickClick; case XbButton.RStickClick: return m.RStickClick; } throw new MakeCSharpHappyException (); }
public static bool GetButtonUp(XbButton btn) { return Input.GetKeyUp (buttonToKeyCode (btn)); }
// Update is called once per frame void Update() { if (InputActions.MenuConfirms) { CurrentUserSettings.Save(); } foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(kcode)) { if (!reservedKeyboardInputs.Contains(kcode)) { if (Jump.isFocused) { reservedKeyboardInputs.Remove(newJump); newJump = kcode; Jump.text = newJump.ToString(); reservedKeyboardInputs.Add(newJump); } if (Dodge.isFocused) { reservedKeyboardInputs.Remove(newDodge); newDodge = kcode; Dodge.text = newDodge.ToString(); reservedKeyboardInputs.Add(newDodge); } if (BasicAttack.isFocused) { reservedKeyboardInputs.Remove(newBasicAttack); newBasicAttack = kcode; BasicAttack.text = newBasicAttack.ToString(); reservedKeyboardInputs.Add(newBasicAttack); } if (MagnetImpact.isFocused) { reservedKeyboardInputs.Remove(newMagnetImpact); newMagnetImpact = kcode; MagnetImpact.text = newMagnetImpact.ToString(); reservedKeyboardInputs.Add(newMagnetImpact); } if (JumpQuake.isFocused) { reservedKeyboardInputs.Remove(newJumpQuake); newJumpQuake = kcode; JumpQuake.text = newJumpQuake.ToString(); reservedKeyboardInputs.Add(newJumpQuake); } } } } foreach (XbButton button in Enum.GetValues(typeof(XbButton))) { if (XbInput.GetButtonDown(button)) { if (!reservedXboxControllerInputs.Contains(button)) { if (JumpXbox.isFocused) { reservedXboxControllerInputs.Remove(newJumpXbox); newJumpXbox = button; JumpXbox.text = newJumpXbox.ToString(); reservedXboxControllerInputs.Add(newJumpXbox); } if (DodgeXbox.isFocused) { reservedXboxControllerInputs.Remove(newDodgeXbox); newDodgeXbox = button; DodgeXbox.text = newDodgeXbox.ToString(); reservedXboxControllerInputs.Add(newDodgeXbox); } if (BasicAttackXbox.isFocused) { reservedXboxControllerInputs.Remove(newBasicAttackXbox); newBasicAttackXbox = button; BasicAttackXbox.text = newBasicAttackXbox.ToString(); reservedXboxControllerInputs.Add(newBasicAttackXbox); } if (MagnetImpactXbox.isFocused) { reservedXboxControllerInputs.Remove(newMagnetImpactXbox); newMagnetImpactXbox = button; MagnetImpactXbox.text = newMagnetImpactXbox.ToString(); reservedXboxControllerInputs.Add(newMagnetImpactXbox); } if (JumpQuakeXbox.isFocused) { reservedXboxControllerInputs.Remove(newJumpQuakeXbox); newJumpQuakeXbox = button; JumpQuakeXbox.text = newJumpQuakeXbox.ToString(); reservedXboxControllerInputs.Add(newJumpQuakeXbox); } } } } }
// Use this for initialization void Start() { /*var resolutions = new List<String>(); * foreach (var resolution in Screen.resolutions) { * resolutions.Add (resolution.ToString()); * } * ScreenResolution.AddOptions (resolutions); * ScreenResolution.value = Array.IndexOf(Screen.resolutions, Screen.currentResolution); * * Windowed.isOn = !Screen.fullScreen;*/ CurrentUserSettings.LoadSettings(); AmbientAudioVolume.minValue = 0.0f; AmbientAudioVolume.maxValue = 1.0f; AmbientAudioVolume.value = CurrentUserSettings.Data.AmbientVolume; newAmbientVolume = CurrentUserSettings.Data.AmbientVolume; ActionAudioVolume.minValue = 0.0f; ActionAudioVolume.maxValue = 1.0f; ActionAudioVolume.value = CurrentUserSettings.Data.ActionVolume; newActionVolume = CurrentUserSettings.Data.ActionVolume; MusicAudioVolume.minValue = 0.0f; MusicAudioVolume.maxValue = 1.0f; MusicAudioVolume.value = CurrentUserSettings.Data.MusicVolume; newMusicVolume = CurrentUserSettings.Data.MusicVolume; Jump.text = CurrentUserSettings.Data.KeyboardJump; newJump = (KeyCode)System.Enum.Parse(typeof(KeyCode), Jump.text); reservedKeyboardInputs.Add(newJump); Dodge.text = CurrentUserSettings.Data.KeyboardDodge; newDodge = (KeyCode)System.Enum.Parse(typeof(KeyCode), Dodge.text); reservedKeyboardInputs.Add(newDodge); BasicAttack.text = CurrentUserSettings.Data.KeyboardBasicAttack; newBasicAttack = (KeyCode)System.Enum.Parse(typeof(KeyCode), BasicAttack.text); reservedKeyboardInputs.Add(newBasicAttack); MagnetImpact.text = CurrentUserSettings.Data.KeyboardMagnetImpact; newMagnetImpact = (KeyCode)System.Enum.Parse(typeof(KeyCode), MagnetImpact.text); reservedKeyboardInputs.Add(newMagnetImpact); JumpQuake.text = CurrentUserSettings.Data.KeyboardJumpQuake; newJumpQuake = (KeyCode)System.Enum.Parse(typeof(KeyCode), JumpQuake.text); reservedKeyboardInputs.Add(newJumpQuake); JumpXbox.text = CurrentUserSettings.Data.XbButtonJump; newJumpXbox = (XbButton)System.Enum.Parse(typeof(XbButton), JumpXbox.text); reservedXboxControllerInputs.Add(newJumpXbox); DodgeXbox.text = CurrentUserSettings.Data.XbButtonDodge; newDodgeXbox = (XbButton)System.Enum.Parse(typeof(XbButton), DodgeXbox.text); reservedXboxControllerInputs.Add(newDodgeXbox); BasicAttackXbox.text = CurrentUserSettings.Data.XbButtonBasicAttack; newBasicAttackXbox = (XbButton)System.Enum.Parse(typeof(XbButton), BasicAttackXbox.text); reservedXboxControllerInputs.Add(newBasicAttackXbox); MagnetImpactXbox.text = CurrentUserSettings.Data.XbButtonMagnetImpact; newMagnetImpactXbox = (XbButton)System.Enum.Parse(typeof(XbButton), MagnetImpactXbox.text); reservedXboxControllerInputs.Add(newMagnetImpactXbox); JumpQuakeXbox.text = CurrentUserSettings.Data.XbButtonJumpQuake; newJumpQuakeXbox = (XbButton)System.Enum.Parse(typeof(XbButton), JumpQuakeXbox.text); reservedXboxControllerInputs.Add(newJumpQuakeXbox); }
public ButtonBinding(KeyCode c, XbButton b, params KeyCode[] a) { Keyboard = c; XboxController = b; ExtraAliases = a == null ? new List <KeyCode>() : a.ToList(); }