using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using XFramework;
///
/// 学员端操作完成弹出
/// 用于显示教员发送的评估结果
/// 学员可主动退出 并通知教员
///
public class WaitResultPanel : BasePanel
{
const string panelName = "Panel_WaitResultPanel";
Transform waitText;//等待中提示文字
Text showLevelText;//显示评价等级
Text showRemark;//显示教员评语
public WaitResultPanel() :base(new UIType("Panel_WaitResultPanel"))
{
}
protected override void InitEvent()
{
ActivePanel.FindChildTrans("Button_Close").GetComponent().onClick.AddListener(CloseButtonOn);
waitText = ActivePanel.FindChildTrans("Text_wating");
showLevelText = ActivePanel.FindChildTrans("Text_level").GetComponent();
showRemark = ActivePanel.FindChildTrans("Text_remark").GetComponent();
}
public override void OnStart()
{
base.OnStart();
EventCenter.Instance.AddEventListener("TeacherSendResult", InjectResult);
waitText.gameObject.SetActive(true);
showLevelText.gameObject.SetActive(false);
showRemark.gameObject.SetActive(false);
}
//注入成绩类
private void InjectResult(NetAppraiseData netAppraiseData)
{
if (netAppraiseData.appraised)//有效评估成绩
{
waitText.gameObject.SetActive(false);
showLevelText.gameObject.SetActive(true);
string color = "";
switch (netAppraiseData.appraiseLevel)
{
case "优秀":
color = "FFFF00";
break;
case "良好":
color = "04FF00";
break;
case "一般":
color = "00FFF5";
break;
case "较差":
color = "FF6A00";
break;
}
LocalizationManager.SetFormatted(showLevelText, "{1} ", color, netAppraiseData.appraiseLevel);
if (!string.IsNullOrEmpty(netAppraiseData.remark))//有教员评语时 显示教员评语
{
showRemark.gameObject.SetActive(true);
showRemark.text = netAppraiseData.remark;
}
}
else//教员放弃评价 返回初始场景 无需发送结束事件
{
FinishedWait();
}
}
//尝试关闭本界面时
private void CloseButtonOn()
{
if (!showLevelText.gameObject.activeSelf) //未显示成绩 退出提示
{
Push(new PromptWindows()).Change(new PromptWindowInitData(LocalizationManager.Get("是否不再等待教员评价,并返回初始场景?"), ClosePanelAndSend));//弹出提示界面
}
else
{
ClosePanelAndSend();
}
}
private void ClosePanelAndSend()
{
TCPManager.Instance.SendNetMsg(NetMsgName.StuCloseResPanel);
FinishedWait();
}
//结束等待界面
private void FinishedWait()
{
EventCenter.Instance.RemoveEnvetListener("TeacherSendResult", InjectResult);
Pop();
SceneSystem.Instance.SetScene(new StudentLoginScene(LoadSceneType.Login));
}
}