예제 #1
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);
        }
예제 #2
0
        private void initMotionInputs()
        {
            IList <string> list236B = new List <string> ();

            list236B.Add("236");
            list236B.Add("2365");
            list236B.Add("2369");
            S236B = new AttackMotionInput(list236B, "B", Time236);

            IList <string> list66 = new List <string> ();

            list66.Add("656");
            list66.Add("956");
            list66.Add("9856");
            list66.Add("9656");
            M66 = new MotionInput(list66, Time66);

            IList <string> list44 = new List <string> ();

            list44.Add("454");
            list44.Add("754");
            list44.Add("7854");
            list44.Add("7454");
            M44 = new MotionInput(list44, Time66);

            IList <string> list4 = new List <string> ();

            list4.Add("4");
            M4 = new MotionInput(list4, 0);
            IList <string> list6 = new List <string> ();

            list6.Add("6");
            M6 = new MotionInput(list6, 0);
            IList <string> listJump = new List <string> ();

            listJump.Add("8");
            listJump.Add("7");
            listJump.Add("9");
            MJump = new MotionInput(listJump, 0);

            IList <string> list5A = new List <string> ();

            list5A.Add("5");
            list5A.Add("6");
            list5A.Add("4");
            list5A.Add("1");
            list5A.Add("2");
            list5A.Add("3");
            list5A.Add("7");
            list5A.Add("8");
            list5A.Add("9");
            N5A = new AttackMotionInput(list5A, "A", 0);

            IList <string> list5B = new List <string> ();

            list5B.Add("5");
            list5B.Add("6");
            list5B.Add("4");
            list5B.Add("1");
            list5B.Add("2");
            list5B.Add("3");
            list5B.Add("7");
            list5B.Add("8");
            list5B.Add("9");
            N5B = new AttackMotionInput(list5B, "B", 0);

            IList <string> list5C = new List <string> ();

            list5C.Add("5");
            list5C.Add("6");
            list5C.Add("4");
            list5C.Add("1");
            list5C.Add("2");
            list5C.Add("3");
            list5C.Add("7");
            list5C.Add("8");
            list5C.Add("9");
            N5C = new AttackMotionInput(list5C, "C", 0);

            IList <string> listForwardThrow = new List <string> ();

            listForwardThrow.Add("6");
            ForwardThrow = new AttackMotionInput(listForwardThrow, "AD", 2);

            IList <string> listBackwardThrow = new List <string> ();

            listBackwardThrow.Add("4");
            BackwardThrow = new AttackMotionInput(listBackwardThrow, "AD", 2);

            IList <string> listRC = new List <string> ();

            listRC.Add("5");
            listRC.Add("6");
            listRC.Add("4");
            listRC.Add("1");
            listRC.Add("2");
            listRC.Add("3");
            listRC.Add("7");
            listRC.Add("8");
            listRC.Add("9");
            RC = new AttackMotionInput(listRC, "ABD", 3);
        }