feat: VFS 虚拟仿真实验核心框架 v2
- 加权评分系统:每步独立 ScoreWeight,满分 100,SequenceClick 按子项比例计分 - StepData 新增 DetailedContent(学习模式详细操作说明)和 SubStepCount - 伤情检查步骤扩展为 5 子项序列(视觉检查→肿胀→疼痛→生命体征→神经评估) - 夹板固定模式完整评分(选择夹板→放置衬垫→夹板固定→固定后检查) - Doc/ 文件夹归档三份文档:项目大纲、文案、评分标准 - README 更新评分权重表和夹板固定流程
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 全局单例管理器:持有当前实验的类型、模式、固定方式与加权分数。
|
||||
/// 挂在场景第一个 GameObject 上,设置 DontDestroyOnLoad。
|
||||
/// </summary>
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance { get; private set; }
|
||||
|
||||
[Header("当前实验设置(运行时赋值)")]
|
||||
public ExperimentType CurrentExperimentType = ExperimentType.FractureFixation;
|
||||
public ExperimentMode CurrentMode = ExperimentMode.Learn;
|
||||
public FixationMethod CurrentFixationMethod = FixationMethod.LimbFixation;
|
||||
|
||||
[Header("加权评分")]
|
||||
public float TotalWeightedScore; // 实际得分(加权累加)
|
||||
public float MaxWeightedScore = 100f; // 总分
|
||||
|
||||
[Header("考核记录")]
|
||||
public float[] StepScores; // 每步实际得分(含权重)
|
||||
public float[] StepMaxScores; // 每步满分(权重值)
|
||||
public string[] StepFeedback; // 每题错误反馈文本
|
||||
public bool[] StepCorrect; // 每题是否有任何得分
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>初始化考核记录数组</summary>
|
||||
public void InitExamRecord(int stepCount)
|
||||
{
|
||||
StepScores = new float[stepCount];
|
||||
StepMaxScores = new float[stepCount];
|
||||
StepFeedback = new string[stepCount];
|
||||
StepCorrect = new bool[stepCount];
|
||||
TotalWeightedScore = 0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录一个考核步骤的结果。
|
||||
/// proportion 为 0~1,表示得分比例(SequenceClick 类型部分正确时用到)。
|
||||
/// </summary>
|
||||
public void RecordExamResult(int stepIndex, float maxScore, float proportion, string feedback)
|
||||
{
|
||||
if (StepScores == null || stepIndex >= StepScores.Length) return;
|
||||
|
||||
StepMaxScores[stepIndex] = maxScore;
|
||||
float earned = maxScore * Mathf.Clamp01(proportion);
|
||||
StepScores[stepIndex] = earned;
|
||||
StepFeedback[stepIndex] = feedback;
|
||||
StepCorrect[stepIndex] = proportion > 0f;
|
||||
TotalWeightedScore += earned;
|
||||
}
|
||||
|
||||
/// <summary>按百分比返回考核分数</summary>
|
||||
public float GetExamPercentage()
|
||||
{
|
||||
if (MaxWeightedScore <= 0f) return 0f;
|
||||
return TotalWeightedScore / MaxWeightedScore * 100f;
|
||||
}
|
||||
|
||||
/// <summary>获取总分(整数)</summary>
|
||||
public int GetExamScoreRounded()
|
||||
{
|
||||
return Mathf.RoundToInt(TotalWeightedScore);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user