unityzgy/Assets/Scripts/UIScripts/Teacher/Mono/AppraiseWindow1.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

117 lines
3.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using XFramework;
using XFramework.Objects;
//科目1 科目2 训练使用的窗口
public class AppraiseWindow1 : AppraiseWindowBase
{
//显示评分
public Text text_score;
float transportScore;//转运时间评分 该评分根据教员端设定的最短时间计算
float weightScore;//受权重影响的指标评价总分数
float otherScore;//传回的评分中不受权重调节的部分 例如距离水源的距离 答题扣分等等
XDictionary<string, float> deductMsg;//转运时间之外的评估项和对应基础得分
XDictionary<string, float> deductWeight;//转运时间之外的评估项和对应权重
public Transform deductPointParent;//评价指标父物体 附带 Group组件 可以自动确定子物体的位置
//转运时间展示器
public TransportScoreCtrl timeScoreCtrl;
public override void SetResultMsg(NetAnswerSheet value, OnlineStudent onlineStudent)
{
base.SetResultMsg(value, onlineStudent);
CreatAppraisePoints(value.deductMsg);
otherScore = value.score- CalculateTotleScore();//计算不受权重影响的评分
transportScore = ShowTransportTime(value.transportTime);
ShowScore();
}
//创建评价指标 记录指标对应的权重值 权重范围为0-2
private void CreatAppraisePoints(XDictionary<string, float> deductMsg)
{
if (deductMsg == null)
return;
deductWeight = new XDictionary<string, float>();
this.deductMsg = deductMsg;
foreach (var item in deductMsg)
{
deductWeight[item.Key] = ResourcesCreater.InstantiatePrefab("评价指标", deductPointParent).GetComponent<AppraiseSliderCtrl>().InjectInitData(item.Key, WeightChanged);//记录当前因素对应的权重值
}
}
//权重变化
private void WeightChanged(string age0, float value)
{
deductWeight[age0] = value;
CalculateTotleScore();
}
/// <summary>
/// 显示转运用时
/// </summary>
private float ShowTransportTime(int time)
{
if (time == 0)//无效数据 不显示 非展开科目 或者展开科目展开未完成时为0
{
timeScoreCtrl.gameObject.SetActive(false);
return 0;
}
timeScoreCtrl.gameObject.SetActive(true);
return timeScoreCtrl.GetComponent<TransportScoreCtrl>().InjectTimeGetScore(time, TransportTimeScoreChanged);
}
//转运时间扣分 值发生变化
private void TransportTimeScoreChanged( float score)
{
transportScore = score;
ShowScore();
}
//计算受权重影响的评价指标
private float CalculateTotleScore()
{
weightScore = 0;
foreach (var item in deductMsg)
{
if (deductWeight.ContainsKey(item.Key))
{
weightScore += item.Value * deductWeight[item.Key];
}
else
{
weightScore += item.Value;
}
}
ShowScore();
return weightScore;
}
//显示扣除的总分
private void ShowScore()
{
text_score.text = (weightScore+ transportScore+otherScore).ToString("0.00");
}
//界面隐藏时 初始化界面
protected override void Clear()
{
base.Clear();
Transform[] deductPoints = deductPointParent.GetComponentsInChildren<Transform>();
for (int i = 0; i < deductPoints.Length; i++)//关闭时回收所有的权重滑块和分数
{
ObjectPool.Instance.Destroy(deductPoints[i].gameObject);
}
timeScoreCtrl.gameObject.SetActive(false);//隐藏转运部分扣分项
}
}