Пример #1
0
        /// <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;
                }
            }
        }
Пример #2
0
    /// <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);
    }
Пример #3
0
 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));
 }
Пример #4
0
 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);
 }
Пример #5
0
 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));
 }
Пример #6
0
    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);
    }
Пример #7
0
    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);
    }
Пример #8
0
    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);
    }
Пример #9
0
    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);
        }
    }
Пример #10
0
 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));
 }
Пример #11
0
    /// <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);
        }
    }
Пример #12
0
    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);
    }
Пример #13
0
 /// <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);
 }
Пример #14
0
 /// <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);
 }
Пример #15
0
 /// <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));
 }
Пример #16
0
 /// <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);
Пример #17
0
 /// <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));
 }