mirror of
https://github.com/ConjureETS/GameOff2024.git
synced 2026-03-24 05:00:59 +00:00
Peasant can finish the quiz
This commit is contained in:
parent
1a34a1c036
commit
f2b39a9dad
@ -46,9 +46,10 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
answers: []
|
answers: []
|
||||||
initTime: 20
|
initTime: 2
|
||||||
minTimePerQuestion: 5
|
minTimePerQuestion: 0.5
|
||||||
maxTimePerQuestion: 18
|
maxTimePerQuestion: 1
|
||||||
|
successRate: 0.75
|
||||||
--- !u!1 &5739709613417327085
|
--- !u!1 &5739709613417327085
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -764,21 +764,6 @@ PrefabInstance:
|
|||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_TransformParent: {fileID: 54002814}
|
m_TransformParent: {fileID: 54002814}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 774219910790536021, guid: 58a9a466f0501ce4d8388102500b1754,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: initTime
|
|
||||||
value: 2
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 774219910790536021, guid: 58a9a466f0501ce4d8388102500b1754,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: maxTimePerQuestion
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 774219910790536021, guid: 58a9a466f0501ce4d8388102500b1754,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: minTimePerQuestion
|
|
||||||
value: 0.5
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 2684113167729998087, guid: 58a9a466f0501ce4d8388102500b1754,
|
- target: {fileID: 2684113167729998087, guid: 58a9a466f0501ce4d8388102500b1754,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
@ -3952,6 +3937,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
questionAmount: 20
|
questionAmount: 20
|
||||||
|
quizTakerAmount: 8
|
||||||
questionVisual:
|
questionVisual:
|
||||||
- {fileID: -959586227, guid: 19a8aecd158cac04fb8bb6de1e21ffaa, type: 3}
|
- {fileID: -959586227, guid: 19a8aecd158cac04fb8bb6de1e21ffaa, type: 3}
|
||||||
- {fileID: -1923230478, guid: 19a8aecd158cac04fb8bb6de1e21ffaa, type: 3}
|
- {fileID: -1923230478, guid: 19a8aecd158cac04fb8bb6de1e21ffaa, type: 3}
|
||||||
@ -3960,7 +3946,6 @@ MonoBehaviour:
|
|||||||
- {fileID: 233852084, guid: 19a8aecd158cac04fb8bb6de1e21ffaa, type: 3}
|
- {fileID: 233852084, guid: 19a8aecd158cac04fb8bb6de1e21ffaa, type: 3}
|
||||||
seed: 0
|
seed: 0
|
||||||
randomGeneration: 1
|
randomGeneration: 1
|
||||||
correctAnswer: []
|
|
||||||
--- !u!1 &1839156921
|
--- !u!1 &1839156921
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using GameOff.Peasant;
|
||||||
using GameOff.Quiz;
|
using GameOff.Quiz;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Random = System.Random;
|
using Random = System.Random;
|
||||||
@ -12,10 +13,10 @@ namespace GameOff.Core
|
|||||||
public static QuizHandler Instance { get; private set; }
|
public static QuizHandler Instance { get; private set; }
|
||||||
|
|
||||||
[SerializeField] private int questionAmount = 20;
|
[SerializeField] private int questionAmount = 20;
|
||||||
|
[SerializeField] private int quizTakerAmount = 8;
|
||||||
[SerializeField] private List<Sprite> questionVisual;
|
[SerializeField] private List<Sprite> questionVisual;
|
||||||
[SerializeField] private int seed;
|
[SerializeField] private int seed;
|
||||||
[SerializeField] private bool randomGeneration;
|
[SerializeField] private bool randomGeneration;
|
||||||
[SerializeField] private string[] correctAnswer;
|
|
||||||
|
|
||||||
private readonly List<string> ChoicePossibles = new List<string>() { "a", "b", "c", "d", "e", "f" };
|
private readonly List<string> ChoicePossibles = new List<string>() { "a", "b", "c", "d", "e", "f" };
|
||||||
|
|
||||||
@ -46,7 +47,6 @@ namespace GameOff.Core
|
|||||||
private void GenerateQuiz()
|
private void GenerateQuiz()
|
||||||
{
|
{
|
||||||
_questionInfos = new List<QuestionInfo>();
|
_questionInfos = new List<QuestionInfo>();
|
||||||
correctAnswer = new string[questionAmount];
|
|
||||||
|
|
||||||
for (int i = 0; i < questionAmount; i++)
|
for (int i = 0; i < questionAmount; i++)
|
||||||
{
|
{
|
||||||
@ -58,11 +58,25 @@ namespace GameOff.Core
|
|||||||
tmp.Add(ChoicePossibles[x]);
|
tmp.Add(ChoicePossibles[x]);
|
||||||
|
|
||||||
_questionInfos.Add(new QuestionInfo(i + 1, questionVisual[_random.Next(questionVisual.Count)], tmp, answer));
|
_questionInfos.Add(new QuestionInfo(i + 1, questionVisual[_random.Next(questionVisual.Count)], tmp, answer));
|
||||||
correctAnswer[i] = tmp[_random.Next(amount)];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetAnswerAtIndex(int index) => correctAnswer[index];
|
public string GetAnswerAtIndex(int index, float successRate) {
|
||||||
|
if(_random.Next(100) <= successRate * 100)
|
||||||
|
return _questionInfos[index].Answer;
|
||||||
|
return _questionInfos[index].Choices[_random.Next(_questionInfos[index].Count)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetResultPercent(string[] answer)
|
||||||
|
{
|
||||||
|
float succeed = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < answer.Length; i++)
|
||||||
|
if (answer[i] == _questionInfos[i].Answer)
|
||||||
|
succeed++;
|
||||||
|
|
||||||
|
return succeed / questionAmount * 100;
|
||||||
|
}
|
||||||
|
|
||||||
public List<QuestionInfo> QuestionInfos => _questionInfos;
|
public List<QuestionInfo> QuestionInfos => _questionInfos;
|
||||||
public int QuestionAmount => questionAmount;
|
public int QuestionAmount => questionAmount;
|
||||||
|
|||||||
@ -11,6 +11,8 @@ namespace GameOff.Peasant
|
|||||||
[SerializeField] private float initTime = 20f;
|
[SerializeField] private float initTime = 20f;
|
||||||
[SerializeField] private float minTimePerQuestion = 5f;
|
[SerializeField] private float minTimePerQuestion = 5f;
|
||||||
[SerializeField] private float maxTimePerQuestion = 18f;
|
[SerializeField] private float maxTimePerQuestion = 18f;
|
||||||
|
[Range(0, 1)]
|
||||||
|
[SerializeField] private float successRate = 0.75f;
|
||||||
|
|
||||||
private int _indexQuestion;
|
private int _indexQuestion;
|
||||||
private float _answerTimer;
|
private float _answerTimer;
|
||||||
@ -29,12 +31,15 @@ namespace GameOff.Peasant
|
|||||||
|
|
||||||
if (_answerTimer <= 0)
|
if (_answerTimer <= 0)
|
||||||
{
|
{
|
||||||
answers[_indexQuestion] = QuizHandler.Instance.GetAnswerAtIndex(_indexQuestion);
|
answers[_indexQuestion] = QuizHandler.Instance.GetAnswerAtIndex(_indexQuestion, successRate);
|
||||||
_answerTimer = RandomQuestionTimer();
|
_answerTimer = RandomQuestionTimer();
|
||||||
_indexQuestion++;
|
_indexQuestion++;
|
||||||
|
|
||||||
if (_indexQuestion >= answers.Length)
|
if (_indexQuestion >= answers.Length)
|
||||||
|
{
|
||||||
|
Debug.Log($"{name}: {QuizHandler.Instance.GetResultPercent(answers)}%");
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,5 +17,7 @@ namespace GameOff.Quiz
|
|||||||
Choices = choices;
|
Choices = choices;
|
||||||
Answer = answer;
|
Answer = answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Count => Choices.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user