73 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| namespace MMO
 | |
| {
 | |
|     public class MMOSkinCell : MMOListCell
 | |
|     {
 | |
|         public Action<int> DelRedeem;
 | |
|         public Action<int> DelWatchRV;
 | |
| 
 | |
|         [SerializeField] Image mImgIcon;
 | |
|         [SerializeField] Text mTxtName;
 | |
| 
 | |
|         [SerializeField] Image mImgProgress;
 | |
|         [SerializeField] Text mTxtProgress;
 | |
| 
 | |
|         [SerializeField] GameObject mGobNoAd;
 | |
|         [SerializeField] GameObject mGobComplete;
 | |
| 
 | |
|         [SerializeField] Button mBtnWatchAd;
 | |
|         [SerializeField] Button mBtnRedeem;
 | |
| 
 | |
|         private MMODataSkin mData;
 | |
| 
 | |
|         private void Awake()
 | |
|         {
 | |
|             mBtnRedeem.onClick.AddListener(OnClickRedeem);
 | |
|             mBtnWatchAd.onClick.AddListener(OnClickWatchAd);
 | |
|         }
 | |
| 
 | |
|         public void ConfigSkin(MMODataSkin pData)
 | |
|         {
 | |
|             mData = pData;
 | |
| 
 | |
|             mImgIcon.sprite = MMOResourceManager.Instance.LoadRes<Sprite>(string.Format("MMOImage/SkinIcon/Skin{0:D3}", mData.SkinID));
 | |
|             mTxtName.text = mData.SkinName;
 | |
| 
 | |
|             int tOwnedCount = MMOUserData.Instance.GetSkinPieceCount(pData.SkinID);
 | |
|             mImgProgress.fillAmount = tOwnedCount / (float)mData.TotalCount;
 | |
|             mTxtProgress.text = string.Format("{0}/{1}", tOwnedCount, mData.TotalCount);
 | |
| 
 | |
|             if (!MMOUserData.Instance.IsSkinRedeemed(mData.SkinID))
 | |
|             {
 | |
|                 bool tIsSkinADAvailable = MMOUserData.Instance.IsSkinAdAvailable(mData.SkinID);
 | |
| 
 | |
|                 mBtnRedeem.gameObject.SetActive(tOwnedCount >= mData.TotalCount);
 | |
|                 mBtnWatchAd.gameObject.SetActive(tOwnedCount < mData.TotalCount && tIsSkinADAvailable);
 | |
|                 mGobNoAd.SetActive(tOwnedCount < mData.TotalCount && !tIsSkinADAvailable);
 | |
|                 mGobComplete.SetActive(false);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 mBtnRedeem.gameObject.SetActive(false);
 | |
|                 mBtnWatchAd.gameObject.SetActive(false);
 | |
|                 mGobNoAd.SetActive(false);
 | |
|                 mGobComplete.SetActive(true);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void OnClickRedeem()
 | |
|         {
 | |
|             DelRedeem?.Invoke(mIndex);
 | |
|         }
 | |
| 
 | |
|         private void OnClickWatchAd()
 | |
|         {
 | |
|             DelWatchRV?.Invoke(mIndex);
 | |
|         }
 | |
|     }
 | |
| } |