96 lines
2.5 KiB
C#
96 lines
2.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class Judgmentstate : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 环境设置按钮
|
|
/// </summary>
|
|
public Button environment;
|
|
/// <summary>
|
|
/// 天气配置页面
|
|
/// </summary>
|
|
public RectTransform weather_panl;
|
|
/// <summary>
|
|
/// 关闭天气配置界面按钮
|
|
/// </summary>
|
|
public Button fanhui1;
|
|
public Button off_btn;
|
|
public Button initiate_btn;//开始按钮
|
|
public Button Pause_btn;//暂停按钮
|
|
public Button finish_btn;//结束按钮
|
|
public Text countdown_text;//倒计时文本
|
|
public bool isp=false;//判断游戏结束
|
|
public float a=5;
|
|
|
|
public bool UNITY_EDITOR { get; private set; }
|
|
|
|
void Start()
|
|
{
|
|
Time.timeScale = 0;
|
|
environment.onClick.AddListener(() =>
|
|
{
|
|
weather_panl.gameObject.SetActive(true);
|
|
});
|
|
off_btn.onClick.AddListener(() =>
|
|
{
|
|
weather_panl.gameObject.SetActive(false);
|
|
});
|
|
fanhui1.onClick.AddListener(() =>
|
|
{
|
|
GameMain.tiao = false;
|
|
SceneManager.LoadScene("SampleScene");
|
|
});
|
|
Operation();//开始暂停结束方法
|
|
}
|
|
|
|
private void Operation()
|
|
{
|
|
initiate_btn.onClick.AddListener(() =>
|
|
{
|
|
initiate_btn.gameObject.SetActive(false);
|
|
Pause_btn.gameObject.SetActive(true);
|
|
Time.timeScale = 1;
|
|
AudioListener.pause = true;
|
|
});
|
|
Pause_btn.onClick.AddListener(() =>
|
|
{
|
|
if (isp!=false)
|
|
{
|
|
initiate_btn.gameObject.SetActive(true);
|
|
Pause_btn.gameObject.SetActive(false);
|
|
Time.timeScale = 0;
|
|
AudioListener.pause = false;
|
|
}
|
|
});
|
|
finish_btn.onClick.AddListener(() =>
|
|
{
|
|
if (Time.timeScale!=0)
|
|
{
|
|
isp = true;
|
|
}
|
|
countdown_text.gameObject.SetActive(true);
|
|
});
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (isp==true)
|
|
{
|
|
a -= Time.deltaTime;
|
|
countdown_text.text=a.ToString("0");
|
|
if (a<=0)
|
|
{
|
|
countdown_text.gameObject.SetActive(false);
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
Application.Quit();//在可执行程序中结束运行
|
|
isp = false;
|
|
}
|
|
}
|
|
}
|
|
}
|