402 lines
11 KiB
C#
402 lines
11 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Diagnostics.Contracts;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.XR;
|
|
using static UnityEditor.PlayerSettings;
|
|
|
|
public class Submit : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 提交按钮
|
|
/// </summary>
|
|
public Button submitbutton;
|
|
/// <summary>
|
|
/// 交卷按钮
|
|
/// </summary>
|
|
public Button onvolumebutton;
|
|
/// <summary>
|
|
/// 练习的分页面
|
|
/// </summary>
|
|
public GameObject practicepanl;
|
|
/// <summary>
|
|
/// 查看答案按钮
|
|
/// </summary>
|
|
public Button answerbutton;
|
|
/// <summary>
|
|
/// 考试分数
|
|
/// </summary>
|
|
public Text marktext;
|
|
/// <summary>
|
|
/// 返回按钮
|
|
/// </summary>
|
|
public Button backbutton;
|
|
/// <summary>
|
|
/// 考核面板
|
|
/// </summary>
|
|
public GameObject examinepanl;
|
|
/// <summary>
|
|
/// 技能冷却时间
|
|
/// </summary>
|
|
public float examinetimer = 10f;
|
|
/// <summary>
|
|
/// 技能冷却时间
|
|
/// </summary>
|
|
public float skilltimer = 0f;
|
|
/// <summary>
|
|
/// 技能冷却图片
|
|
/// </summary>
|
|
public Image coolingimage;
|
|
/// <summary>
|
|
/// 技能冷却开关
|
|
/// </summary>
|
|
private bool isCooldown = false;
|
|
/// <summary>
|
|
/// 系统提示
|
|
/// </summary>
|
|
public Text warntext;
|
|
/// <summary>
|
|
/// 体统提示时间
|
|
/// </summary>
|
|
public float timer = 10f;
|
|
/// <summary>
|
|
/// 倒计时
|
|
/// </summary>
|
|
public Text timetext;
|
|
/// <summary>
|
|
/// 提示是否交卷页面
|
|
/// </summary>
|
|
public GameObject submissionpromptpanl;
|
|
/// <summary>
|
|
/// 确定按钮
|
|
/// </summary>
|
|
public Button submitbutton2;
|
|
/// <summary>
|
|
/// 取消按钮
|
|
/// </summary>
|
|
public Button cancelbutton2;
|
|
/// <summary>
|
|
/// 三个菜单按钮
|
|
/// </summary>
|
|
public Toggle electricitychargeaccounting, powersupplycontract, contract;
|
|
/// <summary>
|
|
/// 初始化用户名
|
|
/// </summary>
|
|
public Text nametext;
|
|
/// <summary>
|
|
/// 初始化时间
|
|
/// </summary>
|
|
public Text loginname;
|
|
/// <summary>
|
|
/// 覆约合同预设体
|
|
/// </summary>
|
|
public GameObject retreatyobj;
|
|
/// <summary>
|
|
/// 电费计算预设体
|
|
/// </summary>
|
|
public GameObject electricchargeobj;
|
|
/// <summary>
|
|
/// 覆约电费供电页面练习预制体生成位置
|
|
/// </summary>
|
|
public RectTransform retreatypanl;
|
|
public RectTransform powersupplypanl;
|
|
public RectTransform electricchargepanl;
|
|
/// <summary>
|
|
/// 接收覆约合同的预设体
|
|
/// </summary>
|
|
public GameObject retreatpreform;
|
|
public GameObject electricchargeprrform;
|
|
/// <summary>
|
|
/// 初始化每个考试toggle显示按钮
|
|
/// </summary>
|
|
public Vector3 pos;
|
|
/// <summary>
|
|
/// 提交练习那个页面区分
|
|
/// </summary>
|
|
public Judgmentstate judgmentstate;
|
|
/// <summary>
|
|
/// 电费核算答案查询页面
|
|
/// </summary>
|
|
public GameObject viewimage;
|
|
/// <summary>
|
|
/// 电费核算取消按钮
|
|
/// </summary>
|
|
public Button forkoffbutton;
|
|
private void Awake()
|
|
{
|
|
Initialize();//初始化
|
|
switch (ScoreManager.Instance.Examinationpaper)
|
|
{
|
|
case Examinationpaper.practice:
|
|
Practicesubject();//练习页面
|
|
break;
|
|
case Examinationpaper.Reviewexamination:
|
|
Reviewpaper();//覆约页面
|
|
break;
|
|
case Examinationpaper.Powersupplytest:
|
|
Powersupplytestpaper();//供电页面
|
|
break;
|
|
case Examinationpaper.Electricityfeetest:
|
|
Electricityexaminationpaper();//电费页面
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 初始化场景
|
|
/// </summary>
|
|
private void Initialize()
|
|
{
|
|
pos = contract.transform.position;
|
|
loginname.text = PlayerPrefs.GetString("time");
|
|
nametext.text = PlayerPrefs.GetString("Name");
|
|
Debug.LogError(ScoreManager.Instance.Examinationpaper);
|
|
retreatyobj = Resources.Load<GameObject>("UIpanel/practice1");
|
|
electricchargeobj = Resources.Load<GameObject>("UIpanel/practicepanl3");
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
submitbutton.onClick.AddListener(() =>
|
|
{
|
|
switch (ScoreManager.Instance.Judgmentstate)
|
|
{
|
|
case Judgmentstate.page1:
|
|
Practicesubmission1();
|
|
break;
|
|
case Judgmentstate.page2:
|
|
Practicesubmission2();
|
|
break;
|
|
case Judgmentstate.page3:
|
|
Practicesubmission3();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
backbutton.onClick.AddListener(() =>
|
|
{
|
|
switch (ScoreManager.Instance.Judgmentstate)
|
|
{
|
|
case Judgmentstate.page1:
|
|
Repractice1();
|
|
break;
|
|
case Judgmentstate.page2:
|
|
Repractice2();
|
|
break;
|
|
case Judgmentstate.page3:
|
|
Repractice3();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
});
|
|
onvolumebutton.onClick.AddListener(() =>
|
|
{
|
|
submissionpromptpanl.SetActive(true);
|
|
});
|
|
cancelbutton2.onClick.AddListener(() =>
|
|
{
|
|
submissionpromptpanl.SetActive(false);
|
|
});
|
|
submitbutton2.onClick.AddListener(() =>
|
|
{
|
|
switch (ScoreManager.Instance.Examinationpaper)
|
|
{
|
|
case Examinationpaper.practice:
|
|
break;
|
|
case Examinationpaper.Reviewexamination:
|
|
Handinanexaminationpaper1();
|
|
break;
|
|
case Examinationpaper.Powersupplytest:
|
|
Handinanexaminationpaper2();
|
|
break;
|
|
case Examinationpaper.Electricityfeetest:
|
|
Handinanexaminationpaper3();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
Answer();//查看答案
|
|
}
|
|
|
|
private void Answer()
|
|
{
|
|
answerbutton.onClick.AddListener(() =>
|
|
{
|
|
viewimage.SetActive(true);
|
|
});
|
|
forkoffbutton.onClick.AddListener(() =>
|
|
{
|
|
viewimage.SetActive(false);
|
|
});
|
|
}
|
|
|
|
private void Handinanexaminationpaper3()
|
|
{
|
|
Debug.Log("电费核算交卷");
|
|
electricchargeprrform = GameObject.Find("practicepanl3(Clone)");
|
|
Destroy(electricchargeprrform);
|
|
submissionpromptpanl.SetActive(false);
|
|
onvolumebutton.gameObject.SetActive(false);
|
|
isCooldown = true;
|
|
examinepanl.SetActive(true);
|
|
}
|
|
|
|
private void Handinanexaminationpaper2()
|
|
{
|
|
|
|
}
|
|
|
|
private void Handinanexaminationpaper1()
|
|
{
|
|
retreatpreform = GameObject.Find("practice1(Clone)");
|
|
retreatpreform.SetActive(false);
|
|
submissionpromptpanl.SetActive(false);
|
|
onvolumebutton.gameObject.SetActive(false);
|
|
isCooldown = true;
|
|
examinepanl.SetActive(true);
|
|
}
|
|
|
|
private void Repractice3()
|
|
{
|
|
Destroy(retreatpreform);
|
|
Instantiate(retreatyobj, retreatypanl);
|
|
practicepanl.SetActive(false);
|
|
ScoreManager.Instance.SubtractScore(100);
|
|
}
|
|
|
|
private void Repractice2()
|
|
{
|
|
Debug.Log("供电合同返回");
|
|
practicepanl.SetActive(false);
|
|
|
|
}
|
|
|
|
private void Repractice1()
|
|
{
|
|
Debug.Log("电费核算返回");
|
|
practicepanl.SetActive(false);
|
|
Instantiate(electricchargeobj,electricchargepanl);
|
|
ScoreManager.Instance.SubtractElectriccharge(100);
|
|
|
|
}
|
|
|
|
private void Practicesubmission3()
|
|
{
|
|
retreatpreform = GameObject.Find("practice1(Clone)");
|
|
Destroy(retreatpreform);
|
|
//retreatpreform.SetActive(false);
|
|
answerbutton.gameObject.SetActive(false);
|
|
marktext.text = ScoreManager.Instance.Score.ToString();
|
|
practicepanl.SetActive(true);
|
|
}
|
|
|
|
private void Practicesubmission2()
|
|
{
|
|
Debug.Log("提交供电合同");
|
|
answerbutton.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void Practicesubmission1()
|
|
{
|
|
Debug.Log("提交电费核算");
|
|
electricchargeprrform = GameObject.Find("practicepanl3(Clone)");
|
|
Destroy(electricchargeprrform);
|
|
Electricitychargeaccounting.Instance.Calculatescore();
|
|
Electricitychargeaccounting.Instance.Calculatescore2();
|
|
answerbutton.gameObject.SetActive(true);
|
|
marktext.text = ScoreManager.Instance.Electriccharge.ToString();
|
|
practicepanl.SetActive(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 覆约合同考试页面初始化
|
|
/// </summary>
|
|
public void Reviewpaper()
|
|
{
|
|
contract.isOn = true;
|
|
contract.gameObject.SetActive(true);
|
|
electricitychargeaccounting.gameObject.SetActive(false);
|
|
powersupplycontract.gameObject.SetActive(false);
|
|
onvolumebutton.gameObject.SetActive(true);
|
|
retreatypanl.gameObject.SetActive(true);
|
|
powersupplypanl.gameObject.SetActive(false);
|
|
electricchargepanl.gameObject.SetActive(false);
|
|
Instantiate(retreatyobj, retreatypanl);
|
|
}
|
|
/// <summary>
|
|
/// 所有练习科目页面初始化
|
|
/// </summary>
|
|
public void Practicesubject()
|
|
{
|
|
contract.isOn = true;
|
|
submitbutton.gameObject.SetActive(true);
|
|
retreatypanl.gameObject.SetActive(true);
|
|
powersupplypanl.gameObject.SetActive(false);
|
|
electricchargepanl.gameObject.SetActive(false);
|
|
Instantiate(electricchargeobj,electricchargepanl);
|
|
Instantiate(retreatyobj, retreatypanl);
|
|
}
|
|
/// <summary>
|
|
/// 供电考试页面初始化
|
|
/// </summary>
|
|
public void Powersupplytestpaper()
|
|
{
|
|
powersupplycontract.transform.position = pos;
|
|
powersupplycontract.isOn = true;
|
|
contract.gameObject.SetActive(false);
|
|
electricitychargeaccounting.gameObject.SetActive(false);
|
|
powersupplycontract.gameObject.SetActive(true);
|
|
retreatypanl.gameObject.SetActive(false);
|
|
onvolumebutton.gameObject.SetActive(true);
|
|
powersupplypanl.gameObject.SetActive(true);
|
|
electricchargepanl.gameObject.SetActive(false);
|
|
}
|
|
/// <summary>
|
|
/// 电费核算考试页面初始化
|
|
/// </summary>
|
|
public void Electricityexaminationpaper()
|
|
{
|
|
electricitychargeaccounting.transform.position = pos;
|
|
electricitychargeaccounting.isOn = true;
|
|
contract.gameObject.SetActive(false);
|
|
electricitychargeaccounting.gameObject.SetActive(true);
|
|
powersupplycontract.gameObject.SetActive(false);
|
|
retreatypanl.gameObject.SetActive(false);
|
|
powersupplypanl.gameObject.SetActive(false);
|
|
onvolumebutton.gameObject.SetActive(true);
|
|
electricchargepanl.gameObject.SetActive(true);
|
|
Instantiate(electricchargeobj,electricchargepanl);
|
|
}
|
|
void Update()
|
|
{
|
|
//十秒后自动退出程序
|
|
if (isCooldown)
|
|
{
|
|
coolingimage.fillAmount = 1 - (skilltimer / examinetimer);
|
|
skilltimer += Time.deltaTime;
|
|
timer -= Time.deltaTime;
|
|
warntext.text = timer.ToString("0") + "秒后自动退出系统";
|
|
timetext.text = timer.ToString("0");
|
|
if (coolingimage.fillAmount == 0)
|
|
{
|
|
// 退出应用程序
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
#else
|
|
Application.Quit();
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
}
|