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

97 lines
2.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;
2022-02-11 09:21:44 +00:00
using DG.Tweening;
2022-02-09 08:35:01 +00:00
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-14 10:38:47 +00:00
[SerializeField] GameObject mGobNewTag;
[SerializeField] GameObject mGobCompleteTag;
2022-02-09 08:35:01 +00:00
private bool mIsCompleted;
private void Awake()
{
Button tBtn = GetComponent<Button>();
UIUtils.BindBtn(tBtn, OnClick, AudioClipType.Click_Tip);
2022-02-09 08:35:01 +00:00
}
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);
2022-02-14 10:38:47 +00:00
ShowNew(false);
ShowComplete(false);
2022-02-09 08:35:01 +00:00
}
public void ShowTip(bool pShow)
{
2022-02-10 10:17:22 +00:00
if (mGobTips != null)
{
mGobTips.SetActive(pShow);
}
}
public void ShowNew(bool pShow)
{
2022-02-14 10:38:47 +00:00
if (mGobNewTag != null)
2022-02-10 10:17:22 +00:00
{
2022-02-14 10:38:47 +00:00
mGobNewTag.SetActive(pShow);
2022-02-11 09:21:44 +00:00
if (pShow)
{
2022-02-14 10:38:47 +00:00
mGobNewTag.transform.localScale = Vector3.zero;
mGobNewTag.transform.DOScale(Vector3.one, 0.5f).SetEase(Ease.OutBounce);
AudioManager.Instance.PlaySound(AudioClipType.New);
2022-02-14 10:38:47 +00:00
}
}
}
public void ShowComplete(bool pShow)
{
if (mGobCompleteTag != null)
{
mGobCompleteTag.SetActive(pShow);
if (pShow)
{
mGobCompleteTag.transform.localScale = Vector3.zero;
mGobCompleteTag.transform.DOScale(Vector3.one, 0.5f).SetEase(Ease.OutBounce);
AudioManager.Instance.PlaySound(AudioClipType.Complete);
2022-02-11 09:21:44 +00:00
}
2022-02-10 10:17:22 +00:00
}
2022-02-09 08:35:01 +00:00
}
private void OnClick()
{
2022-07-27 02:30:05 +00:00
//TKGSDKManager.Instance.LogEvent(Const.AdsEvent.ClickTip, Const.AdsEvtID.Level, PlayerData.Instance.CurrentLevel.ToString());
2022-02-16 11:41:50 +00:00
2022-02-14 10:38:47 +00:00
ShowTip(false);
2022-02-09 08:35:01 +00:00
DelClick?.Invoke();
}
}