public void ConstructSimonTest(IMiniGameEventManager miniGameEventManager, string miniGameId, int inputCount, int inputSequenceCount, int failureThreshold) { Simon simon = new Simon(miniGameEventManager, miniGameId, inputCount, inputSequenceCount, failureThreshold); Assert.AreEqual(simon.GetMiniGameId(), miniGameId); Assert.AreEqual(simon.GetInputIds().Length, inputCount); Assert.AreEqual(simon.GetInputSequence().Length, inputSequenceCount); Assert.AreEqual(simon.GetFailureThreshold(), failureThreshold); }
private void Start() { simon = new Simon(PuzzlerMiniGameEventManager.instance, miniGameId, inputCount, inputSequenceCount, failureThreshold); inputSequence = simon.GetInputSequence(); if (PuzzlerMiniGameEventManager.instance != null) { PuzzlerMiniGameEventManager.instance.PuzzlerInputReceived += OnMiniGameInputReceived; PuzzlerMiniGameEventManager.instance.MiniGameRequestPlay += PlaySequence; PuzzlerMiniGameEventManager.instance.PuzzlerMiniGameSolved += OnMiniGameSolved; //PuzzlerMiniGameEventManager.instance.PuzzlerMiniGameFailed += OnMiniGameFailed; } }
public void SimonSolvedWithWrongAnswersTest(IMiniGameEventManager miniGameEventManager, string miniGameId, int inputCount, int inputSequenceCount, int failureThreshold) { bool miniGameSolved = false; int wrongAnswerCount = 0; int correctAnswerCount = 0; bool miniGameFailed = false; miniGameEventManager.OnMiniGameInputReceived( Arg.Any <string>(), Arg.Do <InputResults>(x => { if (x.Equals(InputResults.FAIL)) { wrongAnswerCount++; } if (x.Equals(InputResults.PASS)) { correctAnswerCount++; } }), Arg.Any <int>() ); miniGameEventManager.When(x => x.OnMiniGameFailed(miniGameId)).Do(x => miniGameFailed = true); miniGameEventManager.When(x => x.OnMiniGameSolved(miniGameId)).Do(x => miniGameSolved = true); Simon simon = new Simon(miniGameEventManager, miniGameId, inputCount, inputSequenceCount, failureThreshold); int[] inputSequence = simon.GetInputSequence(); simon.VerifyInput(simon.GetInputIds().Length + 1); foreach (int input in inputSequence) { simon.VerifyInput(input); } Assert.IsTrue(miniGameSolved); Assert.IsTrue(!miniGameFailed); Assert.AreEqual(simon.GetInputSequence().Length, correctAnswerCount); Assert.AreEqual(simon.GetFailureCount(), wrongAnswerCount); }
public void OnMiniGameSolved(object source, PuzzlerMiniGameEventArgs args) { if (args.MiniGameId == miniGameId) { simon = new Simon(PuzzlerMiniGameEventManager.instance, miniGameId, inputCount, inputSequenceCount, failureThreshold); inputSequence = simon.GetInputSequence(); if (gameWonClip) { AudioSource audioSource = transform.GetComponent <AudioSource>(); if (audioSource) { audioSource.clip = gameWonClip; audioSource.Play(); } } } }