// Creates the moves that the Combo system will use public void IntializeCombos() { comboNames = new string[moveDef.Length]; int comboCount = 0; // Loop through the moves for (int i = 0; i < moveDef.Length; i++) { ComboAction[] challSequence = new ComboAction[moveDef[i].comboDef.Length]; // loop through sequence for (int j = 0; j < moveDef[i].comboDef.Length; j++) { // Test to see what typ of combo it is (AXIS or BUTTON) switch (moveDef[i].comboDef[j].inptType) { case InputType.AXIS: // Its a axis type challSequence[j] = CreateAxisAction(ref moveDef[i].comboDef[j]); break; case InputType.BUTTON: // Its a button type challSequence[j] = CreateButtonAction(ref moveDef[i].comboDef[j]); break; } } comboCount += 1; // The created Move that can be added to the dictonary Move moveRev = new Move(moveDef[i].name, challSequence); comboNames[i] = moveRev.name; Combo.AddCombo(moveRev); } }
// Checks if a combo has been succesful private static bool CheckCombo(Move move, ref float m_timeLastInput, ref int currentIndex, PlayerID plyrID) { // if enough time has past set the index back to zero (combo timeout) if (Time.time > m_timeLastInput + move.sequence[currentIndex].executionTime) currentIndex = 0; // If current index is less then the sequence if (currentIndex < move.sequence.Length) { bool chainWasSucces = false; int offset = 0; do { if (ActionCheck(move.sequence[currentIndex + offset], plyrID)) { chainWasSucces = true; offset += 1; // If not part of a combo chain break if (!move.sequence[currentIndex + offset - 1].connecting) { break; } } else { chainWasSucces = false; break; } } while ((currentIndex + offset) < move.sequence.Length); if (chainWasSucces) { currentIndex += offset; m_timeLastInput = Time.time; } //DEBUGING THE INPUT TYPES //InputType[] it = new InputType[move.sequence.Length]; //for (int i = 0; i < move.sequence.Length; i++) { // it[i] = GetComboActionType(move.sequence[i]); // Debug.Log(it[i] + " " + i); //} // If there are no more combos left return true and reset index if (currentIndex >= move.sequence.Length) { currentIndex = 0; return true; } else return false; } return false; }
// Quick way to add many combos to the dictonary public static void AddMultpleCombos(Move[] mvs) { for (int i = 0; i < mvs.Length; i++) { AddCombo(mvs[i]); } }
public static void DebugCombo(Move combo) { InputType[] it = new InputType[combo.sequence.Length]; for (int i = 0; i < combo.sequence.Length; i++) { it[i] = GetComboActionType(combo.sequence[i]); Debug.Log(it[i] + " " + i); } }
// Adding combo to the dictonary public static void AddCombo(Move mv) { if (!moveDictonary.ContainsKey(mv.name)) { moveDictonary.Add(mv.name, mv); } else { Debug.LogError("Combo Already Present In Dictonary"); } }