75 lines
1.5 KiB
C#
Raw Normal View History

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;
[SerializeField] private TextMeshProUGUI name;
[SerializeField] private Button _button;
[SerializeField] private GameObject back;
[SerializeField] private GameObject lockObj;
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);
lockObj.SetActive(!DataManager.LevelOpen(id));
}
else
{
data = null;
back.SetActive(true);
_button.gameObject.SetActive(false);
}
}
private void ButtonEvent()
{
GameManager.ins.ResetPack();
}
// 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);
}
}