mycj_demo/mycj/Assets/Script/Penal.cs

102 lines
2.2 KiB
C#
Raw Permalink Normal View History

2024-12-02 09:37:47 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Penal : MonoBehaviour
{
public static Penal instance;
public GameObject Panel;
public Text Paneltext;
public Button againBTNNext;
public Button PanelBTNNext;
public Button PanelBTNClose;
2024-12-02 23:38:32 +08:00
public int wipe_outnumber=0;
2024-12-02 09:37:47 +08:00
// Start is called before the first frame update
private void Awake()
{
instance = this;
}
void Start()
{
2024-12-02 23:38:32 +08:00
2024-12-02 09:37:47 +08:00
Panel.SetActive(false);
2024-12-02 23:38:32 +08:00
againBTNNext.onClick.AddListener(() => {
2024-12-02 09:37:47 +08:00
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
});
2024-12-02 23:38:32 +08:00
PanelBTNNext.onClick.AddListener(() => { });
PanelBTNClose.onClick.AddListener(() => {
2024-12-02 09:37:47 +08:00
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
});
//Daojishi(5f);
}
// Update is called once per frame
void Update()
{
2024-12-02 23:38:32 +08:00
if (wipe_outnumber == 10)
{
GameVictory();
}
2024-12-02 09:37:47 +08:00
}
public void GameVictory()
{
Panel.SetActive(true);
2024-12-02 23:38:32 +08:00
Panel.GetComponent<Image>().color = Color.blue;
2024-12-02 09:37:47 +08:00
Paneltext.text = "Victory";
Paneltext.color = Color.yellow;
againBTNNext.gameObject.SetActive(false);
PanelBTNNext.gameObject.SetActive(true);
PanelBTNClose.gameObject.SetActive(true);
}
public void GameOver()
{
Panel.SetActive(true);
Panel.GetComponent<Image>().color = Color.red;
Paneltext.text = "GameOver";
Paneltext.color = Color.black;
againBTNNext.gameObject.SetActive(true);
PanelBTNNext.gameObject.SetActive(false);
PanelBTNClose.gameObject.SetActive(true);
}
2024-12-02 23:38:32 +08:00
//public void Daojishi(float number)
//{
// StartCoroutine(daojishi(number));
//}
//IEnumerator daojishi(float number)
//{
// float temp = number;
// while (temp > 0.01f)
// {
// djs.GetComponent<Text>().text = temp.ToString();
// temp -= 1;
// yield return new WaitForSeconds(1);
// }
// djs.SetActive(false);
//}
2024-12-02 09:37:47 +08:00
}