ShanxiKnowledgeBase/SXElectricity Marketing 2.0/Assets/Zion/Scripts/YL/Submit.cs

220 lines
6.1 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;
public class Submit : MonoBehaviour
{
/// <summary>
/// 练习模式图片
/// </summary>
private Sprite practicesprite;
/// <summary>
/// 考核模式图片
/// </summary>
private Sprite examinesprite;
/// <summary>
/// 考核练习图片
/// </summary>
public Image practicemode;
/// <summary>
/// 步骤列表
/// </summary>
public GameObject taskstep;
/// <summary>
/// 考试和训练内容
/// </summary>
public GameObject contractreversionpanl;
/// <summary>
/// 提交按钮
/// </summary>
public Button submitbutton;
/// <summary>
/// 交卷按钮
/// </summary>
public Button onvolumebutton;
/// <summary>
/// 练习的分页面
/// </summary>
public GameObject practicepanl;
/// <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 contract;
/// <summary>
/// 三个菜单按钮
/// </summary>
public GameObject electricitychargeaccounting, powersupplycontract;
/// <summary>
/// 初始化用户名
/// </summary>
public Text nametext;
/// <summary>
/// 操作步骤信息
/// </summary>
public GameObject firstcontent, secondcontent, thirdcontent, numberfourcontent, fifthcontent, sixthcontent, seventhcontent, eighthcontent;
/// <summary>
/// 初始化时间
/// </summary>
public Text loginname;
private void Awake()
{
loginname.text = DateTime.Now.ToString();
nametext.text = PlayerPrefs.GetString("Name");
Debug.Log(nametext.text);
Debug.LogError(ScoreManager.Instance.judgmentbos);
practicesprite = Resources.Load<Sprite>("UIpanel/练习模式");
examinesprite = Resources.Load<Sprite>("UIpanel/考试模式");
contract.isOn = true;
if (ScoreManager.Instance.judgmentbos)
{
firstcontent.SetActive(false);
secondcontent.SetActive(false);
thirdcontent.SetActive(false);
numberfourcontent.SetActive(false);
fifthcontent.SetActive(false);
sixthcontent.SetActive(false);
seventhcontent.SetActive(false);
eighthcontent.SetActive(false);
practicemode.sprite = examinesprite;
electricitychargeaccounting.SetActive(false);
powersupplycontract.SetActive(false);
onvolumebutton.gameObject.SetActive(true);
}
else
{
practicemode.sprite = practicesprite;
submitbutton.gameObject.SetActive(true);
}
}
void Start()
{
submitbutton.onClick.AddListener(() =>
{
practicemode.gameObject.SetActive(false);
taskstep.SetActive(false);
contractreversionpanl.SetActive(false);
marktext.text = ScoreManager.Instance.Score.ToString();
practicepanl.SetActive(true);
});
backbutton.onClick.AddListener(() =>
{
practicepanl.SetActive(false);
practicemode.gameObject.SetActive(true);
taskstep.SetActive(true);
contractreversionpanl.SetActive(true);
ScoreManager.Instance.SubtractScore(100);
Inactivation(contractreversionpanl.transform);
SceneManager.LoadScene("shanxii");
});
onvolumebutton.onClick.AddListener(() =>
{
submissionpromptpanl.SetActive(true);
});
cancelbutton2.onClick.AddListener(() =>
{
submissionpromptpanl.SetActive(false);
});
submitbutton2.onClick.AddListener(() =>
{
submissionpromptpanl.SetActive(false);
practicemode.gameObject.SetActive(false);
taskstep.SetActive(false);
contractreversionpanl.SetActive(false);
onvolumebutton.gameObject.SetActive(false);
isCooldown = true;
examinepanl.SetActive(true);
});
}
public void Inactivation(Transform pos)
{
for (int i = 0; i < pos.childCount; i++)
{
Transform pront = pos.GetChild(i);
if (i > 0)
{
pront.gameObject.SetActive(false);
}
}
pos.transform.GetChild(0).gameObject.SetActive(true);
}
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
}
}
}
}