using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; public class StepListProxy : DataProxy { public List m_StepMsgInfos; /// /// 表格名称 /// string m_TableName; /// /// 处理一级和二级对应关系 /// 注意:(此方法只适用于m_StepMsgInfos不为空的情况) /// /// OpDataInfo public Dictionary> ProcessingData() { Dictionary> tmpDicStepListInfos = new Dictionary>(); foreach (var item in m_StepMsgInfos) { if (!tmpDicStepListInfos.ContainsKey(item.parentStepName)) tmpDicStepListInfos.Add(item.parentStepName, new List()); tmpDicStepListInfos[item.parentStepName].Add(item); } return tmpDicStepListInfos; } /// /// 处理一级和二级对应关系 /// /// OpDataInfo public Dictionary> ProcessingData(List stepListInfos) { Dictionary> tmpDicStepListInfos = new Dictionary>(); foreach (var item in stepListInfos) { if (!tmpDicStepListInfos.ContainsKey(item.parentStepName)) tmpDicStepListInfos.Add(item.parentStepName, new List()); tmpDicStepListInfos[item.parentStepName].Add(item); } return tmpDicStepListInfos; } /// /// 根据id获取信息 /// public OperationStepDataInfo GetOpStepDataInfoById(int operationId) { return m_StepMsgInfos.Find(t => t.id == operationId.ToString()); } /// /// 通过步骤ID获取对应的二级信息 /// /// public List GetOneLevelAndSecondLevelOpStepDataInfoByOperationLevelId(int operationId) { OperationStepDataInfo tmpOperationInfo = m_StepMsgInfos.Find(t => t.id == operationId.ToString()); if (tmpOperationInfo != null) { return m_StepMsgInfos.FindAll(t => t.parentStepName == tmpOperationInfo.parentStepName); } return null; } /// /// 从Excel文件读取流程信息 /// /// 表明 /// 表头 /// public List ReadStepMsgInfoFromTable(string tableName) { m_TableName = tableName + GlobalConfig.excelSuffix; m_StepMsgInfos = new List(); string tmpPath = System.IO.Path.Combine(GlobalConfig.operateTablePath, m_TableName); m_StepMsgInfos = ExcelHelper.ReadInfoFromExcel(tmpPath, 1); return m_StepMsgInfos; } public OperationStepDataInfo GetOperationStepDataInfoById(int id) { return m_StepMsgInfos.Find(t => int.Parse(t.id) == id); } public void SetOperationCameraPoseById(int id, Vector3 position, Vector3 eulerAngles) { OperationStepDataInfo tmpInfo = m_StepMsgInfos.Find(t => int.Parse(t.id) == id); tmpInfo.position = LUtilitys.ParseString(position); tmpInfo.rotation = LUtilitys.ParseString(eulerAngles); } /// /// 保存当前数据 /// public void SaveOperation() { string tmpPath = Path.Combine(GlobalConfig.operateTablePath, m_TableName); ExcelHelper.WriteInfoToExcel(tmpPath, m_StepMsgInfos); } }