|
|
|
using MS;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
[ExecuteInEditMode]
|
|
|
|
public class LevelGroupButton : MonoBehaviour
|
|
|
|
{
|
|
|
|
public LevelGroup levelGroup;
|
|
|
|
|
|
|
|
// Use TMP_Text instead of Text
|
|
|
|
public TMP_Text TitleLbl;
|
|
|
|
public TMP_Text LevelCompletdLbl;
|
|
|
|
public GameObject AwardGoldImage;
|
|
|
|
public int TotalLevelsCompleted;
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
UpdateUI();
|
|
|
|
GetComponent<Button>().onClick.AddListener(delegate
|
|
|
|
{
|
|
|
|
HomeScene.instance.ShowDetailLevel(this);
|
|
|
|
HomeScene.instance.PlayButton();
|
|
|
|
GameObject.FindWithTag("LevelGroupPopup").GetComponent<Popup>().Close();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
UpdateUI(); // If more logic is needed, add it here
|
|
|
|
}
|
|
|
|
|
|
|
|
[ContextMenu("UpdateUI")]
|
|
|
|
public void UpdateUI()
|
|
|
|
{
|
|
|
|
base.name = levelGroup.LevelGroupName;
|
|
|
|
TitleLbl.text = base.name.ToUpper();
|
|
|
|
LevelCompletdLbl.text = levelGroup.CompletedLevel + " / " + levelGroup.TotalLevel;
|
|
|
|
|
|
|
|
// Decide between SetActive or using _2dxFX_GrayScale
|
|
|
|
if (levelGroup.CompletedLevel >= 5)
|
|
|
|
{
|
|
|
|
AwardGoldImage.SetActive(true); // Show award if completed levels >= 5
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel >= levelGroup.TotalLevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
TotalLevelsCompleted = levelGroup.CompletedLevel;
|
|
|
|
}
|
|
|
|
}
|