2024-11-11 12:38:38 -05:00

47 lines
1.2 KiB
C#

using System;
using GameOff.Core;
using GameOff.Quiz;
using UnityEngine;
using Random = UnityEngine.Random;
namespace GameOff.Peasant
{
public class PeasantMain : QuizTaker
{
[SerializeField] private float initTime = 20f;
[SerializeField] private float minTimePerQuestion = 5f;
[SerializeField] private float maxTimePerQuestion = 18f;
private int _indexQuestion;
private float _answerTimer;
protected override void Start()
{
base.Start();
_answerTimer = initTime + RandomQuestionTimer();
}
private void Update()
{
_answerTimer -= Time.deltaTime;
if (_answerTimer <= 0)
{
answers[_indexQuestion] = QuizHandler.Instance.GetAnswerAtIndex(_indexQuestion);
_answerTimer = RandomQuestionTimer();
_indexQuestion++;
if (_indexQuestion >= answers.Length)
enabled = false;
}
}
private float RandomQuestionTimer()
{
return Random.Range(minTimePerQuestion, maxTimePerQuestion);
}
}
}