- 创建维修案例1/2的英/法/俄翻译版XML文件 - TeacherMainPanel: 根据语言选择对应翻译版XML下发 - StudentSub3Panel: 所有InjectOperateMsg改为InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalizedWithTime方法 - LocalizationManager: 修复LocalizeOperateMsg双重格式化bug - LocalizationManager: 新增维修步骤模板/拆卸/安装翻译条目
425 lines
4.5 KiB
C#
425 lines
4.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DevelopEngine;
|
|
using System;
|
|
|
|
/// <summary>
|
|
/// 学员操作记录类 用户收集各类 科目结束时上传回教员端
|
|
/// </summary>
|
|
public class StudentOperateRecorder : Singleton<StudentOperateRecorder>
|
|
{
|
|
private NetAnswerSheet resultMsg;
|
|
|
|
DateTime startLearingTime;
|
|
///设置科目 并初始化存储类 每次设置科目时自动清空之前的记录
|
|
public void SetSubName(NetSubNameEnum netSubName)
|
|
{
|
|
resultMsg = new NetAnswerSheet();
|
|
resultMsg.subName = netSubName;
|
|
resultMsg.errors = new List<string>();
|
|
resultMsg.deductMsg = new XDictionary<string, float>();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 开始计时 每次训练场景加载完成开始计时 完成训练获取该数据时根据该数据计算用时
|
|
/// </summary>
|
|
public void StartTiming()
|
|
{
|
|
startLearingTime = DateTime.Now;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入一条操作记录信息
|
|
/// </summary>
|
|
/// <param name="msg">待记录的信息</param>
|
|
/// <param name="addTime">是否同时记录时间</param>
|
|
public void InjectOperateMsg(string msg, bool addTime = false)
|
|
{
|
|
if (resultMsg.errors == null)
|
|
{
|
|
Debug.LogError("未设置科目进行初始化");
|
|
return;
|
|
}
|
|
|
|
if (addTime)//添加信息存入时的相对时间
|
|
{
|
|
msg = $"{GetTime()}:{msg}";
|
|
}
|
|
resultMsg.errors.Add(msg);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 记录一条本地化操作消息(存储为 key + 参数格式,显示时翻译)
|
|
/// </summary>
|
|
public void InjectOperateMsgLocalized(string key, params object[] args)
|
|
{
|
|
if (resultMsg.errors == null)
|
|
{
|
|
Debug.LogError("未设置科目进行初始化");
|
|
return;
|
|
}
|
|
string stored = "\x01" + key;
|
|
if (args != null)
|
|
{
|
|
for (int i = 0; i < args.Length; i++)
|
|
stored += "\x02" + (args[i] == null ? "" : args[i].ToString());
|
|
}
|
|
resultMsg.errors.Add(stored);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 记录一条带时间前缀的本地化操作消息
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void InjectOperateMsgLocalizedWithTime(string key, params object[] args)
|
|
{
|
|
if (resultMsg.errors == null)
|
|
{
|
|
Debug.LogError("未设置科目进行初始化");
|
|
return;
|
|
}
|
|
string stored = "\x01{0}:\x02" + GetTime() + "\x02" + key;
|
|
if (args != null)
|
|
{
|
|
for (int i = 0; i < args.Length; i++)
|
|
stored += "\x02" + (args[i] == null ? "" : args[i].ToString());
|
|
}
|
|
resultMsg.errors.Add(stored);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 记录每个扣分项
|
|
/// </summary>
|
|
/// <param name="score">扣除分数</param>
|
|
/// <param name="factors">扣分因素 后期需要调整权重的部分 不需要调整的可为空</param>
|
|
public void InjectDecScore(float score, string factors)
|
|
{
|
|
if (score == 0) return;//不扣分的不计入
|
|
if (!string.IsNullOrEmpty(factors)) //需要记录扣分因素的
|
|
{
|
|
if (resultMsg.deductMsg.ContainsKey(factors))
|
|
{
|
|
resultMsg.deductMsg[factors] += score;//同因素扣分时 累加
|
|
}
|
|
else
|
|
{
|
|
resultMsg.deductMsg[factors] = score;//新的扣分因素 直接记录
|
|
}
|
|
}
|
|
resultMsg.score += score;//扣除的分数累加起来
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 记录转运时间
|
|
/// </summary>
|
|
public void InjectTransportTime(int time)
|
|
{
|
|
resultMsg.transportTime = time;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取上传消息
|
|
/// </summary>
|
|
public NetAnswerSheet GetResultMsg()
|
|
{
|
|
resultMsg.totleTime = ((int)(DateTime.Now - startLearingTime).TotalSeconds).ToString();
|
|
return resultMsg;
|
|
}
|
|
|
|
//获取当前时间距离科目开始时刻的时长
|
|
private string GetTime()
|
|
{
|
|
TimeSpan ts = DateTime.Now - startLearingTime;
|
|
if (ts.Hours > 0)
|
|
return $"{ts.Hours}小时{ts.Minutes}分{ts.Seconds}秒";
|
|
else
|
|
return $"{ts.Minutes}分:{ts.Seconds}秒";
|
|
}
|
|
}
|