/// <summary> /// Updates the bard's progress through the current tune. /// </summary> internal void UpdateTune() { // Reset the current button. pressedButton = ControllerInputWrapper.Buttons.Start; // Plays the tune on the beat. if (currentTune != null && buttonPressDelayTimer < 0f && LevelManager.instance.PerfectTiming(rhythmType) >= modifiedThreshold) { if (Random.Range(0f, 1f) < noteAccuracy) { pressedButton = currentTune.tune[tuneProgress]; if (++tuneProgress >= currentTune.tune.Length) { tuneProgress = 0; currentTune = null; } } buttonPressDelay = Mathf.Max(buttonPressDelayTimer, noteDelay); modifiedThreshold = Tune.PERFECT_THRESHOLD; if (Random.Range(0.0f, 1.0f) > timingAccuracy) { modifiedThreshold -= 0.2f; } } }
/// <summary> /// Removes the last AI player from the game. /// </summary> /// <returns>The index of the AI player that was removed.</returns> /// <param name="removalButton">The button that needs to be pressed to remove an AI.</param> public int AllowAIRemoval(ControllerInputWrapper.Buttons removalButton) { PlayerID playerToRemove = PlayerID.None; bool removing = false; foreach (KeyValuePair <PlayerID, ControllerInputWrapper> kvp in playerControls) { if (kvp.Value.GetButton(removalButton)) { removing = true; break; } } if (removing) { foreach (KeyValuePair <PlayerID, ControllerInputWrapper> kvp in playerControls) { if (kvp.Value is AIWrapper && kvp.Key > playerToRemove) { playerToRemove = kvp.Key; } } } if (playerToRemove != PlayerID.None) { RemoveController(playerToRemove); } return((int)playerToRemove); }
public static bool GetButtonUp(ControllerInputWrapper.Buttons button, int joyNum) { joyNum--; if (joyNum < 0 || playerControls[joyNum] == null) { return(false); } return(playerControls[joyNum].GetButtonUp(button, joyNum + 1)); }
public bool GetButtonUp(ControllerInputWrapper.Buttons button, int joyNum) { // joyNum--; // if (joyNum < 0 || playerControls[joyNum] == null) // { // return false; // } // return playerControls[joyNum].GetButtonUp(button, joyNum + 1); return(false); }
public bool GetButtonDown(ControllerInputWrapper.Buttons button, PlayerID id = PlayerID.One) { if (!playerControls.ContainsKey(id)) { return(false); } if (playerControls[id] == null) { return(false); } return(playerControls[id].GetButtonDown(button)); }
public bool GetButtonAll(ControllerInputWrapper.Buttons button, bool isDown) { //This definitely needs an update........... Like seriously.. // int i = 0; // foreach (ControllerInputWrapper cW in playerControls) // { // if (!cW.GetButton(button, i, isDown)){ // return false; // } // } return(false); }
public static bool GetButtonAll(ControllerInputWrapper.Buttons button, bool isDown) { //This definitely needs an update........... Like seriously.. int i = 0; foreach (ControllerInputWrapper cW in playerControls) { if (!cW.GetButton(button, i, isDown)) { return(false); } } return(true); }
public int AllowPlayerRemoval(ControllerInputWrapper.Buttons removalButton) { PlayerID playerToRemove = PlayerID.None; foreach (KeyValuePair <PlayerID, ControllerInputWrapper> kvp in playerControls) { if (kvp.Value.GetButton(removalButton)) { playerToRemove = kvp.Key; break; } } if (playerToRemove != PlayerID.None) { RemoveController(playerToRemove); } return((int)playerToRemove); }
public void AllowPlayerRemoval(ControllerInputWrapper.Buttons removalButton) { PlayerID playerToRemove = PlayerID.None; foreach (KeyValuePair <PlayerID, ControllerInputWrapper> kvp in ControllerManager.instance.playerControls) { if (kvp.Value.GetButton(removalButton)) { playerToRemove = kvp.Key; break; } } if (playerToRemove != PlayerID.None) { // Debug.Log(playerToRemove + " removed"); playerControls.Remove(playerToRemove); } }
public static bool GetButton(ControllerInputWrapper.Buttons button, int joyNum, bool isDown = false) { joyNum--; //Debug.Log(joyNum); if (joyNum < 0) { if (joyNum == -1) { return(keyboardWrapper.GetButton(button, joyNum, isDown)); } return(false); } if (playerControls[joyNum] == null) { return(false); } return(playerControls[joyNum].GetButton(button, joyNum + 1, isDown)); }
/// <summary> /// Updates the bard's progress through the current tune. /// </summary> public void UpdateTune() { // Reset the current button. pressedButton = ControllerInputWrapper.Buttons.Start; // Plays the tune on the beat. if (currentTune != null && buttonPressDelayTimer < 0f && LevelManager.instance.PerfectTiming(rhythmType) >= modifiedThreshold) { pressedButton = currentTune.tune[tuneProgress]; if (++tuneProgress >= currentTune.tune.Length) { tuneProgress = 0; currentTune = null; } buttonPressDelay = Mathf.Max(buttonPressDelayTimer, noteDelay); modifiedThreshold = Tune.PERFECT_THRESHOLD + Random.Range(-timingVariance, timingVariance); } }
public bool AddPlayer(ControllerInputWrapper.Buttons connectCode) { KeyboardWrapper kw = new KeyboardWrapper(-1); if (!playerControls.ContainsValue(kw) && kw.GetButton(connectCode)) { for (int j = 1; j < 5; j++) { if (!playerControls.ContainsKey((PlayerID)j)) { playerControls.Add((PlayerID)(j), kw); Debug.Log((PlayerID)(j) + ": " + kw + " added"); return(true); } } } if (playerControls.Count < 4) { string[] controllerNames = Input.GetJoystickNames(); for (int i = 0; i < controllerNames.Length; i++) { ControllerInputWrapper ciw = getControllerType(i); if (ciw != null && !playerControls.ContainsValue(ciw) && ciw.GetButton(connectCode)) { for (int j = 1; j < 5; j++) { if (!playerControls.ContainsKey((PlayerID)j)) { playerControls.Add((PlayerID)(j), ciw); Debug.Log((PlayerID)(j) + ": " + ciw + " added"); return(true); } } } } } return(false); }
/// <summary> /// Adds an AI controller to the game. /// </summary> /// <returns>Whether the AI controller was successfully added.</returns> public bool AddAI(ControllerInputWrapper.Buttons connectCode) { if (playerControls.Count < 4) { foreach (KeyValuePair <PlayerID, ControllerInputWrapper> kvp in ControllerManager.instance.playerControls) { ControllerInputWrapper ciw = kvp.Value; if (ciw != null && ciw.GetButton(connectCode)) { for (int j = 1; j < 5; j++) { if (!playerControls.ContainsKey((PlayerID)j)) { AIWrapper aiw = new AIWrapper(-2); playerControls.Add((PlayerID)(j), aiw); Debug.Log((PlayerID)(j) + ": " + aiw + " added"); return(true); } } } } } return(false); }
/// <summary> /// Checks if a certain button was pressed. /// </summary> /// <returns>Whether the button was pressed.</returns> /// <param name="button">The button to check for.</param> protected override bool GetButtonDown(ControllerInputWrapper.Buttons button) { return(pressedButton == button); }
/// <summary> /// Checks if a certain button is being pressed. /// </summary> /// <returns>Whether the button is being pressed.</returns> /// <param name="button">The button to check for.</param> protected override bool GetButton(ControllerInputWrapper.Buttons button) { return(ControllerManager.instance.GetButton(button, control.player)); }
/// <summary> /// Checks if a certain button is being pressed. /// </summary> /// <returns>Whether the button is being pressed.</returns> /// <param name="button">The button to check for.</param> protected abstract bool GetButton(ControllerInputWrapper.Buttons button);
/// <summary> /// Checks if a certain button is being pressed. /// </summary> /// <returns>Whether the button is being pressed.</returns> /// <param name="button">The button to check for.</param> protected override bool GetButton(ControllerInputWrapper.Buttons button) { return(GetButtonDown(button)); }