コード例 #1
0
            public static int FindButtonsCurrent(InputBufferReader reader, Factory inputFactory, List <Combination> activeInputs)
            {
                int numFound = 0;

                reader.ResetCurrIndex();
                reader.SetReadIndex(-1);
                reader.ReadBuffer(out GameInputStruct curr);
                AddToActiveInputs <ButtonsCurrent>(activeInputs, inputFactory, reader.currentFrame, newInput => {
                    numFound++;
                    newInput.Init(reader.currentFrame, curr.butA, curr.butB, curr.butC, curr.butD, curr.butS);
                });
                //FightingGameInputCodeDir direction = (FightingGameInputCodeDir) int.Parse(buffer[buffer.Length - 1].ToString());
                return(numFound);
            }
コード例 #2
0
            public static int FindQuarterCircleButtonPresses(InputBufferReader reader, Factory inputFactory, List <Combination> activeInputs)
            {
                int numFound = 0;

                reader.ResetCurrIndex();

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

                foreach (QuarterCircle qc in quarterCircles)
                {
                    reader.SetReadIndex(-(reader.currentFrame - qc.GetFrame()) - 1);
                    reader.ReadBuffer(out GameInputStruct curr);

                    bool butAPrev = curr.butA;
                    bool butBPrev = curr.butB;
                    bool butCPrev = curr.butC;
                    bool butDPrev = curr.butD;
                    bool butSPrev = curr.butS;

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

                        FindSingleButtonPress(butAPrev, butBPrev, butCPrev, butDPrev, butSPrev, la, ignoreBut: FightingGameInputCodeBut.None, callback: buttonCode => {
                            AddToActiveInputs <QuarterCircleButtonPress>(activeInputs, inputFactory, reader.currentFrame, newInput => {
                                numFound++;
                                newInput.Init(inputFrameIndex, qc.endDirection, buttonCode);
                            });
                        });

                        butAPrev = la.butA;
                        butBPrev = la.butB;
                        butCPrev = la.butC;
                        butDPrev = la.butD;
                        butSPrev = la.butS;
                    }

                    butAPrev = curr.butA;
                    butBPrev = curr.butB;
                    butCPrev = curr.butC;
                    butDPrev = curr.butD;
                    butSPrev = curr.butS;

                    for (int n = 0; n < 8 && reader.ReadyNextLookBehind(); ++n)
                    {
                        int inputFrameIndex = reader.LookBehind(out GameInputStruct lb);

                        // If you both reverse the order of the 2 frames AND negate both values, it's the same as checking in the correct order
                        FindSingleButtonPress(!butAPrev, !butBPrev, !butCPrev, !butDPrev, !butSPrev, !lb, ignoreBut: FightingGameInputCodeBut.None, callback: buttonCode => {
                            AddToActiveInputs <QuarterCircleButtonPress>(activeInputs, inputFactory, reader.currentFrame, newInput => {
                                numFound++;
                                //newInput.Init(inputFrameIndex + 1, qc.endDirection, buttonCode); // This uses the button press as the trigger
                                newInput.Init(qc.GetFrame(), qc.endDirection, buttonCode);         // This uses the end of the quarter circle as the trigger
                            });
                        });

                        butAPrev = lb.butA;
                        butBPrev = lb.butB;
                        butCPrev = lb.butC;
                        butDPrev = lb.butD;
                        butSPrev = lb.butS;
                    }
                }

                return(numFound);
            }
コード例 #3
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);
            }