void Update() { kickTimer.UpdateTimer(Time.deltaTime); if (Input.GetKeyDown(KeyCode.Return)) { KickCamera(Vector3.right, 2); } if (kicking) { if (recoiling) { if (kickTimer.Running) { float timerPercentage = (kickTimer.counter / kickTimer.timerTargetValue); //int kt = (int)(kickTimer.counter * 100); //Debug.Log("Recoiling\nTimer running: " + kickTimer.counter); transform.position = Vector3.Lerp(intendedPosition, kickedPosition, timerPercentage); } if (kickTimer.CheckTimer()) { transform.position = kickedPosition; //Debug.Log("Recoil Complete\nTimer running: " + kickTimer.counter + "\t" + kickTimer.CheckTimer()); recoiling = false; kickTimer.Reset(true); kickTimer.Start(); } } if (!recoiling) { if (kickTimer.Running) { float timerPercentage = (kickTimer.counter / kickTimer.timerTargetValue); transform.position = Vector3.Lerp(kickedPosition, intendedPosition, timerPercentage); } if (kickTimer.CheckTimer()) { transform.position = intendedPosition; kicking = false; } } } }
void HandleInputLogic() { #region Pre-trial if (!started) { if (CheckInput()) { Instructions.gameObject.SetActive(false); started = true; timer.Start(); } } #endregion #region Running Trial //If we're running trials if (started && trialIndex < numTrials) { //If we got input if (CheckInput()) { //If we're getting input if (receivingInput) { //Set the score and reaction counter score[trialIndex] += Time.timeSinceLevelLoad - gettingInputStart; reactionTime[trialIndex] = Time.timeSinceLevelLoad - gettingInputStart; //We don't want to ask for input PromptInput.gameObject.SetActive(false); //We haven't given a blink yet presentedBlinkYet = false; //Reset the clock timer.Reset(true); //Next trial trialIndex++; if (trialIndex >= numTrials) { OutputScores(); running = false; } } else { //Punish the user for early input score[trialIndex] += .25f; //Set the timer back so they don't miss the actual input. timer.AdjustTime(-.35f); } } } #endregion }