| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- using ChivaXR;
- using QFramework;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using System.ComponentModel;
- using I2.Loc;
- using System.Globalization;
- public enum OperationMode
- {
- /// <summary>
- /// 学习模式
- /// </summary>
- [LabelText("学习模式")]
- Learn,
- /// <summary>
- /// 练习模式
- /// </summary>
- [LabelText("练习模式")]
- Practice,
- /// <summary>
- /// 考试模式
- /// </summary>
- [LabelText("考核模式")]
- Exam,
- /// <summary>
- /// 闯关模式
- /// </summary>
- [LabelText("闯关模式")]
- Challenge,
- /// <summary>
- /// 自由练习
- /// </summary>
- [LabelText("自由练习模式")]
- FreeParctice,
- /// <summary>
- /// 自由考核
- /// </summary>
- [LabelText("自由考核模式")]
- FreeExam,
- [LabelText("默认空模式")]
- None
- }
- public class OperateSetting : MonoSingleton<OperateSetting>
- {
- [LabelText("需要加载的检修配置表格名称")]
- public string m_CourseName;
- [LabelText("是否打开标题界面")]
- public bool m_ActiveTitlePanel = true;
- /// <summary>
- /// 设置操作模式
- /// </summary>
- [LabelText("设置操作模式")]
- public OperationMode m_CurrentOperationMode = OperationMode.Practice;
- [LabelText("考试时间")]
- public int examTime = 20;
- [LabelText("最大容错次数")]
- public int maxErrorCount = 30;
- public ToolPackUILogic ToolPackUILogic;
- /// <summary>
- /// 工具包中的工具
- /// </summary>
- [HideInInspector]
- public List<ToolConfig> m_ToolKitToolConfigs;
- /// <summary>
- /// 当前步骤正确的工具名称
- /// </summary>
- public List<string> m_CurrentStepRightToolNames;
- private PC_OperatePanel m_OperatePanel;
- /// <summary>
- /// 是否开启题库
- /// </summary>
- [HideInInspector]
- public bool isOpenQuestion=true;
- /// <summary>
- /// 是否开启检查模式
- /// </summary>
- [HideInInspector]
- public bool isOpenCheck = false;
- private List<QuestionInfo> m_QuestionList=new List<QuestionInfo>();
- #region 本地化语言
- public bool useLocalization = false;
- public string en_courseName;
- /// <summary>
- /// 课程数据多语言初始化
- /// </summary>
- public void InitCourseLocalization()
- {
- StepListProxy m_StepListProxy = DAL.Instance.Get<StepListProxy>();
- List<OperationStepDataInfo> tmpStepListInfos = m_StepListProxy.ReadStepMsgInfoFromTable(m_CourseName);
- List<string[]> courseLocalization = new List<string[]>();
- courseLocalization.Add(new string[] { "Key", "Type", "Desc", "Chinese", "English [en-US]" });
- for (int i = 0; i < tmpStepListInfos.Count; i++)
- {
- List<string> tempLocalizationTerm = new List<string>();
- //parentStep;
- tempLocalizationTerm.Add(tmpStepListInfos[i].id + "parentStepName");
- tempLocalizationTerm.Add("Text");
- tempLocalizationTerm.Add("");
- tempLocalizationTerm.Add(tmpStepListInfos[i].parentStepName);
- tempLocalizationTerm.Add(tmpStepListInfos[i].en_parentStepName);
- courseLocalization.Add(tempLocalizationTerm.ToArray());
- //StepName
- tempLocalizationTerm.Clear();
- tempLocalizationTerm.Add(tmpStepListInfos[i].id + "stepName");
- tempLocalizationTerm.Add("Text");
- tempLocalizationTerm.Add("");
- tempLocalizationTerm.Add(tmpStepListInfos[i].stepName);
- tempLocalizationTerm.Add(tmpStepListInfos[i].en_stepName);
- courseLocalization.Add(tempLocalizationTerm.ToArray());
- //stepDescr
- tempLocalizationTerm.Clear();
- tempLocalizationTerm.Add(tmpStepListInfos[i].id + "stepDescr");
- tempLocalizationTerm.Add("Text");
- tempLocalizationTerm.Add("");
- tempLocalizationTerm.Add(tmpStepListInfos[i].stepDescr);
- tempLocalizationTerm.Add(tmpStepListInfos[i].en_stepDescr);
- courseLocalization.Add(tempLocalizationTerm.ToArray());
- //stepMattersNeedingAttention
- tempLocalizationTerm.Clear();
- tempLocalizationTerm.Add(tmpStepListInfos[i].id + "stepMattersNeedingAttention");
- tempLocalizationTerm.Add("Text");
- tempLocalizationTerm.Add("");
- tempLocalizationTerm.Add(tmpStepListInfos[i].stepMattersNeedingAttention);
- tempLocalizationTerm.Add(tmpStepListInfos[i].en_stepMattersNeedingAttention);
- courseLocalization.Add(tempLocalizationTerm.ToArray());
- }
- LanguageSource languageSource = this.gameObject.AddComponent<LanguageSource>();
- languageSource.SourceData.Import_CSV(string.Empty, courseLocalization, eSpreadsheetUpdateMode.Replace);
- TermData data = languageSource.SourceData.AddTerm(ScriptTerms.operatepanel.coursetitle);
- data.Languages[0] = m_CourseName;
- data.Languages[1] = en_courseName;
- LocalizationManager.LocalizeAll();
- }
- /// <summary>
- /// 获取相机配置数据
- /// </summary>
- /// <returns></returns>
- private SettingInfo GetSettingInfo()
- {
- // 拼接文件基本路径
- string filePath = PathHelper.CombineFilePath(PathHelper.m_ReadOnlyPath,
- "Json",
- "SettingInfo.json");
- string fileData = FileHelper.GetAllDataInfo(filePath);
- SettingInfo config = JsonUtility.FromJson<SettingInfo>(fileData);
- return config == null ? null : config;
- }
- #endregion
- private void Awake()
- {
- ResKit.Init();
- if (GlobalData.m_CurrentOperationMode != OperationMode.None)
- {
- m_CurrentOperationMode = GlobalData.m_CurrentOperationMode;
- }
- ParseParameters();
- #region 本地化语言
- if (useLocalization)
- {
- LocalizationConfig.localization = true;
- InitCourseLocalization();
- }
- InitGameSetting();
- #endregion
- if (!string.IsNullOrEmpty(m_CourseName))
- {
- LoadCourse(m_CourseName);
- }
-
- InitQuestionInfo();
- InitOperationMode();
- ProcessManagement.Instance.awakePlay = false;
- }
- private void ParseParameters()
- {
- string[] args = System.Environment.GetCommandLineArgs();
- ///临时测试数据
- string para = "b0e6098c7b65e46928b38e09a506234abb0b9a0/闭式水泵整体拆装/访客/40008013900/127.0.0.1:15157/Exam/测试参数/这是第条参数/这是总平台参数";
- string[] tmpArgs = para.Split('/');
- // 文件各种:手机号/课程名/模式/地址
- string tmpPhoneNumber = "";
- string tmpCourseName = "";
- string tmpMode = "";
- UserProxy userProxy = DAL.Instance.Get<UserProxy>();
- userProxy.userInfo.userName = tmpArgs[2];
- userProxy.userInfo.phoneNumber = tmpArgs[3];
- Debug.Log(tmpArgs.Length + "-asd-" + args[1]);
- if (tmpArgs.Length < 4)
- {
- #region 电专平台接口解析
- // 文件各种:手机号/课程名/模式/地址
- tmpPhoneNumber = tmpArgs[0];
- tmpCourseName = tmpArgs[1];
- tmpMode = tmpArgs[2];
- //if (tmpArgs.Length > 3)
- //{
- // string tmpAddress = tmpArgs[3];
- // //GrpcChannelContronller.Instance.StartClient(tmpAddress);
- // GetInfoaboutSpecifiedUser(tmpPhoneNumber);
- //}
- #endregion
- }
- else
- {
- #region 通用平台接口解析
- tmpPhoneNumber = tmpArgs[5];
- tmpCourseName = tmpArgs[1];
- tmpMode = tmpArgs[2];
- GrpcChannelContronller.Instance.StartClient(tmpArgs[4]);
- tmpCourseName = tmpArgs[1];
- GlobalConfig.m_SelectDevice = tmpCourseName;
- switch (tmpArgs[5])
- {
- case "Learn":
- m_CurrentOperationMode = OperationMode.Learn;
- break;
- case "Practice":
- m_CurrentOperationMode = OperationMode.Practice;
- break;
- case "Exam":
- m_CurrentOperationMode = OperationMode.Exam;
- break;
- default:
- tmpMode = "学习";
- break;
- }
- Debug.Log(tmpCourseName + " --" + tmpMode);
- #endregion
- }
- }
- /// <summary>
- /// 初始化游戏设置
- /// </summary>
- private void InitGameSetting()
- {
- SettingInfo settingInfo = GetSettingInfo();
- if (LocalizationManager.HasLanguage(settingInfo.language))
- {
- LocalizationManager.CurrentLanguage = settingInfo.language;
- }
- RoamCameraController.Instance.TranslateSpeed = settingInfo.keySpeedValue * 20;
- RoamCameraController.Instance.MouseScrollMoveSpeed = settingInfo.mouseSpeedValue * 2;
- }
- /// <summary>
- /// 初始化题库
- /// </summary>
- private void InitQuestionInfo()
- {
- m_QuestionList = DAL.Instance.Get<QuestionProxy>().ReadStepMsgInfoFromTable(OperateSetting.Instance.m_CourseName + "_题库");
- }
- public QuestionInfo GetQuestionInfo(int stepID)
- {
- QuestionInfo tmpQuestionInfo = m_QuestionList.Find(t => t.StepId == stepID.ToString());
- return tmpQuestionInfo;
- }
- private void Start()
- {
- if (CameraRayCastManager.Instance != null) Debug.Log("<color=green>检测已开启</color>");
- }
- //启动流程
- public void StartProcess()
- {
- //加载考试时长及错误
- if (m_CurrentOperationMode == OperationMode.Exam|| m_CurrentOperationMode == OperationMode.FreeExam)
- {
- ExamManagerForPC tmpExamManagerForPC = this.gameObject.AddComponent<ExamManagerForPC>();
- tmpExamManagerForPC.examTime = this.examTime;
- tmpExamManagerForPC.m_maxErrorCount = maxErrorCount;
- UIKit.GetPanel<PC_OperatePanel>().StartExam(examTime);
- UIKit.GetPanel<PC_OperatePanel>().ExamInfo.ErrorCount.text = "x" + maxErrorCount.ToString();
- }
- else
- {
- UIKit.GetPanel<PC_OperatePanel>().StartGame();
- }
- InitOperationMode();
- if (m_CurrentOperationMode == OperationMode.FreeParctice || m_CurrentOperationMode == OperationMode.FreeExam)
- {
- FreeProcessManagement.Instance.ActiveProcess();
- //关闭自动执行步骤
- ProcessManagement.Instance.autoEnterNextProcess = false;
- }
- else
- {
- ProcessManagement.Instance.ActiveCurrentProcess();
- }
- }
- public void InitOperationMode()
- {
- if (m_CurrentOperationMode != OperationMode.FreeParctice&&m_CurrentOperationMode!=OperationMode.FreeExam)
- {
- foreach (var item in ProcessManagement.Instance.processes)
- {
- item.preprocess = item.GetOrAddComponent<Preprocess_VoiceAndCamera>();
- }
- }
- switch (m_CurrentOperationMode)
- {
- case OperationMode.Learn:
- Preprocess_VoiceAndCamera.playView = true;
- Preprocess_VoiceAndCamera.WaitAudioFinishedToExit = true;
- Preprocess_VoiceAndCamera.WaitViewFinishedToExit = true;
- Preprocess_VoiceAndCamera.ViewMoveTime = 2;
- break;
- case OperationMode.Practice:
- Preprocess_VoiceAndCamera.playView = false;
- Preprocess_VoiceAndCamera.WaitAudioFinishedToExit = false;
- Preprocess_VoiceAndCamera.WaitViewFinishedToExit = false;
- break;
- case OperationMode.Exam:
- Preprocess_VoiceAndCamera.playView = false;
- Preprocess_VoiceAndCamera.playAudio = false;
- Preprocess_VoiceAndCamera.WaitAudioFinishedToExit = false;
- Preprocess_VoiceAndCamera.WaitViewFinishedToExit = false;
- break;
- case OperationMode.FreeParctice:
- case OperationMode.FreeExam:
- Preprocess_VoiceAndCamera.playView = false;
- Preprocess_VoiceAndCamera.playAudio = false;
- Preprocess_VoiceAndCamera.WaitAudioFinishedToExit = false;
- Preprocess_VoiceAndCamera.WaitViewFinishedToExit = false;
- FreeProcessManagement.Instance.InitFreeProcess(m_CourseName);
- break;
- case OperationMode.Challenge:
- break;
- default:
- break;
- }
- }
- public void LoadCourse(string name)
- {
- if (m_CurrentOperationMode == OperationMode.Exam)
- {
- ExamSetProxy tmpProxy = DAL.Instance.Get<ExamSetProxy>();
- ExamSetInfo tmpExamInfo = tmpProxy.GetExamSetInfoByCourseName(name);
- if (tmpExamInfo != null)
- {
- maxErrorCount = int.Parse(tmpExamInfo.maxErrorCount);
- examTime = int.Parse(tmpExamInfo.examTime);
- }
- }
- UIKit.OpenPanel<ToolDisplayForm>();
- UIKit.OpenPanel<LogSystemForm>();
- m_OperatePanel = UIKit.OpenPanel<PC_OperatePanel>(
- new PC_OperatePanelData
- {
- courseName = m_CourseName,
- OpenTitleBg = m_ActiveTitlePanel
- });
- if (ProcessManagement.Instance)
- {
- ProcessManagement.Instance.EnterProcessEvent += m_OperatePanel.OnEnterProcessByStepID;
- ProcessManagement.Instance.processElementDisActiveEvent += m_OperatePanel.OnPrcessElementDisActive;
- ProcessManagement.Instance.processFinishEvent += ProcessEndPanel;
- }
- UIKit.OpenPanel<ArrowTipsPanel>();
- }
- /// <summary>
- /// 完成所有流程后打开练习结束界面/成绩单界面
- /// </summary>
- public void ProcessEndPanel()
- {
- switch (m_CurrentOperationMode)
- {
- case OperationMode.Practice:
- m_OperatePanel.PracticeEnd();
- break;
- case OperationMode.Exam:
- //ExamManagerForPC.instance.ExamFinish();
- //operatePanel.ExamEnd();
- break;
- }
- }
- private void OnDisable()
- {
- if (ProcessManagement.Instance)
- {
- ProcessManagement.Instance.EnterProcessEvent -= m_OperatePanel.OnEnterProcessByStepID;
- ProcessManagement.Instance.processElementDisActiveEvent -= m_OperatePanel.OnPrcessElementDisActive;
- ProcessManagement.Instance.processFinishEvent -= ProcessEndPanel;
- }
- }
- }
|