private void ShuffleInputSequence() { List <int> matchValuesToAdd = new List <int>(); int inputId = 0; for (int i = 0; i < matchValues.Length; i++) { matchValuesToAdd.Add(matchValues[i]); matchValuesToAdd.Add(matchValues[i]); } for (int i = 0; i < gridLength; i++) { for (int j = 0; j < gridHeight; j++) { if (matchValuesToAdd.Count > 0) { int matchValueIndex = Random.Range(0, matchValuesToAdd.Count); inputGrid[i, j] = new MemoryMatchInput { inputId = inputId, coords = new Coords { x = i, y = j }, matchValue = matchValuesToAdd[matchValueIndex] }; matchValuesToAdd.RemoveAt(matchValueIndex); inputId++; } } } correctMatches = new List <MemoryMatchInput>(); }
public void InputReceived(MemoryMatchInput currentInput) { if (lastViewedInput == null) { lastViewedInput = currentInput; PuzzlerMiniGameEventManager.instance.OnMiniGameInputReceived(miniGameId, InputResults.NEUTRAL, currentInput.inputId); } else if (lastViewedInput.inputId == currentInput.inputId) { lastViewedInput = null; PuzzlerMiniGameEventManager.instance.OnMiniGameInputReceived(miniGameId, InputResults.NEUTRAL, currentInput.inputId); } else if (lastViewedInput.matchValue == currentInput.matchValue) { correctMatches.Add(lastViewedInput); correctMatches.Add(currentInput); PuzzlerMiniGameEventManager.instance.OnMiniGameInputReceived(miniGameId, InputResults.PASS, currentInput.inputId); if (correctMatches.Count == inputIds.Length) { PuzzlerMiniGameEventManager.instance.OnMiniGameSolved(miniGameId); } } else if (lastViewedInput.matchValue != currentInput.matchValue) { lastViewedInput = null; PuzzlerMiniGameEventManager.instance.OnMiniGameInputReceived(miniGameId, InputResults.FAIL, currentInput.inputId); } }