예제 #1
0
    /// <summary>
    /// calculates the players score and cycles through arrays in the incorrect loop
    /// </summary>
    /// <param name="result"></param>
    void UpdateScore(bool result)
    {
        clickyButton = false;
        // if the player answered correctly
        if (result)
        {
            //things that happen in both loops
            incorrectCounter = 0;
            correctQuestions++;
            battleScore += 200;
            updateUI.DisplayResult("That answer was... correct!");
            enemyUnit.TakeDamage(1);

            //things that happen in incorrect loop
            if (incorrectLoop)
            {
                enemyUnit.incorrectlyAnsweredQs.RemoveAt(1);
            }
        }
        //if the player answered incorrectly
        else
        {
            //things that happen in both loops
            timesAttempted[questionNumber - 1]++;
            updateUI.DisplayResult("That answer was... incorrect");
            if (battleScore > 0)
            {
                battleScore -= 100;
                if (battleScore < 0)
                {
                    battleScore = 0;
                }
            }

            //things that happen in incorrect loop
            if (incorrectLoop)
            {
                // removes from list and adds to another as the system uses the second slot for calculations
                // but the incorrect questions still need to be stored somewhere
                incorrectCounter++;
                if (incorrectCounter >= 1)
                {
                    this.incorrectQuestions.Add(enemyUnit.incorrectlyAnsweredQs[1]);
                }
                ///enemyUnit.incorrectlyAnsweredQs.RemoveAt(1);
            }

            //things that happen in first loop
            else
            {
                enemyUnit.incorrectlyAnsweredQs.Add(questionNumber);
            }
        }

        updateUI.DisplayScore(battleScore);
        UpdateQuestion();
    }