2022-02-10 09:21:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
2022-02-15 04:16:18 +00:00
|
|
|
|
using DG.Tweening;
|
2022-02-10 09:21:59 +00:00
|
|
|
|
|
2022-02-13 09:36:12 +00:00
|
|
|
|
public class LevelCell : MonoBehaviour
|
2022-02-10 09:21:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
public Action<int> DelClick;
|
|
|
|
|
|
|
2022-02-16 04:11:28 +00:00
|
|
|
|
public Transform CurrentSignTrans => mGobCurrent.transform;
|
|
|
|
|
|
|
2022-02-10 09:21:59 +00:00
|
|
|
|
[SerializeField] Button mBtnBg;
|
|
|
|
|
|
[SerializeField] ImageNum mInmLevel;
|
|
|
|
|
|
[SerializeField] Image mImgIconBg;
|
|
|
|
|
|
[SerializeField] Image mImgIcon;
|
|
|
|
|
|
[SerializeField] GameObject mGobDone;
|
|
|
|
|
|
[SerializeField] GameObject mGobComplete;
|
|
|
|
|
|
[SerializeField] Image mImgProgress;
|
2022-02-15 07:43:03 +00:00
|
|
|
|
[SerializeField] GameObject mGobCurrent;
|
2022-02-10 09:21:59 +00:00
|
|
|
|
|
2022-04-01 14:07:21 +00:00
|
|
|
|
[SerializeField] Button mBtnUnlock;
|
|
|
|
|
|
|
2022-02-13 09:36:12 +00:00
|
|
|
|
[SerializeField] GameObject mGobEmpty;
|
2022-02-15 04:16:18 +00:00
|
|
|
|
[SerializeField] Button mBtnComingSoon;
|
|
|
|
|
|
[SerializeField] Image mImgComingSoon;
|
2022-02-10 09:21:59 +00:00
|
|
|
|
|
2022-02-13 09:36:12 +00:00
|
|
|
|
private int mIndex;
|
|
|
|
|
|
private int mLevelID;
|
|
|
|
|
|
|
2022-02-10 09:21:59 +00:00
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
2022-02-15 04:16:18 +00:00
|
|
|
|
UIUtils.BindBtn(mBtnBg, OnClickBg);
|
2022-04-01 14:07:21 +00:00
|
|
|
|
UIUtils.BindBtn(mBtnUnlock, OnClickBg);
|
2022-02-16 09:00:22 +00:00
|
|
|
|
UIUtils.BindBtn(mBtnComingSoon, OnClickComingSoon, AudioClipType.New);
|
2022-02-10 09:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-13 09:36:12 +00:00
|
|
|
|
public void Init(int pIndex)
|
2022-02-10 09:21:59 +00:00
|
|
|
|
{
|
2022-02-13 09:36:12 +00:00
|
|
|
|
mIndex = pIndex;
|
|
|
|
|
|
|
2022-02-10 09:21:59 +00:00
|
|
|
|
mLevelID = GameConfig.Instance.LevelSort[mIndex];
|
|
|
|
|
|
LevelData tLvData = GameConfig.Instance.GetLevelData(mLevelID);
|
|
|
|
|
|
|
|
|
|
|
|
mInmLevel.SetNum(mIndex + 1);
|
|
|
|
|
|
if (ColorUtility.TryParseHtmlString(tLvData.LevelColorCode, out Color tBgColor))
|
|
|
|
|
|
{
|
|
|
|
|
|
mImgIconBg.color = tBgColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mImgIcon.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetLevelIconSmall(mLevelID));
|
|
|
|
|
|
|
|
|
|
|
|
int tUnlockedEndingCount = PlayerData.Instance.EndingCountOfLevel(mLevelID);
|
|
|
|
|
|
bool tIsAllEndingsDone = tUnlockedEndingCount == tLvData.Endings.Count;
|
|
|
|
|
|
mGobDone.SetActive(tIsAllEndingsDone);
|
|
|
|
|
|
mGobComplete.SetActive(tIsAllEndingsDone);
|
|
|
|
|
|
|
|
|
|
|
|
mImgProgress.fillAmount = (float)tUnlockedEndingCount / tLvData.Endings.Count;
|
2022-02-13 09:36:12 +00:00
|
|
|
|
|
|
|
|
|
|
mBtnBg.gameObject.SetActive(true);
|
2022-04-01 14:07:21 +00:00
|
|
|
|
mBtnUnlock.gameObject.SetActive(false);
|
2022-02-15 04:16:18 +00:00
|
|
|
|
mGobEmpty.SetActive(false);
|
|
|
|
|
|
mBtnComingSoon.gameObject.SetActive(false);
|
2022-02-13 09:36:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-15 07:43:03 +00:00
|
|
|
|
public void ShowCurrent(bool pShow)
|
|
|
|
|
|
{
|
2022-02-16 04:11:28 +00:00
|
|
|
|
mGobCurrent.SetActive(true);//always show,only use transform
|
|
|
|
|
|
//mGobCurrent.SetActive(pShow);
|
2022-02-15 07:43:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-01 14:07:21 +00:00
|
|
|
|
public void SetUnlock()
|
|
|
|
|
|
{
|
|
|
|
|
|
mBtnBg.gameObject.SetActive(false);
|
|
|
|
|
|
mBtnUnlock.gameObject.SetActive(true);
|
|
|
|
|
|
mGobEmpty.SetActive(false);
|
|
|
|
|
|
mBtnComingSoon.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-13 09:36:12 +00:00
|
|
|
|
public void SetEmpty()
|
|
|
|
|
|
{
|
|
|
|
|
|
mBtnBg.gameObject.SetActive(false);
|
2022-04-01 14:07:21 +00:00
|
|
|
|
mBtnUnlock.gameObject.SetActive(false);
|
2022-02-15 04:16:18 +00:00
|
|
|
|
mGobEmpty.SetActive(true);
|
|
|
|
|
|
mBtnComingSoon.gameObject.SetActive(false);
|
2022-02-13 09:36:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetComingSoon()
|
|
|
|
|
|
{
|
|
|
|
|
|
mBtnBg.gameObject.SetActive(false);
|
2022-04-01 14:07:21 +00:00
|
|
|
|
mBtnUnlock.gameObject.SetActive(false);
|
2022-02-15 04:16:18 +00:00
|
|
|
|
mGobEmpty.SetActive(false);
|
|
|
|
|
|
mBtnComingSoon.gameObject.SetActive(true);
|
2022-02-10 09:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-15 04:16:18 +00:00
|
|
|
|
private void OnClickBg()
|
2022-02-10 09:21:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
DelClick?.Invoke(mIndex);
|
|
|
|
|
|
}
|
2022-02-15 04:16:18 +00:00
|
|
|
|
|
|
|
|
|
|
private void OnClickComingSoon()
|
|
|
|
|
|
{
|
|
|
|
|
|
mImgComingSoon.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
|
|
|
|
mImgComingSoon.color = Color.white;
|
|
|
|
|
|
mImgComingSoon.rectTransform.localScale = Vector3.zero;
|
|
|
|
|
|
|
|
|
|
|
|
mImgComingSoon.rectTransform.DOKill();
|
2022-02-15 04:43:25 +00:00
|
|
|
|
mImgComingSoon.rectTransform.DOScale(1, 0.5f).SetEase(Ease.OutBounce);
|
2022-02-15 04:16:18 +00:00
|
|
|
|
|
|
|
|
|
|
mImgComingSoon.DOKill();
|
2022-02-15 04:43:25 +00:00
|
|
|
|
mImgComingSoon.DOFade(0, 0.5f).SetDelay(2f);
|
2022-02-15 04:16:18 +00:00
|
|
|
|
}
|
2022-02-10 09:21:59 +00:00
|
|
|
|
}
|