- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
228 lines
6.8 KiB
Plaintext
228 lines
6.8 KiB
Plaintext
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DevelopEngine;
|
|
using System;
|
|
using UnityEngine.Events;
|
|
/// <summary>
|
|
/// 流程管理 管理流程中所有的步骤 为步骤规划前置和后置关系 提供流程启动入口 提供流程反转功能
|
|
/// </summary>
|
|
public class ProcessManager : Singleton<ProcessManager>
|
|
{
|
|
ProcessEnum currentProcess;
|
|
Dictionary<string, StepNodeBase> stepNodesDic = new Dictionary< string,StepNodeBase>();
|
|
|
|
List<string> finishedStep= new List<string>();
|
|
bool planningOver;
|
|
string lastStep;//最终步骤名称
|
|
|
|
UnityAction<ProcessEnum> processOverEvent;
|
|
/// <summary>
|
|
/// 添加待管理的步骤
|
|
/// </summary>
|
|
/// <param name="stepNode"></param>
|
|
public void AddStep(StepNodeBase stepNode)
|
|
{
|
|
if (!stepNodesDic.ContainsKey(stepNode.NodeName))
|
|
{
|
|
stepNodesDic.Add(stepNode.NodeName, stepNode);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("存在名称重复的流程节点,无法加入管理队列!");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始流程
|
|
/// </summary>
|
|
public void StartProcess(UnityAction<ProcessEnum> processOver=null)
|
|
{
|
|
this.processOverEvent = processOver;
|
|
finishedStep = new List<string>();
|
|
if (planningOver)
|
|
{
|
|
Debug.Log($"启动{currentProcess.ToString()}流程");
|
|
|
|
foreach (var item in stepNodesDic)//先设置流程 后启动流程 避免某些节点激活时自动完成影响后续节点
|
|
{
|
|
item.Value.SetProcess(currentProcess);
|
|
}
|
|
|
|
foreach (var item in stepNodesDic)
|
|
{
|
|
item.Value.ProcessStart();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("未完成流程规划 无法开始");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清空流程
|
|
/// </summary>
|
|
public void ClearProcess()
|
|
{
|
|
stepNodesDic.Clear();
|
|
planningOver = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置流程类型
|
|
/// </summary>
|
|
/// <param name="processName"> 拆卸 OR 装配</param>
|
|
public void SetProcess(ProcessEnum processName)
|
|
{
|
|
currentProcess = processName;
|
|
switch (processName)
|
|
{
|
|
case ProcessEnum.teardown:
|
|
PlanningTeardownStep();
|
|
break;
|
|
case ProcessEnum.assemble:
|
|
PlanningAssembleStep();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
//规划一体化装置拆卸流程
|
|
protected void PlanningTeardownStep()
|
|
{
|
|
PlanningNodes("三角木","千斤顶");
|
|
PlanningNodes("三角木", "制动螺栓");
|
|
PlanningNodes("千斤顶", "车轮");
|
|
PlanningNodes("千斤顶", "车轮螺栓组");
|
|
PlanningNodes("制动螺栓", "车轮");
|
|
PlanningNodes("制动螺栓", "车轮螺栓组");
|
|
PlanningNodes("车轮螺栓组", "一体化装置");
|
|
|
|
|
|
//PlanningNodes("千斤顶", "车轮螺栓A");
|
|
//PlanningNodes("千斤顶", "车轮螺栓B");
|
|
//PlanningNodes("千斤顶", "车轮螺栓C");
|
|
//PlanningNodes("千斤顶", "车轮螺栓D");
|
|
//PlanningNodes("制动螺栓", "车轮螺栓A");
|
|
//PlanningNodes("制动螺栓", "车轮螺栓B");
|
|
//PlanningNodes("制动螺栓", "车轮螺栓C");
|
|
//PlanningNodes("制动螺栓", "车轮螺栓D");
|
|
//PlanningNodes("车轮螺栓A", "一体化装置");
|
|
//PlanningNodes("车轮螺栓B", "一体化装置");
|
|
//PlanningNodes("车轮螺栓C", "一体化装置");
|
|
//PlanningNodes("车轮螺栓D", "一体化装置");
|
|
|
|
lastStep = "一体化装置";
|
|
planningOver = true;
|
|
}
|
|
|
|
|
|
//规划规划一体化装置安装流程
|
|
protected void PlanningAssembleStep()
|
|
{
|
|
if (/*currentProcess == ProcessEnum.teardown &&*/ planningOver)//已经规划完拆卸流程
|
|
{
|
|
//翻转流程
|
|
ReversalProcess();
|
|
lastStep = "三角木";
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("安装流程需手动规划");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 规划两个节点关系
|
|
/// </summary>
|
|
/// <param name="preconditionNodeName">前置节点名称</param>
|
|
/// <param name="postpositionNodeName">后置节点名称</param>
|
|
protected void PlanningNodes(string preconditionNodeName,string postpositionNodeName)
|
|
{
|
|
if (!stepNodesDic.ContainsKey(preconditionNodeName))
|
|
{
|
|
Debug.LogError($"流程种不存在{preconditionNodeName}节点 无法规划节点关系");
|
|
return;
|
|
}
|
|
if (!stepNodesDic.ContainsKey(postpositionNodeName))
|
|
{
|
|
Debug.LogError($"流程种不存在{postpositionNodeName}节点 无法规划节点关系");
|
|
return;
|
|
}
|
|
stepNodesDic[preconditionNodeName].postpositionNodes.Add( stepNodesDic[postpositionNodeName]);
|
|
stepNodesDic[postpositionNodeName].preconditionNodes.Add(stepNodesDic[preconditionNodeName]);
|
|
}
|
|
|
|
//记录完成节点
|
|
public void RecordFinisedStep(string finisedStep)
|
|
{
|
|
finishedStep.Add(finisedStep);
|
|
if (finisedStep == lastStep)//
|
|
{
|
|
processOverEvent?.Invoke(currentProcess);
|
|
}
|
|
}
|
|
|
|
//流程翻转
|
|
protected void ReversalProcess()
|
|
{
|
|
Debug.Log("反转流程");
|
|
foreach (var item in stepNodesDic)//遍历所有的步骤节点 退出节点激活状态 调换前置、后置步骤关系
|
|
{
|
|
List<StepNodeBase> tempSteps = item.Value.postpositionNodes;//
|
|
item.Value.ProcessStop();
|
|
item.Value.postpositionNodes = item.Value.preconditionNodes;
|
|
item.Value.preconditionNodes = tempSteps;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加特定步骤的完成监听事件
|
|
/// </summary>
|
|
public void RegisterStepFinishedEvent( string stepName,UnityAction stepFinised)
|
|
{
|
|
if (stepNodesDic.ContainsKey(stepName))
|
|
{
|
|
stepNodesDic[stepName].NodeFinished += stepFinised;
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError($"当前流程不存在{stepName}步骤,无法注册结束事件");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加特定步骤的完成监听事件
|
|
/// </summary>
|
|
public void RemoveStepFinishedEvent(string stepName, UnityAction stepFinised)
|
|
{
|
|
if (stepNodesDic.ContainsKey(stepName))
|
|
{
|
|
stepNodesDic[stepName].NodeFinished -= stepFinised;
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError($"当前流程不存在{stepName}步骤,无法注销结束事件");
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
//流程名称
|
|
public enum ProcessEnum
|
|
{
|
|
/// <summary>
|
|
/// 拆卸流程
|
|
/// </summary>
|
|
teardown,
|
|
|
|
/// <summary>
|
|
/// 组装流程
|
|
/// </summary>
|
|
assemble,
|
|
}
|
|
|
|
|