112 lines
3.1 KiB
C#
112 lines
3.1 KiB
C#
|
|
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 GameObject startPanel;
|
|
[SerializeField] private GameObject levelPanel;
|
|
[SerializeField] private PackPanel packPanel;
|
|
[SerializeField] private Button packButton;
|
|
[SerializeField] private GameObject winPanel;
|
|
[SerializeField] private GameObject losePanel;
|
|
[SerializeField] private GameObject tourPanel;
|
|
[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;
|
|
winrestButton.onClick.AddListener(StartPanelEvent);
|
|
wincloseButton.onClick.AddListener(ClosePanelEvent);
|
|
loseRestButton.onClick.AddListener(StartPanelEvent);
|
|
loseCloseButton.onClick.AddListener(ClosePanelEvent);
|
|
}
|
|
/// <summary>
|
|
/// 关闭页面方法
|
|
/// </summary>
|
|
public void ClosePanelEvent()
|
|
{
|
|
GameManager.ins.start = false;
|
|
// startPanel.SetActive(true);
|
|
// winPanel.SetActive(false);
|
|
// packPanel.gameObject.SetActive(false);
|
|
// losePanel.SetActive(false);
|
|
// tourPanel.SetActive(false);
|
|
OpenLevelPanel();
|
|
}
|
|
|
|
public void OpenLevelPanel()
|
|
{
|
|
startPanel.SetActive(false);
|
|
winPanel.SetActive(false);
|
|
losePanel.SetActive(false);
|
|
packPanel.gameObject.SetActive(false);
|
|
levelPanel.SetActive(true);
|
|
tourPanel.SetActive(false);
|
|
levelPanel.GetComponent<LevelPanel>().StartPanel(DataManager.chapter);
|
|
}
|
|
/// <summary>
|
|
/// 开始游戏页面方法
|
|
/// </summary>
|
|
public void StartPanelEvent()
|
|
{
|
|
startPanel.SetActive(false);
|
|
winPanel.SetActive(false);
|
|
losePanel.SetActive(false);
|
|
packPanel.gameObject.SetActive(true);
|
|
GameManager.ins.ResetPack();
|
|
_textMeshPro.text = "剩余箱子数:" + (GameManager.ins.index - 1);
|
|
ResetPropattributes();
|
|
}
|
|
|
|
public void StartTourPanel()
|
|
{
|
|
GameManager.ins.start = false;
|
|
startPanel.SetActive(false);
|
|
winPanel.SetActive(false);
|
|
packPanel.gameObject.SetActive(false);
|
|
losePanel.SetActive(false);
|
|
tourPanel.SetActive(true);
|
|
tourPanel.GetComponent<TourPanel>().StartVoid();
|
|
}
|
|
/// <summary>
|
|
/// 胜利页面
|
|
/// </summary>
|
|
public void Win()
|
|
{
|
|
winPanel.SetActive(true);
|
|
}
|
|
/// <summary>
|
|
/// 失败页面
|
|
/// </summary>
|
|
public void Lose()
|
|
{
|
|
losePanel.SetActive(true);
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
ClosePanelEvent();
|
|
}
|
|
|
|
public void ResetPropattributes()
|
|
{
|
|
packPanel.ResetPropattributes();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
} |