2026-06-24 02:33:48 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 实验结束后的结果展示面板。
|
|
|
|
|
|
/// 考核模式:显示加权成绩 + 错题分析列表(含每步得分/满分)。
|
|
|
|
|
|
/// 学习模式:显示注意事项。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class ScoreDisplay : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
[Header("面板根节点")]
|
|
|
|
|
|
[SerializeField] private GameObject _panelRoot;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("考核模式")]
|
|
|
|
|
|
[SerializeField] private GameObject _examResultRoot;
|
2026-06-24 02:44:58 +08:00
|
|
|
|
[SerializeField] private Text _scoreTitle;
|
|
|
|
|
|
[SerializeField] private Text _scoreValue;
|
2026-06-24 02:33:48 +08:00
|
|
|
|
[SerializeField] private Transform _analysisListParent;
|
|
|
|
|
|
[SerializeField] private GameObject _analysisItemPrefab;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("学习模式 - 注意事项")]
|
|
|
|
|
|
[SerializeField] private GameObject _notesRoot;
|
2026-06-24 02:44:58 +08:00
|
|
|
|
[SerializeField] private Text _notesText;
|
2026-06-24 02:33:48 +08:00
|
|
|
|
|
|
|
|
|
|
[Header("底部按钮")]
|
|
|
|
|
|
[SerializeField] private Button _confirmButton;
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly string NotesContent =
|
|
|
|
|
|
"1. 下肢损伤选择仰卧位;\n" +
|
|
|
|
|
|
"2. 骨折固定前后要脱掉鞋袜并检查下肢末梢循环、运动、感觉;\n" +
|
|
|
|
|
|
"3. 穿带子时应从健侧穿向伤侧;\n" +
|
|
|
|
|
|
"4. 骨折固定时先固定伤口的近心端,后固定远心端,再由上而下进行固定;\n" +
|
|
|
|
|
|
"5. 固定后尽可能抬高下肢。";
|
|
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
2026-06-24 02:44:58 +08:00
|
|
|
|
if (_confirmButton) _confirmButton.onClick.AddListener(OnConfirm);
|
2026-06-24 02:33:48 +08:00
|
|
|
|
if (_panelRoot != null) _panelRoot.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowExamScore()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_panelRoot != null) _panelRoot.SetActive(true);
|
|
|
|
|
|
if (_examResultRoot != null) _examResultRoot.SetActive(true);
|
|
|
|
|
|
if (_notesRoot != null) _notesRoot.SetActive(false);
|
|
|
|
|
|
|
|
|
|
|
|
var gm = GameManager.Instance;
|
|
|
|
|
|
if (gm == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
int score = gm.GetExamScoreRounded();
|
|
|
|
|
|
float pct = gm.GetExamPercentage();
|
|
|
|
|
|
if (_scoreTitle != null) _scoreTitle.text = "成绩显示栏";
|
2026-06-24 02:44:58 +08:00
|
|
|
|
if (_scoreValue != null) _scoreValue.text = "考试成绩:" + score + " 分(" + pct.ToString("F0") + "%)";
|
2026-06-24 02:33:48 +08:00
|
|
|
|
|
|
|
|
|
|
BuildAnalysisList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowNotesOnly()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_panelRoot != null) _panelRoot.SetActive(true);
|
|
|
|
|
|
if (_examResultRoot != null) _examResultRoot.SetActive(false);
|
|
|
|
|
|
if (_notesRoot != null) _notesRoot.SetActive(true);
|
|
|
|
|
|
|
|
|
|
|
|
if (_notesText != null) _notesText.text = NotesContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BuildAnalysisList()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_analysisListParent == null || _analysisItemPrefab == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Transform child in _analysisListParent)
|
|
|
|
|
|
Destroy(child.gameObject);
|
|
|
|
|
|
|
|
|
|
|
|
var gm = GameManager.Instance;
|
|
|
|
|
|
if (gm == null || gm.StepScores == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < gm.StepScores.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = Instantiate(_analysisItemPrefab, _analysisListParent);
|
2026-06-24 02:44:58 +08:00
|
|
|
|
var text = item.GetComponentInChildren<Text>();
|
2026-06-24 02:33:48 +08:00
|
|
|
|
if (text == null) continue;
|
|
|
|
|
|
|
|
|
|
|
|
float earned = gm.StepScores[i];
|
|
|
|
|
|
float max = gm.StepMaxScores[i];
|
|
|
|
|
|
bool fullScore = Mathf.Approximately(earned, max);
|
|
|
|
|
|
bool zeroScore = earned <= 0f;
|
|
|
|
|
|
|
|
|
|
|
|
string status;
|
|
|
|
|
|
if (fullScore) status = "<color=#00FF00>正确</color>";
|
|
|
|
|
|
else if (zeroScore) status = "<color=#FF0000>错误</color>";
|
2026-06-24 02:44:58 +08:00
|
|
|
|
else status = "<color=#FFAA00>部分正确</color>";
|
2026-06-24 02:33:48 +08:00
|
|
|
|
|
2026-06-24 02:44:58 +08:00
|
|
|
|
string scorePart = "(" + earned.ToString("F0") + "/" + max.ToString("F0") + " 分)";
|
2026-06-24 02:33:48 +08:00
|
|
|
|
string fbPart = (!fullScore && !string.IsNullOrEmpty(gm.StepFeedback[i]))
|
2026-06-24 02:44:58 +08:00
|
|
|
|
? ":" + gm.StepFeedback[i] : "";
|
2026-06-24 02:33:48 +08:00
|
|
|
|
|
2026-06-24 02:44:58 +08:00
|
|
|
|
text.text = "第" + (i + 1) + "题:" + status + " " + scorePart + fbPart;
|
2026-06-24 02:33:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnConfirm()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_panelRoot != null) _panelRoot.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|