unityzgy/Assets/Scripts/UIScripts/Student/Mono/FixStepWindowCtrl.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

126 lines
3.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using XFramework.Objects;
//正式操作开始前的步骤规划提示面板
//创建步骤元素 管理未规划和已规划的元素及相关数据 返回规划完成的数据
public class FixStepWindowCtrl : MonoBehaviour
{
public GameObject childPrefab;//节点预制件
//左侧父节点
public Transform unPlanningStepsParent;
Dictionary<GameObject, StepData> unPlanningSteps = new Dictionary<GameObject, StepData>();//左侧物体节点 和对应的数据
//右侧父节点
public Transform PlannedStepsParent;
Dictionary<GameObject, StepData> PlannedSteps = new Dictionary<GameObject, StepData>();//右侧物体节点
List<StepData> rightSteps = new List<StepData>();//完成规划的数据 按照进入存储
UnityAction<List<StepData>> planningOverEvent;//规划完成事件
string currentStepName;//当前阶段的名称
public Button button_sure;//完成规划
private void Start()
{
button_sure.onClick.AddListener(ButtonSure);
}
//隐藏窗口
public void Hide()
{
this.gameObject.SetActive(false);
}
//显示窗口 注入数据
public void ActiveWindow(List<StepData> steps,UnityAction<List<StepData>> overEvent)
{
this.gameObject.SetActive(true);
planningOverEvent = overEvent;
for (int i = 0; i < steps.Count; i++)
{
GameObject newStepGO = ObjectPool.Instance.Instantiate(childPrefab, unPlanningStepsParent);
newStepGO.transform.localScale = Vector3.one;
newStepGO.GetComponent<StepButtonCtrl>().InjectInitData(steps[i].describe, StepClickOn, StepType.unPlanning);
unPlanningSteps.Add(newStepGO, steps[i]);
}
}
//某个步骤按钮被点击时 移动位置 并记录相关数据
public void StepClickOn(StepButtonCtrl stepButton)
{
//左侧的按钮点击了 移动到右侧 标记为完成规划
if (stepButton.Type == StepType.unPlanning)
{
stepButton.transform.SetParent(PlannedStepsParent);
stepButton.Type = StepType.Planned;
PlannedSteps.Add(stepButton.gameObject, unPlanningSteps[stepButton.gameObject]);
rightSteps.Add(unPlanningSteps[stepButton.gameObject]);
unPlanningSteps.Remove(stepButton.gameObject);
}
else//右侧按钮点击了 移动到左侧 标记为未完成规划
{
stepButton.transform.SetParent(unPlanningStepsParent);
stepButton.Type = StepType.unPlanning;
unPlanningSteps.Add(stepButton.gameObject, PlannedSteps[stepButton.gameObject]);
rightSteps.Remove(PlannedSteps[stepButton.gameObject]);
PlannedSteps.Remove(stepButton.gameObject);
}
}
//按下提交按钮时评估是否正确 正确时结束规划 清空本界面 错误时不做处理
void ButtonSure()
{
EditorAppraiser editorAppraiser = new EditorAppraiser();
string error = editorAppraiser.AppraiseSteps(rightSteps);
if (string.IsNullOrEmpty(error))//规划的步骤正确
{
planningOverEvent?.Invoke(rightSteps);
Clear();
this.gameObject.SetActive(false);
}
else {
Debug.Log("提示规划步骤有误,不做其他处理");
}
}
//清空界面和相关数据
void Clear()
{
foreach (var item in unPlanningSteps)
{
ObjectPool.Instance.Destroy(item.Key);
}
unPlanningSteps.Clear();
foreach (var item in PlannedSteps)
{
ObjectPool.Instance.Destroy(item.Key);
}
PlannedSteps.Clear();
rightSteps.Clear();
}
}
public enum StepType
{
//未规划的
unPlanning,
//规划完成的
Planned,
}