using System.Collections.Generic; using MotionFramework; using UnityEngine; using UnityEngine.UI; namespace DefaultNamespace.ProcessMode { [ScriptDescription("流程模式管理器")] public class AnimationProcessManager : MonoBehaviour { private Dictionary processes; // 存储不同类型流程的字典 public ProcessMode currentMode; // 当前模式 private int currentStepIndex; // 当前步骤索引 private ProcessUIManager uiManager; // 引用UIManager实例 /// /// 构造函数 /// /// UIManager实例 public AnimationProcessManager(ProcessUIManager uiManager) { this.uiManager = uiManager; processes = new Dictionary(); InitializeProcesses(); // 初始化流程 currentStepIndex = 0; } /// /// 初始化所有流程 /// private void InitializeProcesses() { AddProcess("Teaching"); // 添加教学流程 AddProcess("Training"); // 添加培训流程 AddProcess("Practice"); // 添加练习流程 AddProcess("Assessment"); // 添加考核流程 } /// /// 添加一个新的流程 /// /// 流程类型 public void AddProcess(string type) { if (!processes.ContainsKey(type)) { processes[type] = new AnimationProcess(type); } } /// /// 向指定类型的流程中添加步骤 /// /// 流程类型 /// 要添加的步骤 public void AddStepToProcess(string type, AnimationStep step) { if (processes.ContainsKey(type)) { processes[type].AddStep(step); } } /// /// 获取指定类型流程的总评分 /// /// 流程类型 /// 总评分 public float GetTotalScoreForProcess(string type) { if (processes.ContainsKey(type)) { return processes[type].CalculateTotalScore(); } return 0; } /// /// 处理用户点击事件 /// /// 被点击的对象 public void HandleClick(GameObject clickedObject) { string type = currentMode.ToString(); if (processes.ContainsKey(type)) { AnimationProcess process = processes[type]; if (currentStepIndex < process.Steps.Count) { AnimationStep step = process.Steps[currentStepIndex]; if (step.CorrectObject == clickedObject) { step.PlayAnimation(); switch (currentMode) { case ProcessMode.Teaching: uiManager.HighlightNextStep(step); // 高亮下一个步骤 break; case ProcessMode.Training: uiManager.ShowTrainingStep(step); // 显示培训步骤 break; case ProcessMode.Practice: uiManager.ShowPracticeStep(step); // 显示练习步骤 break; case ProcessMode.Assessment: // 无提示 break; } currentStepIndex++; } else { Debug.Log("Incorrect object clicked."); } } } } } }