|
@@ -29,17 +29,17 @@ public class MathQuizManager : MonoBehaviour
|
|
private Vector3 lastEnemyPos;
|
|
private Vector3 lastEnemyPos;
|
|
private int deathCount = 0;
|
|
private int deathCount = 0;
|
|
|
|
|
|
- void Start() { NewProblem(); UpdateCoin(); }
|
|
|
|
|
|
+ void Start() { NewProblem(); UpdateCoin(); ShowQuizUI(true); }
|
|
|
|
|
|
void NewProblem()
|
|
void NewProblem()
|
|
{
|
|
{
|
|
int a = Random.Range(1, 11), b = Random.Range(1, 11);
|
|
int a = Random.Range(1, 11), b = Random.Range(1, 11);
|
|
- if (Random.value < 0.5f) // 加法
|
|
|
|
|
|
+ if (Random.value < 0.5f)
|
|
{
|
|
{
|
|
currentAnswer = a + b;
|
|
currentAnswer = a + b;
|
|
questionText.text = $"{a} + {b} = ?";
|
|
questionText.text = $"{a} + {b} = ?";
|
|
}
|
|
}
|
|
- else // 减法
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
if (b > a) (a, b) = (b, a);
|
|
if (b > a) (a, b) = (b, a);
|
|
currentAnswer = a - b;
|
|
currentAnswer = a - b;
|
|
@@ -123,7 +123,6 @@ public class MathQuizManager : MonoBehaviour
|
|
{
|
|
{
|
|
Destroy(obj);
|
|
Destroy(obj);
|
|
}
|
|
}
|
|
- // 新手引导
|
|
|
|
if (!PlayerPrefs.HasKey("FirstQuizTutorial"))
|
|
if (!PlayerPrefs.HasKey("FirstQuizTutorial"))
|
|
{
|
|
{
|
|
PlayerPrefs.SetInt("FirstQuizTutorial", 1);
|
|
PlayerPrefs.SetInt("FirstQuizTutorial", 1);
|
|
@@ -141,4 +140,12 @@ public class MathQuizManager : MonoBehaviour
|
|
if (oldest) Destroy(oldest.gameObject);
|
|
if (oldest) Destroy(oldest.gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 新增:控制题目和答案的显示/隐藏
|
|
|
|
+ public void ShowQuizUI(bool show)
|
|
|
|
+ {
|
|
|
|
+ if (questionText) questionText.gameObject.SetActive(show);
|
|
|
|
+ foreach (var a in answers)
|
|
|
|
+ if (a && a.gameObject) a.gameObject.SetActive(show);
|
|
|
|
+ }
|
|
}
|
|
}
|