private void IsInputReceived() { if (countDownTimer < 1) { currentState = SimoneState.INPUTRECEIVED; } next = 0; //reset it back to 0 }
private void StartPlayingState() { currentState = SimoneState.PLAYING; next = 0; //Next should start at 0 //isDisplayingSequence = true;//Sequence should be displayed first //awaitingPlayerInput = false;//Then player input after sequence sequenceList = simonSaysRandomizer.RandomizeSequence(maxiumSequenceLength); //Get a randomized sequence list at the start and how long the sequence is }
private bool DoesInputMatchSequence() { bool answeredCorrectly = false; //simonImageDisplay.DisplayImageSequence(inputManager.Inputs[next]); //Display the button pressed if (inputManager.Inputs.Count < 1) { currentState = SimoneState.PLAYING; return(answeredCorrectly); } for (int i = 0; i < inputManager.Inputs.Count; i++) { if (i > sequenceList.Count) { return(answeredCorrectly); } if (sequenceList[next] == inputManager.Inputs[next]) //If the button (index) pressed matches the button index on the sequence list { answeredCorrectly = true; PlayAudioClip(correctSound); currentState = SimoneState.PLAYING; } else { answeredCorrectly = false; PlayAudioClip(wrongSound); currentState = SimoneState.PLAYING; } next++; //add 1 to get to the next index in the sequence if (!(next < maxiumSequenceLength) || answeredCorrectly == false) // Once int next reaches max or player answered wrong { sequenceList = simonSaysRandomizer.RandomizeSequence(maxiumSequenceLength); //Get a new randomized sequence next = 0; //- reset it back to 0 //isDisplayingSequence = true; //display the new sequence //awaitingPlayerInput = false;//stop getting player input StartCoroutine(TimedSequence()); //wait a bit to clear image timeStamp = Mathf.RoundToInt(Time.fixedTime) + 2; //Get the current time plus a bit of a delay(2) } } return(answeredCorrectly); }
//Main Methods private void DisplaySequence() { if (Mathf.RoundToInt(Time.fixedTime) == timeStamp + secondsToWait) //waits every so seconds until displaying the next button { simonImageDisplay.DisplayImageSequence(sequenceList[next]); //Display the button on the sequence list StartCoroutine(TimedSequence()); //Wait a bit until clearing image next++; //add 1 to get to the next index in the sequence if (!(next < maxiumSequenceLength)) // Once int next reaches max { //isDisplayingSequence = false;//No longer displaying sequence //awaitingPlayerInput = true;//Start getting player input currentState = SimoneState.AWAITINGINPUT; } timeStamp = Mathf.RoundToInt(Time.fixedTime); //Get the current time to update the time to wait until displaying the next image } }
// Use this for initialization private void Awake() { isInputCorrect = true; currentState = SimoneState.START; GetComponentsForSetup(); }