예제 #1
0
        /// <summary>
        /// i.e. won't detect negative edge or holds
        /// </summary>
        /// <param name="inputHistory"></param>
        /// <param name="motionInput"></param>
        /// <returns></returns>
        public static bool InterpretNormalAttackInput(InputHistory inputHistory, AttackMotionInput motionInput)
        {
            InputHistoryEntry    entry   = inputHistory.GetEntry(0);
            IList <ButtonStatus> buttons = entry.buttons;

            ButtonStatus[] reference = motionInput.buttons;

            for (int i = 0; i < buttons.Count; i++)
            {
                ButtonStatus currStatus = buttons[i];
                if (reference[i] == ButtonStatus.Down &&
                    currStatus == ButtonStatus.Down)
                {
                    // Down match
                }
                else if (reference[i] == ButtonStatus.Up)
                {
                    // Up ignored
                }
                else
                {
                    // mismatch!
                    // TODO: might lead to strange behavior currently. i.e. 632AB might not give nothing instead of A DP
                    return(false);
                }
            }

            return(InterpretMotionInput(inputHistory, motionInput));
        }
예제 #2
0
        public override string ToString()
        {
            string result = "InputHistory:\n";

            for (int i = 0; i < InputHistorySize; i++)
            {
                InputHistoryEntry entry = new InputHistoryEntry(
                    inputHistory[i],
                    buttonHistory[i],
                    timeHistory[i]
                    );
                result += "[" + entry.ToString() + "]\n";
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// i.e. won't detect negative edge
        /// Great for detecting FD, not so great for detecting throw
        /// </summary>
        /// <param name="inputHistory"></param>
        /// <param name="motionInput"></param>
        /// <returns></returns>
        public static bool InterpretHoldButtonCombo(InputHistory inputHistory, AttackMotionInput motionInput)
        {
            int index       = 0;
            int totalFrames = 0;

            InputHistoryEntry    entry   = null;
            IList <ButtonStatus> buttons = null;

            ButtonStatus[] reference = motionInput.buttons;

            bool noMatchesFound = true; // has the input history matched a button combo yet?

            while (noMatchesFound)
            {
                if (index >= inputHistory.GetSize())
                {
                    return(false);
                }

                entry   = inputHistory.GetEntry(index);
                buttons = entry.buttons;

                bool noMismatch = true;

                for (int i = 0; i < buttons.Count; i++)
                {
                    ButtonStatus currStatus = buttons[i];
                    if (reference[i] == ButtonStatus.Down &&
                        (currStatus == ButtonStatus.Down || currStatus == ButtonStatus.Hold))
                    {
                        // held[i] = true;
                    }
                    else if (reference[i] == ButtonStatus.Up)
                    {
                        // Up ignored
                    }
                    else
                    {
                        // mismatch!
                        // TODO: might lead to strange behavior currently. i.e. 632AB might not give nothing instead of A DP
                        noMismatch = false;
                    }
                }
                if (index > 0)
                {
                    // i.e. first input has running frames since last input.
                    // Only factor in if motion input is longer than 1 input (ie. 46A)
                    totalFrames += inputHistory.GetEntry(index - 1).runningFrames;
                    if (totalFrames > motionInput.frameLimit)
                    {
                        return(false);
                    }
                }

                if (noMismatch)
                {
                    return(InterpretMotionInput(inputHistory, motionInput));
                }

                index++;
            }
            return(false);
        }
예제 #4
0
        /// <summary>
        /// i.e. won't detect negative edge
        /// Great for detecting FD, not so great for detecting throw
        /// </summary>
        /// <param name="inputHistory"></param>
        /// <param name="motionInput"></param>
        /// <returns></returns>
        public static bool InterpretTapButtonCombo(InputHistory inputHistory, AttackMotionInput motionInput)
        {
            int index       = 0;
            int totalFrames = 0;

            InputHistoryEntry    entry   = null;
            IList <ButtonStatus> buttons = null;

            ButtonStatus[] reference   = motionInput.buttons;
            int[]          frameLimits = new int[reference.Length];

            bool noMatchesFound = true; // has the input history matched a button combo yet?

            while (noMatchesFound)
            {
                if (index >= inputHistory.GetSize())
                {
                    return(false);
                }

                entry   = inputHistory.GetEntry(index);
                buttons = entry.buttons;

                for (int i = 0; i < buttons.Count; i++)
                {
                    ButtonStatus currStatus = buttons[i];
                    if (reference[i] == ButtonStatus.Down)
                    {
                        if (currStatus == ButtonStatus.Down)
                        {
                            frameLimits[i] = motionInput.frameLimit + 1;
                        }
                        else
                        {
                            // ignore everything else
                        }
                    }
                    else
                    {
                        // reference up doesn't affect button combo
                        frameLimits[i] = 100; // indicate safe state
                    }
                }
                if (index > 0)
                {
                    // i.e. first input has running frames since last input.
                    // Only factor in if motion input is longer than 1 input (ie. 46A)
                    totalFrames += inputHistory.GetEntry(index - 1).runningFrames;
                    if (totalFrames > motionInput.frameLimit)
                    {
                        return(false);
                    }
                }

                bool buttonComboDetected = true;
                for (int i = 0; i < frameLimits.Length; i++)
                {
                    if (frameLimits[i] <= 0)
                    {
                        buttonComboDetected = false;
                    }
                    frameLimits[i] = frameLimits[i] - 1;
                }
                if (buttonComboDetected)
                {
                    return(InterpretMotionInput(inputHistory, motionInput));
                }

                index++;
            }
            return(false);
        }
예제 #5
0
        /// <summary>
        /// Return true if input history matches the numpad inputs given
        ///
        /// TODO: Make sure this function isn't too slow
        /// </summary>
        /// <param name="inputHistory">The player's most recent inputs</param>
        /// <param name="motionInput">All possible forms of the given motion input</param>
        /// <returns>true if the player inputs match this motion input</returns>
        public static bool InterpretMotionInput(InputHistory inputHistory, MotionInput motionInput)
        {
            int    historyIndex   = -1;        // which index in the input history to look at?
            Numpad prevInput      = Numpad.N0; // most recently interpreted numpad direction
            int    curIndex       = 0;         // which index in the motion inputs to look at?
            int    totalFrames    = 0;         // total frames the input took to input
            bool   noMatchesFound = false;     // has the input history matched a motion input yet?

            // assume watching all at first
            bool[] notWatching = new bool[motionInput.motionInputs.Count];
            while (!noMatchesFound)
            {
                // find next input in inputHistory to consider
                historyIndex++;
                if (historyIndex >= inputHistory.GetSize())
                {
                    return(false);
                }
                InputHistoryEntry currEntry = inputHistory.GetEntry(historyIndex);
                // add to total frames

                if (currEntry.direction != prevInput)
                {
                    // new numpad input to investigate!
                    // update prev input for next iteration
                    prevInput = currEntry.direction;
                    for (int i = 0; i < notWatching.Length; i++)
                    {
                        if (notWatching[i] == false)
                        {
                            // still watching this motion input list
                            IList <Numpad> curMotionInput = motionInput.motionInputs[i];
                            if (curIndex == curMotionInput.Count - 1 &&
                                curMotionInput[curIndex] == currEntry.direction)
                            {
                                // curMotionInput was on watch list and is not exhausted
                                // means a match was detected!
                                if (totalFrames <= motionInput.frameLimit)
                                {
                                    // TODO: You can put this check earlier probably!
                                    return(true);
                                }
                                notWatching[i] = true;
                            }
                            else if (curMotionInput[curIndex] != currEntry.direction)
                            {
                                // motion input did not match up, don't watch it anymore
                                notWatching[i] = true;
                            }
                        }
                    }
                    // looking for next index on next new direction found
                    curIndex++;
                }

                // are we watching any other motion inputs?
                noMatchesFound = true;
                foreach (bool notWatch in notWatching)
                {
                    noMatchesFound = noMatchesFound && notWatch;
                }

                if (historyIndex > 0)
                {
                    // i.e. first input has running frames since last input.
                    // Only factor in if motion input is longer than 1 input (ie. 46A)
                    totalFrames += inputHistory.GetEntry(historyIndex - 1).runningFrames;
                }
            }
            return(false);
        }