-1

I have a multiple choice quiz game, and i want to make score. however i want to connect the score with my time renaming therefore if user chooses the right answer he get's 10 points but i also want to multiply that number with the time remaining. so if the time reaches 0 the game ends if he finishes fast he get's higher score, and if he finishes so slow he will lose score. to to summarize i want the time remaining and the points to be connected together.

What i have tried is, on each correct answer i pass in a point and i made it score and also i have a high score, what i can't figure out is how to connect it to the time remaining?

Here's what i have

public void AnswerButtonClick(bool isCorrect)
{
    if (isCorrect)
    {
        Debug.Log("I'm Correct");
        theAnswerIsCorrect = true;
        playerScore += currentRoundData.pointAddedForCorrectAnswer;
        scoreDisplayText.text = "Score: " + playerScore.ToString();


    }

    else
        theAnswerIsCorrect = false;



    // Do we still have questions?
    if (questionPool.Length > questionIndex + 1)
    {
        //questionIndex++;

        UpdateQuestionIndex();
        StartCoroutine(DelayTime(3));
      //  ShowQuestion();
    }

    else
    {
        EndRound();
    }
}

This just add's point if i get the correct answer, what i need is how do also calculate the time remaining with my points.

Here's the time remaining

// Update is called once per frame
void Update () 
{
    if (isRoundActive)
    {
        timerRemaing -= Time.deltaTime;
        UpdateTimeRemainingDisplay();

        if (timerRemaing <= 0)
            EndRound();  


    }   
}

so basically everytime my time is getting lower i lose more score. Thank you

Nanopili
  • 73
  • 12
  • You're being downvoted because there is nothing we can help with. Supply the code you're using and there is at least something to try to understand. Is your question how to get the time between 2 instances? `var startingTime = Time.time;` will do that for you, then `var timeUsed = Time.time - startingTime;` – Fredrik Schön Jan 17 '17 at 08:54
  • No worries! Are these 2 different scripts on different gameobjects? – Fredrik Schön Jan 17 '17 at 09:03
  • No, they are on the same GameManager script – Nanopili Jan 17 '17 at 09:04
  • And your question is how to use `timerRemaining` with `playerScore`? Mathematically or programatically? As in... Do you need help with how to get a good, realtistic score every time with these values or how to code it? – Fredrik Schön Jan 17 '17 at 09:07
  • How much time does the player have for each question? – Fredrik Schön Jan 17 '17 at 09:08
  • Mathematically and programatically. first i need to know the math then i will try to program it.. Each round player has 80 seconds to asnwer all 10 questions – Nanopili Jan 17 '17 at 09:10
  • And you want the time to factor in on the points at the very end of the 10 questions, or at every question? – Fredrik Schön Jan 17 '17 at 09:20
  • in the end of the 10 question i want to display the score. and i want the score to be a factor of the time remaining + the points ( player get's points if he chooses the correct answer) so to avoid confusion, the score will be if the user finishes faster he get's higher score. so it's TimeRemaning + points collected. But how do i calculate the time remaining as a score..? – Nanopili Jan 17 '17 at 09:29
  • `timerRemaining` is a float, is the score an int? You could just make the score a float and you can just add them together. `float finalScore = timerRemain + playerScore;` – Fredrik Schön Jan 17 '17 at 09:36
  • i will try that, thank you very much .. Meanwhile can you also help me on my other question which can be found here : http://stackoverflow.com/questions/41690670/unity-quiz-game-multiple-choice-button-colors only if you are free pls ^^ – Nanopili Jan 17 '17 at 09:53

2 Answers2

0

I think it would be best to start a timer at the beginning of each question, and then create some algorithm for the points. I hope I understood your question right

Sokui
  • 53
  • 1
  • 10
0

Why you don't multiply the variable timerRemaing with a Question Score variable and add it to the Player Score variable?

That's what u want right?

Sergio
  • 43
  • 10