Beispiel #1
0
    private void GenerateSampleFromTestCase(D2TestCase testCase)
    {
        ResetLines();
        activeTestSampleResults = new D2TestSampleResults(testCase);
        Random random = new Random();
        int    lineCount;

        switch (testCase)
        {
        case D2TestCase.CorrectD:
            letterField.text = "d";
            lineCount        = 2;
            AddLines(lineCount);
            break;

        case D2TestCase.WrongD:
            letterField.text = "d";
            lineCount        = (int)random.Next(2, 5);
            if (lineCount == 2)
            {
                lineCount = 1;
            }
            AddLines(lineCount);
            break;

        case D2TestCase.WrongP:
            letterField.text = "p";
            lineCount        = (int)random.Next(1, 3);
            AddLines(lineCount);
            break;
        }
    }
Beispiel #2
0
    private IEnumerator FadeOutAndFinishTestCase()
    {
        sampleTimer.StopTimer();
        sampleTimer.TimerFinishedEvent   -= OnTimerFinishedEvent;
        confirmButton.ButtonPressedEvent -= OnButtonPressedEvent;

        Color imageColor = fadeImage.color;

        imageColor.a = 1;
        double startTime = AudioSettings.dspTime;
        double endTime   = startTime + fadeTime;
        double timeElapsed;
        float  progress;

        while (AudioSettings.dspTime < endTime)
        {
            timeElapsed     = AudioSettings.dspTime - startTime;
            progress        = (float)(timeElapsed / fadeTime);
            imageColor.a    = progress;
            fadeImage.color = imageColor;
            yield return(null);
        }
        imageColor.a    = 1f;
        fadeImage.color = imageColor;

        yield return(new WaitForSeconds(0.1f));

        ResetLines();
        activeTestSampleResults = null;
        TestSampleFinishedEvent?.Invoke(activeTestSampleResults);
    }
    private void OnTestSampleFinishedEvent(D2TestSampleResults results)
    {
        testSample.TestSampleFinishedEvent -= OnTestSampleFinishedEvent;
        testSampleResults[testSampleCount]  = results;
        testSampleCount++;

        if (testSampleCount < sampleCount)
        {
            StartTest();
        }
        else
        {
            FinishTest();
        }
    }