WXGame/box1/Assets/Script/UI/MainPanel.cs

112 lines
3.1 KiB
C#
Raw Normal View History

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 GameObject startPanel;
2024-11-08 18:21:41 +08:00
[SerializeField] private GameObject levelPanel;
2024-11-21 09:35:48 +08:00
[SerializeField] private PackPanel packPanel;
2024-10-24 16:54:32 +08:00
[SerializeField] private Button packButton;
[SerializeField] private GameObject winPanel;
[SerializeField] private GameObject losePanel;
2024-11-08 18:21:41 +08:00
[SerializeField] private GameObject tourPanel;
2024-10-24 16:54:32 +08:00
[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);
}
2024-10-29 15:22:32 +08:00
/// <summary>
/// 关闭页面方法
/// </summary>
2024-11-21 09:35:48 +08:00
public void ClosePanelEvent()
2024-10-24 16:54:32 +08:00
{
GameManager.ins.start = false;
2024-11-21 09:35:48 +08:00
// startPanel.SetActive(true);
// winPanel.SetActive(false);
// packPanel.gameObject.SetActive(false);
// losePanel.SetActive(false);
// tourPanel.SetActive(false);
OpenLevelPanel();
2024-11-08 18:21:41 +08:00
}
public void OpenLevelPanel()
{
startPanel.SetActive(false);
winPanel.SetActive(false);
losePanel.SetActive(false);
2024-11-21 09:35:48 +08:00
packPanel.gameObject.SetActive(false);
2024-11-08 18:21:41 +08:00
levelPanel.SetActive(true);
2024-11-21 09:35:48 +08:00
tourPanel.SetActive(false);
2024-11-08 18:21:41 +08:00
levelPanel.GetComponent<LevelPanel>().StartPanel(DataManager.chapter);
2024-10-24 16:54:32 +08:00
}
2024-10-29 15:22:32 +08:00
/// <summary>
/// 开始游戏页面方法
/// </summary>
2024-11-08 18:21:41 +08:00
public void StartPanelEvent()
2024-10-24 16:54:32 +08:00
{
startPanel.SetActive(false);
winPanel.SetActive(false);
losePanel.SetActive(false);
2024-11-21 09:35:48 +08:00
packPanel.gameObject.SetActive(true);
2024-10-24 16:54:32 +08:00
GameManager.ins.ResetPack();
_textMeshPro.text = "剩余箱子数:" + (GameManager.ins.index - 1);
2024-11-21 09:35:48 +08:00
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();
2024-10-24 16:54:32 +08:00
}
2024-10-29 15:22:32 +08:00
/// <summary>
/// 胜利页面
/// </summary>
2024-10-24 16:54:32 +08:00
public void Win()
{
winPanel.SetActive(true);
}
2024-10-29 15:22:32 +08:00
/// <summary>
/// 失败页面
/// </summary>
2024-10-24 16:54:32 +08:00
public void Lose()
{
losePanel.SetActive(true);
}
// Start is called before the first frame update
void Start()
{
ClosePanelEvent();
}
2024-11-21 09:35:48 +08:00
public void ResetPropattributes()
{
packPanel.ResetPropattributes();
}
2024-10-24 16:54:32 +08:00
// Update is called once per frame
void Update()
{
}
2024-10-25 18:09:59 +08:00
}