feat: MCP Unity 场景优化 — 完整交互体系搭建
- 删除重复 Ground - 创建 [Managers] 空物体,挂载 GameManager + StepManager + ExperimentFlowCoordinator + AudioManager - Main Camera 挂载 InteractionSystem - 伤者 InjectedPerson 下创建 5 个交互子物体 (InjuryVisual/Swelling/Pain/VitalSigns/Neuro) - 创建绑带位置、踝关节、衬垫、夹板位置等空物体 - 道具摆放到位:伤者(2,0.05,5) 施救者(3,0,5) 鞋(2.7,0.15,5.5) 绷带/夹板/急救箱在旁 - InjuryLeg Tag 修正,Ground Tag 修正 - 全部新脚本同步导入 (ExperimentTypes/StepData/ExperimentConfig/StepManager/GameManager/ExperimentFlowCoordinator/InteractionSystem/DraggableObject/HighlightEffect/UIManager/ExamPopup/ScoreDisplay/VideoController/AudioManager/CharacterAnimController/StepAnimationHandler) - 旧脚本 (ExperimentController/ConfigLoader/AnimationController/HUDController/VideoPlayerController/PopupSystem/ModeSelectionUI) 全部兼容修复或 stub - 编译通过,0 错误 - Canvas 挂载 UIManager
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