2024-10-25 18:09:59 +08:00
|
|
|
|
2024-10-24 16:54:32 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
public class MainPanel : MonoBehaviour
|
|
|
|
{
|
|
|
|
public static MainPanel ins;
|
|
|
|
[SerializeField] private Button _startButton;
|
|
|
|
[SerializeField] private Button _closeButton;
|
|
|
|
[SerializeField] private GameObject startPanel;
|
|
|
|
[SerializeField] private GameObject packPanel;
|
|
|
|
[SerializeField] private Button packButton;
|
|
|
|
[SerializeField] private GameObject winPanel;
|
|
|
|
[SerializeField] private GameObject losePanel;
|
|
|
|
[SerializeField] private Button winrestButton;
|
|
|
|
[SerializeField] private Button wincloseButton;
|
|
|
|
[SerializeField] private Button loseRestButton;
|
|
|
|
[SerializeField] private Button loseCloseButton;
|
|
|
|
|
|
|
|
[SerializeField] private TextMeshProUGUI _textMeshPro;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
ins = this;
|
|
|
|
_startButton.onClick.AddListener(StartPanelEvent);
|
|
|
|
_closeButton.onClick.AddListener(ClosePanelEvent);
|
|
|
|
winrestButton.onClick.AddListener(StartPanelEvent);
|
|
|
|
wincloseButton.onClick.AddListener(ClosePanelEvent);
|
|
|
|
loseRestButton.onClick.AddListener(StartPanelEvent);
|
|
|
|
loseCloseButton.onClick.AddListener(ClosePanelEvent);
|
|
|
|
packButton.onClick.AddListener(() =>
|
|
|
|
{
|
|
|
|
GameManager.ins.PackEvent();
|
|
|
|
_textMeshPro.text = "剩余箱子数" + (GameManager.ins.index - 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ClosePanelEvent()
|
|
|
|
{
|
|
|
|
GameManager.ins.start = false;
|
|
|
|
startPanel.SetActive(true);
|
|
|
|
winPanel.SetActive(false);
|
|
|
|
packPanel.SetActive(false);
|
|
|
|
losePanel.SetActive(false);
|
|
|
|
_closeButton.gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void StartPanelEvent()
|
|
|
|
{
|
|
|
|
startPanel.SetActive(false);
|
|
|
|
_closeButton.gameObject.SetActive(true);
|
|
|
|
winPanel.SetActive(false);
|
|
|
|
losePanel.SetActive(false);
|
|
|
|
packPanel.SetActive(true);
|
|
|
|
GameManager.ins.ResetPack();
|
|
|
|
_textMeshPro.text = "剩余箱子数:" + (GameManager.ins.index - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Win()
|
|
|
|
{
|
|
|
|
winPanel.SetActive(true);
|
|
|
|
_closeButton.gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
public void Lose()
|
|
|
|
{
|
|
|
|
_closeButton.gameObject.SetActive(false);
|
|
|
|
losePanel.SetActive(true);
|
|
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
ClosePanelEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2024-10-25 18:09:59 +08:00
|
|
|
}
|