chicken_dy/Assets/Scripts/UI/CustomControl/ButtonEndings.cs

70 lines
1.5 KiB
C#
Raw Normal View History

2022-02-09 08:35:01 +00:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonEndings : MonoBehaviour
{
public Action DelClick;
[SerializeField] GameObject mGobIncomplete;
[SerializeField] GameObject mGobComplete;
[SerializeField] Text mTxtUnlocked;
[SerializeField] Text mTxtTotal;
[SerializeField] Image mImgIcon;
[SerializeField] GameObject mGobTips;
2022-02-10 10:17:22 +00:00
[SerializeField] GameObject mGobNew;
2022-02-09 08:35:01 +00:00
private bool mIsCompleted;
private void Awake()
{
Button tBtn = GetComponent<Button>();
UIUtils.BindBtn(tBtn, OnClick);
}
public void Init(int pLevelID, int pUnlockCount, int pTotalCount)
{
mIsCompleted = pUnlockCount == pTotalCount;
mGobIncomplete.SetActive(!mIsCompleted);
mGobComplete.SetActive(mIsCompleted);
if (!mIsCompleted)
{
mTxtUnlocked.text = pUnlockCount.ToString();
mTxtTotal.text = pTotalCount.ToString();
}
else
{
mImgIcon.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetLevelIconSmall(pLevelID));
}
ShowTip(false);
}
public void ShowTip(bool pShow)
{
2022-02-10 10:17:22 +00:00
if (mGobTips != null)
{
mGobTips.SetActive(pShow);
}
}
public void ShowNew(bool pShow)
{
if (mGobNew != null)
{
mGobNew.SetActive(pShow);
}
2022-02-09 08:35:01 +00:00
}
private void OnClick()
{
DelClick?.Invoke();
}
}