public void Start() { frame = GameObject.FindGameObjectWithTag("rspTime").GetComponent <FrameEnforcer>(); frame.AddUpdate((int)FramePriority.InputBuffer, new Action <int>(ServeBuffer)); inputFactory = new Input.Factory(); inputBuffer = new GameInputStruct[bufferLength]; currState = new GameInputStruct { direction = FightingGameAbsInputCodeDir.Neutral, butA = false, butB = false, butC = false, butD = false, butS = false, }; for (int n = 0; n < inputBuffer.Length; ++n) { inputBuffer[n] = new GameInputStruct { direction = FightingGameAbsInputCodeDir.Neutral, butA = false, butB = false, butC = false, butD = false, butS = false, }; } inputCombinations = new List <Input.Combinations.Combination>(); }
private static int FindMotion(GameInputStruct curr, InputBufferReader reader, FightingGameAbsInputCodeDir[] motion, int[] searchLength) { if (curr.direction == motion[0]) { for (int motionIndex = 1; motionIndex < motion.Length; ++motionIndex) { bool stopSearch = true; for (int n = 0; reader.ReadyNextLookAhead() && n < searchLength[motionIndex - 1]; ++n) { int lookAheadFrameIndex = reader.LookAhead(out GameInputStruct la); if (la.direction == motion[motionIndex]) { if (motionIndex == motion.Length - 1) { return(lookAheadFrameIndex); } else { stopSearch = false; break; } } } if (stopSearch) { return(-1); } } } return(-1); }
public int LookBehind(out GameInputStruct behind) { if (IsLookBehindReadable()) { int currIndex = (bufferLength + inputIndex - (inputDelay + inputBufferSize) + 1 + readerIndex + lookBehindIndex) % bufferLength; behind = inputBuffer[currIndex]; return(frameIndex - (inputDelay + inputBufferSize) + 1 + readerIndex + lookBehindIndex); } else { behind = new GameInputStruct { direction = FightingGameAbsInputCodeDir.None, butA = false, butB = false, butC = false, butD = false, butS = false, }; return(-1); } }
public int ReadBuffer(out GameInputStruct curr) { if (IsReadable()) { lookAheadIndex = 0; lookBehindIndex = 0; // (inputDelay + inputBufferSize) is the relative start of the read point. Subtract the starting from the init. int currIndex = (bufferLength + inputIndex - (inputDelay + inputBufferSize) + 1 + readerIndex) % bufferLength; curr = inputBuffer[currIndex]; return(frameIndex - (inputDelay + inputBufferSize) + 1 + readerIndex); } else { curr = new GameInputStruct { direction = FightingGameAbsInputCodeDir.None, butA = false, butB = false, butC = false, butD = false, butS = false, }; return(-1); } }
private static void FindSingleButtonPress(bool butAPrev, bool butBPrev, bool butCPrev, bool butDPrev, bool butSPrev, GameInputStruct curr, FightingGameInputCodeBut ignoreBut, Action <FightingGameInputCodeBut> callback) { if (ignoreBut != FightingGameInputCodeBut.A && !butAPrev && curr.butA) { callback.Invoke(FightingGameInputCodeBut.A); } if (ignoreBut != FightingGameInputCodeBut.B && !butBPrev && curr.butB) { callback.Invoke(FightingGameInputCodeBut.B); } if (ignoreBut != FightingGameInputCodeBut.C && !butCPrev && curr.butC) { callback.Invoke(FightingGameInputCodeBut.C); } if (ignoreBut != FightingGameInputCodeBut.D && !butDPrev && curr.butD) { callback.Invoke(FightingGameInputCodeBut.D); } if (ignoreBut != FightingGameInputCodeBut.S && !butSPrev && curr.butS) { callback.Invoke(FightingGameInputCodeBut.S); } }
private static void FindSingleButtonRelease(bool butAPrev, bool butBPrev, bool butCPrev, bool butDPrev, bool butSPrev, GameInputStruct curr, FightingGameInputCodeBut ignoreBut, Action <FightingGameInputCodeBut> callback) { FindSingleButtonPress(!butAPrev, !butBPrev, !butCPrev, !butDPrev, !butSPrev, !curr, ignoreBut, callback); }