2024-11-08 18:21:41 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using cfg;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
public class LevelButton : MonoBehaviour
|
|
|
|
{
|
|
|
|
private BLevel data;
|
2024-11-21 09:35:48 +08:00
|
|
|
private int levelID=0;
|
|
|
|
public LevelPanel _panel;
|
2024-11-08 18:21:41 +08:00
|
|
|
[SerializeField] private TextMeshProUGUI name;
|
|
|
|
[SerializeField] private Button _button;
|
|
|
|
[SerializeField] private GameObject back;
|
|
|
|
[SerializeField] private GameObject lockObj;
|
2024-11-21 09:35:48 +08:00
|
|
|
[SerializeField] private GameObject selectObj;
|
2024-11-08 18:21:41 +08:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
{
|
|
|
|
if (data == null)
|
|
|
|
{
|
|
|
|
back.SetActive(true);
|
|
|
|
_button.gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetLevelData(int id)
|
|
|
|
{
|
|
|
|
if (id != 0)
|
|
|
|
{
|
|
|
|
data = JsonTab.Instance.tables.Level.Get(id);
|
|
|
|
name.text = data.Name;
|
|
|
|
back.SetActive(false);
|
|
|
|
_button.gameObject.SetActive(true);
|
2024-11-21 10:26:47 +08:00
|
|
|
lockObj.SetActive(DataManager.LevelOpen(data.Front));
|
2024-11-21 09:35:48 +08:00
|
|
|
levelID = id;
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data = null;
|
|
|
|
back.SetActive(true);
|
|
|
|
_button.gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ButtonEvent()
|
|
|
|
{
|
2024-11-21 09:35:48 +08:00
|
|
|
GameManager.ins.ResetLevel(levelID);
|
|
|
|
_panel.gameObject.SetActive(false);
|
|
|
|
MainPanel.ins.StartPanelEvent();
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
_button.onClick.AddListener(ButtonEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
{
|
|
|
|
_button.onClick.RemoveListener(ButtonEvent);
|
|
|
|
}
|
|
|
|
}
|