You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
4.9 KiB
151 lines
4.9 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
public struct ExamInfoRequestPair
|
||
|
{
|
||
|
public string ID;
|
||
|
public int Pattern;
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 考试管理类
|
||
|
/// </summary>
|
||
|
public class ExamManager : BaseExamManager
|
||
|
{
|
||
|
|
||
|
public bool AutoBackToLastSceneFlag = false;
|
||
|
|
||
|
public override void GetData(IMessage message)
|
||
|
{
|
||
|
//从服务端获取考试信息
|
||
|
//解析message信息
|
||
|
ExamList.Clear();
|
||
|
ExamList = (List<ExaminationInfo>)message.Data;
|
||
|
if (ExamList.Count == 0)
|
||
|
{
|
||
|
this.gameObject.transform.parent.Find("bulletin").gameObject.SetActive(true);//没有考试信息的告示
|
||
|
return;
|
||
|
}
|
||
|
GenerateExamItem();//测试时自动调用
|
||
|
|
||
|
//注册获取服务端时间事件
|
||
|
|
||
|
NetworkManager.Default.SendRequestAsync("GET_SERVER_TIME_REQUEST");//请求服务端时间
|
||
|
//GetExamInfoFromServer();//服务端考试信息刷新UI
|
||
|
//ToDo...下载所有考题文件
|
||
|
//DownloadExam(ExamList[0]);
|
||
|
|
||
|
if (TimeManager.CurExam != null && TimeManager.CurQues != null)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage(TimeManager.CurExam.ID, "ToggleTrue", (object)TimeManager.CurQues.ID);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public override void GetExamInfoFromServer()
|
||
|
{
|
||
|
//连接服务器,获取考试信息数据,准备考试,同时要下载考题文件到本地
|
||
|
//ToDo...
|
||
|
//首先清空以前的记录
|
||
|
|
||
|
|
||
|
|
||
|
////test: 1 exam,1 question
|
||
|
//ExamInfo exam = new ExamInfo();
|
||
|
//exam.ExamName = "exam1";
|
||
|
//exam.ExamID = "1";
|
||
|
//exam.StartTime = "start";
|
||
|
//exam.DurationTime = "2";
|
||
|
//exam.EndTime = "end";
|
||
|
//exam.QuestionList = new List<QuestionInfo_o>();
|
||
|
|
||
|
//QuestionInfo_o question = new QuestionInfo_o();
|
||
|
//question.QuestionName = "油罐考题";
|
||
|
//question.QuestionXMLPath = "question/" + "8.xml";
|
||
|
//question.QuestionID = "1";
|
||
|
//question.SceneID = "5";
|
||
|
//exam.QuestionList.Add(question);
|
||
|
|
||
|
//QuestionInfo_o question1 = new QuestionInfo_o();
|
||
|
//question1.QuestionName = "油罐考题2";
|
||
|
//question1.QuestionXMLPath = "question/" + "8.xml";
|
||
|
//question1.QuestionID = "2";
|
||
|
//question1.SceneID = "6";
|
||
|
//exam.QuestionList.Add(question1);
|
||
|
|
||
|
//ExamList.Add(exam);
|
||
|
//ExamList.Add(exam);
|
||
|
//ExamList.Add(exam);
|
||
|
|
||
|
//下载考题文件到本地
|
||
|
//ToDo...
|
||
|
|
||
|
}
|
||
|
public override void InitMessageType()
|
||
|
{
|
||
|
MESSAGETYPE = "GET_EXAMINATION_INFOS_REFRESH";
|
||
|
}
|
||
|
public override void InitInfo()
|
||
|
{
|
||
|
|
||
|
//给预制体复制
|
||
|
ItemPrefab = Resources.Load<GameObject>("UIPrefab/Examination/ExamInfo2");
|
||
|
var mode = (int)ExamInfoHelpClass.applicationMode;
|
||
|
//向服务端请求考试信息
|
||
|
//NetworkManager.Default.SendAsync("GET_EXAMINATION_INFOS_REQUEST",
|
||
|
// new ExamInfoRequestPair { ID= MySelf.mySelf.ID ,Pattern=(int)ExamInfoHelpClass.applicationMode});
|
||
|
NetworkManager.Default.SendRequestAsync("GET_EXAMINATION_INFOS_REQUEST",
|
||
|
new ExamInfoRequestPair { ID = MySelf.mySelf.ID, Pattern = (int)ExamInfoHelpClass.applicationMode });
|
||
|
|
||
|
MySceneManager.BackToLastSceneEvent += BackToLastSceneEvent;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 下载指定试卷
|
||
|
/// </summary>
|
||
|
/// <param name="ei"></param>
|
||
|
|
||
|
private void BackToLastSceneEvent(MyEventArgs e)
|
||
|
{
|
||
|
if (e.sourceScene == "StartExam" && e.destinateScene == "ModeSelect")
|
||
|
{
|
||
|
if(TimeManager.CurExam != null)
|
||
|
{
|
||
|
Debug.Log("推出前请提交当前考试!");
|
||
|
GameObject TipWindow = Instantiate(Resources.Load<GameObject>("UIPrefab/TipWindow"));
|
||
|
TipWindow.GetComponent<TipWindowManager>().SetWindow(
|
||
|
"确定提交本次考试,并退出 ?", new UnityEngine.Events.UnityAction(OKSubmit), new UnityEngine.Events.UnityAction(NOSubmit));
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
BaseItemManager.CurExam = null;
|
||
|
BaseItemManager.CurQues = null;
|
||
|
BaseItemManager.CurExamID = 0;
|
||
|
BaseItemManager.CurQuestionID = 0;
|
||
|
///////////////////
|
||
|
TimeManager.CurExam = null;
|
||
|
TimeManager.CurQues = null;
|
||
|
TimeManager.RemainSeconds = -10;
|
||
|
}
|
||
|
MySceneManager.BackToLastSceneEvent -= BackToLastSceneEvent;
|
||
|
}
|
||
|
|
||
|
private void NOSubmit()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
private void OKSubmit()
|
||
|
{
|
||
|
AutoBackToLastSceneFlag = true;
|
||
|
MessageDispatcher.SendMessage("SubmitExam", (object)TimeManager.CurExam.ID);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|