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.
307 lines
9.9 KiB
307 lines
9.9 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using UnityEngine.UI;
|
||
|
using System;
|
||
|
using System.IO;
|
||
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
using UnityEngine.SceneManagement;
|
||
|
using System.Xml;
|
||
|
using System.Text;
|
||
|
|
||
|
|
||
|
public class ModeSelectManager : MonoBehaviour {
|
||
|
private Button TrainingModeButton;
|
||
|
private Button ExamModeButton;
|
||
|
public GameObject ExamineUI;
|
||
|
public GameObject TrainUI;
|
||
|
public Button SetExamModeButton;//考试设置
|
||
|
public Button StartExamModeButton;//我要考试
|
||
|
public Button MakeScoreModeButton;//评分
|
||
|
public Button ExamResultModeButton;//试卷
|
||
|
public Button SetTheTestPaperButton;//设置考卷
|
||
|
public Button ChooseQuestionsButton;//选择考题
|
||
|
public Button ExamAllSelectButton;//数据统计
|
||
|
|
||
|
public Button PreparesLessonButton;//备课
|
||
|
public Button TeachingLessonButton;//授课
|
||
|
public Button LearningLessonButton;//自学
|
||
|
public Button CoursewareLearningButton;//课件学习
|
||
|
public Button CourseBaseButton;//课件库
|
||
|
|
||
|
public Toggle TrainingModeToggle;
|
||
|
public Toggle ExamModeToggle;
|
||
|
public GameObject ScencChooseUI;//选择UI场景
|
||
|
// Use this for initialization
|
||
|
void Start () {
|
||
|
|
||
|
//考核
|
||
|
SetExamModeButton.onClick.AddListener(SetExam);
|
||
|
StartExamModeButton.onClick.AddListener(StartExam);
|
||
|
MakeScoreModeButton.onClick.AddListener(MakeScore);
|
||
|
ExamResultModeButton.onClick.AddListener(ExamResult);
|
||
|
SetTheTestPaperButton.onClick.AddListener(SetTheTestPaper);
|
||
|
ChooseQuestionsButton.onClick.AddListener(ChooseQuestions);
|
||
|
ExamAllSelectButton.onClick.AddListener(ExamAllSelect);
|
||
|
//培训
|
||
|
PreparesLessonButton.onClick.AddListener(PreparesLesson);
|
||
|
TeachingLessonButton.onClick.AddListener(TeachingLesson);
|
||
|
LearningLessonButton.onClick.AddListener(LearningLesson);
|
||
|
CoursewareLearningButton.onClick.AddListener(CoursewareLearning);
|
||
|
CourseBaseButton.onClick.AddListener(CourseBase);
|
||
|
|
||
|
ExamModeToggle.onValueChanged.AddListener(ShowExamineMode);
|
||
|
TrainingModeToggle.onValueChanged.AddListener(ShowTrainMode);
|
||
|
|
||
|
//MySceneManager.AddSceneToList(MySceneManager.GetActiveScene().name);
|
||
|
TrainingModeButton = transform.Find("TrainingModeButton").GetComponent<Button>();
|
||
|
ExamModeButton = transform.Find("ExamModeButton").GetComponent<Button>();
|
||
|
|
||
|
CheckUserFolder();
|
||
|
ModeSelect();
|
||
|
MessageDispatcher.AddListener("SecneSelect",GetSelectSence);
|
||
|
|
||
|
//MySceneManager.BackToLastSceneEvent += BackToLastSceneEvent;
|
||
|
|
||
|
}
|
||
|
|
||
|
//private void BackToLastSceneEvent(MyEventArgs args)
|
||
|
//{
|
||
|
// MySceneManager.BackToLastSceneEvent -= BackToLastSceneEvent;
|
||
|
|
||
|
// if (args.sourceScene=="ModeSelect" && args.destinateScene == "Login")
|
||
|
// {
|
||
|
// // HACK: 因为代码抽风,导致这个方法有时会执行两次
|
||
|
// // 特在此处做一个特殊处理
|
||
|
|
||
|
// var loginSetting = GameSetting.LoginSetting;
|
||
|
|
||
|
// if (!loginSetting.Contains(NetworkManager.Default.RemoteEndPoint))
|
||
|
// {
|
||
|
// var ip = default(string);
|
||
|
// var port = default(short);
|
||
|
|
||
|
// GameSetting.LoginSetting.GetLoginAddress(out ip, out port);
|
||
|
|
||
|
// NetworkManager.DestroySession(NetworkManager.Default);
|
||
|
// NetworkManager.CreateDefaultSession(ip, port);
|
||
|
// NetworkManager.Default.Start();
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
public static int I = 1;
|
||
|
public void ModeSelect()
|
||
|
{
|
||
|
if (I == 1)
|
||
|
{
|
||
|
ExamModeToggle.isOn=true;
|
||
|
TrainingModeToggle.isOn = false;
|
||
|
}
|
||
|
else if (I == 2)
|
||
|
{
|
||
|
ExamModeToggle.isOn = false;
|
||
|
TrainingModeToggle.isOn = true;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("SecneSelect", GetSelectSence);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 参考腾讯QQ,生成用户的个人文件夹
|
||
|
/// </summary>
|
||
|
private void CheckUserFolder()
|
||
|
{
|
||
|
//MySelf.mySelf = new UserInfo();
|
||
|
//MySelf.mySelf.ID = "yhd";//测试数据,发布时需要删除
|
||
|
string path = Application.dataPath + @"/ExtendFolder/xml/"+MySelf.mySelf.ID+"/";
|
||
|
string fileDir = Path.GetDirectoryName(path);
|
||
|
|
||
|
string PathPlan = Application.dataPath + @"/Three-dimensionalPlan/";
|
||
|
if (!Directory.Exists(PathPlan))
|
||
|
{
|
||
|
Directory.CreateDirectory(PathPlan);
|
||
|
}
|
||
|
|
||
|
if (!Directory.Exists(fileDir))
|
||
|
{
|
||
|
Directory.CreateDirectory(fileDir);
|
||
|
Directory.CreateDirectory(fileDir + "/recordList/");
|
||
|
Directory.CreateDirectory(fileDir + "/Questions/");
|
||
|
Directory.CreateDirectory(fileDir + "/Answers/");
|
||
|
Directory.CreateDirectory(fileDir + "/Scores/");
|
||
|
Directory.CreateDirectory(fileDir + "/Coursewares/");
|
||
|
//CreateUserDBTable(MySelf.mySelf.ID);
|
||
|
CrestXml(path);
|
||
|
|
||
|
}
|
||
|
ExamInfoHelpClass.CurrentWorkPath = path;//确定当前用户的工作路径
|
||
|
}
|
||
|
public void CrestXml(string path)
|
||
|
{
|
||
|
|
||
|
XmlDocument doc = new XmlDocument();
|
||
|
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
|
||
|
doc.AppendChild(dec);
|
||
|
//创建一个根节点(一级)
|
||
|
XmlElement root = doc.CreateElement("ScoreAssets");
|
||
|
doc.AppendChild(root);
|
||
|
//创建节点(二级)
|
||
|
XmlNode node = doc.CreateElement("Child");
|
||
|
root.AppendChild(node);
|
||
|
//创建节点(三级)
|
||
|
XmlElement ScoreID = doc.CreateElement("score");
|
||
|
|
||
|
|
||
|
ScoreID.SetAttribute("ScoreID", "0");
|
||
|
ScoreID.SetAttribute("AnwserID", "00");
|
||
|
ScoreID.SetAttribute("CreatID", "11");
|
||
|
|
||
|
node.AppendChild(ScoreID);
|
||
|
root.AppendChild(node);
|
||
|
doc.Save(path+"/"+"SocreData.xml");
|
||
|
Console.Write(doc.OuterXml);
|
||
|
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 创建该用户的数据库表
|
||
|
/// </summary>
|
||
|
private void CreateUserDBTable(string tableName)
|
||
|
{
|
||
|
DbTool dbTool = DbTool.getInstance();
|
||
|
dbTool.OpenDB(DbTool.dataBase);
|
||
|
//string dbstr = "create table "+ tableName + " like tableT";//select * into tab_new from tab_old
|
||
|
//string dbstr = "select * into " + tableName + " from tableT";
|
||
|
//string dbstr = "insert into " + tableName + " select * from tableT";
|
||
|
string dbstr = "create table " + tableName + " as select * from tableT";
|
||
|
dbTool.ExecuteQuery(dbstr);
|
||
|
dbTool.CloseSqlConnection();
|
||
|
}
|
||
|
/*
|
||
|
public string ScoreID;
|
||
|
public string MakeScorerID;//评分者ID
|
||
|
public string AnswerID;
|
||
|
public string Score;
|
||
|
public string ScoreXmlPath;*/
|
||
|
|
||
|
/// <summary>
|
||
|
///开启对应模式的UI面板
|
||
|
/// </summary>
|
||
|
public void ShowExamineMode(bool check)
|
||
|
{
|
||
|
ExamineUI.SetActive(true);
|
||
|
TrainUI.SetActive(false);
|
||
|
if (check)
|
||
|
{
|
||
|
I = 1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public void ShowTrainMode(bool check)
|
||
|
{
|
||
|
ExamineUI.SetActive(false);
|
||
|
TrainUI.SetActive(true);
|
||
|
if (check)
|
||
|
{
|
||
|
I = 2;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
///考核模式的按钮
|
||
|
/// </summary>
|
||
|
private void ExamResult()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("ExamResult");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.CheckScore;
|
||
|
}
|
||
|
|
||
|
private void MakeScore()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("MakeScore");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.MakeScore;
|
||
|
}
|
||
|
|
||
|
private void StartExam()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("StartExam");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.ExamineMode;
|
||
|
TimeManager.CurExam = null;
|
||
|
TimeManager.CurQues = null;
|
||
|
TimeManager.RemainSeconds = -10;
|
||
|
}
|
||
|
|
||
|
private void SetTheTestPaper()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("SetExaminationPaper");
|
||
|
}
|
||
|
private void ChooseQuestions()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("SetExaminationQuestion");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.CreatQuestion;
|
||
|
}
|
||
|
private void ExamAllSelect()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("ExamAll");
|
||
|
}
|
||
|
private void SetExam()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("SetExamination");
|
||
|
}
|
||
|
/// <summary>
|
||
|
///培训模式的按钮
|
||
|
/// </summary>
|
||
|
//备课
|
||
|
private void PreparesLesson()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("PrepareLessons");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.PrepareMode;
|
||
|
}
|
||
|
//自学
|
||
|
private ExamInfoHelpClass.Scene sceneType;
|
||
|
public void GetSelectSence(IMessage SceneType)
|
||
|
{
|
||
|
sceneType =( ExamInfoHelpClass.Scene)SceneType.Data;
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.SelfStudyMode;
|
||
|
}
|
||
|
private void LearningLesson()//选择场景
|
||
|
{
|
||
|
ScencChooseUI.SetActive(true);
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.SelfStudyMode;
|
||
|
}
|
||
|
public void JiaZaiChangJing()//加载场景
|
||
|
{
|
||
|
int Num = (int)sceneType;
|
||
|
Debug.Log(Num);
|
||
|
MySceneManager.MyLoadScene(Num.ToString());
|
||
|
}
|
||
|
public void BackModeSelecUI()
|
||
|
{
|
||
|
ScencChooseUI.SetActive(false);
|
||
|
}
|
||
|
/********/
|
||
|
//课件学习
|
||
|
private void CoursewareLearning()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("CoursewareLearning");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.CoursewareMode;
|
||
|
}
|
||
|
//课件库
|
||
|
private void CourseBase()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("CourseBase");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.CourseBaseMode;
|
||
|
}
|
||
|
//授课
|
||
|
private void TeachingLesson()
|
||
|
{
|
||
|
MySceneManager.MyLoadScene("TeachingLesson");
|
||
|
ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.TeachMode;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|