예제 #1
0
            public static int FindQuarterCircles(InputBufferReader reader, Factory inputFactory, List <Combination> activeInputs)
            {
                int numFound = 0;

                reader.ResetCurrIndex();
                FightingGameAbsInputCodeDir currDir = FightingGameAbsInputCodeDir.None;

                while (reader.ReadyNext())
                {
                    int inputFrameIndex = reader.ReadBuffer(out GameInputStruct curr);

                    if (currDir != curr.direction)
                    {
                        currDir = curr.direction;
                        int lookAheadFrameIndex;

                        reader.ResetLookAhead();
                        if ((lookAheadFrameIndex = FindMotion(curr, reader, qcLeft, qcSearchLength)) >= 0)
                        {
                            QuarterCircle input = AddToActiveInputs <QuarterCircle>(activeInputs, inputFactory, reader.currentFrame, newInput => {
                                numFound++;
                                newInput.Init(lookAheadFrameIndex, FightingGameAbsInputCodeDir.Left);
                            });
                        }

                        reader.ResetLookAhead();
                        if ((lookAheadFrameIndex = FindMotion(curr, reader, qcRight, qcSearchLength)) >= 0)
                        {
                            QuarterCircle input = AddToActiveInputs <QuarterCircle>(activeInputs, inputFactory, reader.currentFrame, newInput => {
                                numFound++;
                                newInput.Init(lookAheadFrameIndex, FightingGameAbsInputCodeDir.Right);
                            });
                        }
                    }
                }
                return(numFound);
            }
예제 #2
0
            public static int FindDirectionPlusButtons(InputBufferReader reader, Factory inputFactory, List <Combination> activeInputs)
            {
                int numFound = 0;

                reader.ResetCurrIndex();

                List <Combination> buttonPresses = activeInputs.FindAll(combo => {
                    return(combo.GetType() == typeof(ButtonPress));
                });

                foreach (ButtonPress bp in buttonPresses)
                {
                    bool continueSearch = false;
                    reader.SetReadIndex(-(reader.currentFrame - bp.GetFrame()));

                    int inputFrameIndex = reader.ReadBuffer(out GameInputStruct curr);

                    //for (int n = 0; n < 3 && reader.ReadyNextLookBehind(); ++n) {
                    //    // I'm NOT going to do a look behind for the direction. The frame of the button press is ALL that matters.
                    //}

                    for (int n = 0; n < 5 && reader.ReadyNextLookAhead(); ++n)
                    {
                        int lookAheadFrameIndex = reader.LookAhead(out GameInputStruct la);

                        if (la.direction != curr.direction)
                        {
                            continueSearch = true;
                            break;
                        }
                    }

                    if (!continueSearch && curr.direction != FightingGameAbsInputCodeDir.Neutral)
                    {
                        AddToActiveInputs <DirectionPlusButton>(activeInputs, inputFactory, reader.currentFrame, newInput => {
                            numFound++;
                            newInput.Init(bp.GetFrame(), bp.button0, curr.direction);
                        });
                    }
                    else
                    {
                        reader.ResetLookAhead();
                        int lookAheadFrameIndex             = bp.GetFrame();
                        int holdLength                      = 0;
                        FightingGameAbsInputCodeDir holdDir = curr.direction;
                        for (int n = 0; n < 15 && reader.ReadyNextLookAhead(); ++n)
                        {
                            lookAheadFrameIndex = reader.LookAhead(out GameInputStruct la);

                            if (la.direction == holdDir)
                            {
                                holdLength++;
                                if (holdLength >= 5)
                                {
                                    continueSearch = false;
                                    break;
                                }
                            }
                            else
                            {
                                holdDir    = la.direction;
                                holdLength = 0;
                            }
                        }

                        if (!continueSearch && holdDir != FightingGameAbsInputCodeDir.Neutral)
                        {
                            AddToActiveInputs <DirectionPlusButton>(activeInputs, inputFactory, reader.currentFrame, newInput => {
                                numFound++;
                                newInput.Init(lookAheadFrameIndex, bp.button0, holdDir);
                            });
                        }
                    }
                }
                return(numFound);
            }