123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- 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,
- [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;
- [HideInInspector]
- public List<ToolConfig> m_ToolLibraryToolConfigs;
- /// <summary>
- /// 当前步骤正确的工具名称
- /// </summary>
- public List<string> m_CurrentStepRightToolNames;
- private PC_OperatePanel m_OperatePanel;
- #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;
- }
- #region 本地化语言
- if (useLocalization)
- {
- LocalizationConfig.localization = true;
- InitCourseLocalization();
- }
- InitGameSetting();
- #endregion
- if (!string.IsNullOrEmpty(m_CourseName))
- LoadCourse(m_CourseName);
- InitOperationMode();
- ProcessManagement.Instance.awakePlay = false;
- }
- /// <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;
- }
- private void Start()
- {
- if (CameraRayCastManager.Instance != null) Debug.Log("<color=green>检测已开启</color>");
- }
- //启动流程
- public void StartProcess()
- {
- //加载考试时长及错误
- if (m_CurrentOperationMode == OperationMode.Exam)
- {
- 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();
- ProcessManagement.Instance.ActiveCurrentProcess();
- }
- public void InitOperationMode()
- {
- 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.Challenge:
- break;
- default:
- break;
- }
- }
- public void LoadCourse(string name)
- {
- 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;
- }
- }
- }
|