public IEnumerator WHEN_TimeAndKeyCreated_THEN_KeyNameGetFunctionWorks() { tempTimeAndKey = new TimeAndKey(3.1, KeyCode.Space); tempKeyName = tempTimeAndKey.KeyName; yield return(null); Assert.AreEqual("Space", tempKeyName); }
public IEnumerator TestCatchTheThiefKeysPressedAdd1ItemThenGetterReturnsCorrectValue() { round = new CatchTheThiefRound(); round.UnidentifiedKeysPressed = new List <TimeAndKey>(); TimeAndKey expectedTimeAndKey = new TimeAndKey(1f, KeyCode.Alpha0); round.UnidentifiedKeysPressed.Add(expectedTimeAndKey); TimeAndKey actualTimeAndKey = round.UnidentifiedKeysPressed[0]; yield return(null); Assert.IsTrue(expectedTimeAndKey == actualTimeAndKey); }
/// <summary> /// The action triggered by the player pressing the spacebar. /// The next image will be displayed immediately, the right and wrong conditions will be updated accordingly, /// and the key press time will be properly recorded. /// </summary> public void OnKey(bool isSpaceKey, TimeAndKey wrongKey) { if (initialTestImages != null) { if (gameState != -1 & prepareTime <= 0) { if (serialNumber >= 0 && serialNumber < initialTestImages.Count) // OnKey() processes the results of user keystrokes and saves the results of user keystrokes to storage { currentImageHitRound.isKeyPressed = true; if (currentImageHitRound.UnidentifiedKeysPressed == null) { currentImageHitRound.UnidentifiedKeysPressed = new List <TimeAndKey>(); } keyPressEndTime = Time.time; // The time of pressing the space bar currentImageHitRound.keyPressTime = keyPressEndTime - keyPressStartTime; currentImageHitRound.isSpaceKey = isSpaceKey; if (isSpaceKey) { if (specifiedTheme == initialTestImages[serialNumber].imageTheme) // If the theme is current specified theme { Beep.Play(); // Play the beep sound currentImageHitRound.isCorrectlyIdentified = true; } else { WrongAudio.Play(); // Play the wrong audio currentImageHitRound.isCorrectlyIdentified = false; } serialNumber++; // Go to the next image canShowNextImage = true; imageDisplayedTime = 0; } else { currentImageHitRound.isCorrectlyIdentified = false; currentImageHitRound.UnidentifiedKeysPressed.Add(wrongKey); } } } } }