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

142 lines
4.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;
2024-11-26 15:44:50 +08:00
[SerializeField] private GameObject startPanel;//开始界面
[SerializeField] private GameObject levelPanel;//关卡界面
[SerializeField] private PackPanel packPanel;//背包界面
[SerializeField] private WinPanel winPanel;//胜利界面
[SerializeField] private LosePanel losePanel;//失败界面
[SerializeField] private TourPanel tourPanel;//旅行界面
[SerializeField] private HomePanel homePanel;//家园界面
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;
}
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()
{
2024-11-26 15:44:50 +08:00
GameManager.ins.soundSystem.MainAudio();
2024-11-08 18:21:41 +08:00
startPanel.SetActive(false);
2024-11-26 15:44:50 +08:00
winPanel.gameObject.SetActive(false);
losePanel.gameObject.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-26 15:44:50 +08:00
tourPanel.gameObject.SetActive(false);
homePanel.gameObject.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
{
2024-11-26 15:44:50 +08:00
GameManager.ins.soundSystem.PackAudio();
2024-10-24 16:54:32 +08:00
startPanel.SetActive(false);
2024-11-29 21:37:01 +08:00
levelPanel.gameObject.SetActive(false);
2024-11-26 15:44:50 +08:00
winPanel.gameObject.SetActive(false);
losePanel.gameObject.SetActive(false);
2024-11-21 09:35:48 +08:00
packPanel.gameObject.SetActive(true);
2024-11-26 15:44:50 +08:00
packPanel.ResetTextData();
2024-12-18 11:12:52 +08:00
packPanel.StartPanel();
2024-11-26 15:44:50 +08:00
// _textMeshPro.text = "剩余箱子数:" + (GameManager.ins.index - 1);
2024-11-21 09:35:48 +08:00
ResetPropattributes();
}
public void StartTourPanel()
{
2024-11-26 15:44:50 +08:00
GameManager.ins.soundSystem.tourAudio();
2024-11-21 09:35:48 +08:00
GameManager.ins.start = false;
startPanel.SetActive(false);
2024-11-26 15:44:50 +08:00
winPanel.gameObject.SetActive(false);
2024-11-21 09:35:48 +08:00
packPanel.gameObject.SetActive(false);
2024-11-26 15:44:50 +08:00
losePanel.gameObject.SetActive(false);
tourPanel.gameObject.SetActive(true);
2024-11-21 09:35:48 +08:00
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()
{
2024-11-26 15:44:50 +08:00
winPanel.gameObject.SetActive(true);
winPanel.SaveData(GameManager.ins.level);
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 Lose()
{
2024-11-26 15:44:50 +08:00
losePanel.gameObject.SetActive(true);
losePanel.SaveData(GameManager.ins.level);
}
/// <summary>
/// 家园界面
/// </summary>
public void HomePanel()
{
DataManager.SaveAllStarNum();
homePanel.gameObject.SetActive(true);
startPanel.SetActive(false);
winPanel.gameObject.SetActive(false);
losePanel.gameObject.SetActive(false);
packPanel.gameObject.SetActive(false);
levelPanel.SetActive(false);
tourPanel.gameObject.SetActive(false);
homePanel.ResetImage();
2024-10-24 16:54:32 +08:00
}
// Start is called before the first frame update
void Start()
{
2024-12-18 11:12:52 +08:00
// ClosePanelEvent();
2024-10-24 16:54:32 +08:00
}
2024-11-21 09:35:48 +08:00
public void ResetPropattributes()
{
packPanel.ResetPropattributes();
}
2024-11-26 15:44:50 +08:00
public void AddTourPanel(int addTime)
{
GameManager.ins.soundSystem.tourAudio();
tourPanel.AddTime(addTime);
}
2024-12-18 11:12:52 +08:00
public void ResetPackLockButtonRest()
{
packPanel.ResetAddUnlock();
}
2024-10-24 16:54:32 +08:00
// Update is called once per frame
void Update()
{
}
2024-10-25 18:09:59 +08:00
}