125 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			125 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| using DG.Tweening;
 | |
| 
 | |
| namespace MMO
 | |
| {
 | |
|     public class MMOUISkinPiece : MMOUIBase
 | |
|     {
 | |
|         [SerializeField] Image mImgIcon;
 | |
|         [SerializeField] Text mTxtName;
 | |
|         [SerializeField] Text mTxtAddCount;
 | |
| 
 | |
|         [SerializeField] Image mImgProgress;
 | |
|         [SerializeField] Text mTxtProgress;
 | |
| 
 | |
|         [SerializeField] Button mBtnDouble;
 | |
|         [SerializeField] Button mBtnClaim;
 | |
| 
 | |
|         [SerializeField] GameObject mGobSkin;
 | |
| 
 | |
|         [SerializeField] Transform mTsfHead;
 | |
|         [SerializeField] Transform mTsfBtns;
 | |
|         [SerializeField] Transform mTsfCard;
 | |
|         [SerializeField] Transform mTsfFront;
 | |
|         [SerializeField] Transform mTsfBack;
 | |
| 
 | |
|         private MMODataSkin mData;
 | |
|         private int mAddCount;
 | |
| 
 | |
|         protected override void OnInit()
 | |
|         {
 | |
|             base.OnInit();
 | |
| 
 | |
|             BindBtn(mBtnDouble, OnClickDouble);
 | |
|             BindBtn(mBtnClaim, OnClickClaim);
 | |
|         }
 | |
| 
 | |
|         public override void OnOpen()
 | |
|         {
 | |
|             base.OnOpen();
 | |
| 
 | |
|             mBtnDouble.enabled = true;
 | |
|             mBtnClaim.enabled = true;
 | |
| 
 | |
|             mGobSkin.SetActive(false);
 | |
|             mGobSkin.transform.localScale = Vector3.one;
 | |
|             mTsfHead.localScale = Vector3.zero;
 | |
|             mTsfBtns.localScale = Vector3.zero;
 | |
|             mTsfCard.localPosition = Vector3.zero;
 | |
|             mTsfCard.localScale = Vector3.one;
 | |
|             mTsfBack.localScale = Vector3.one;
 | |
|             mTsfFront.localScale = new Vector3(0, 1, 1);
 | |
| 
 | |
|             mTsfCard.DOKill();
 | |
| 
 | |
|             Sequence tShowSQ = DOTween.Sequence();
 | |
| 
 | |
|             tShowSQ.Append(mTsfCard.DOLocalJump(Vector3.up * 100, 200, 1, 0.3f));
 | |
|             tShowSQ.Join(mTsfBack.DOScaleX(0, 0.3f).SetEase(Ease.Linear));
 | |
|             tShowSQ.Append(mTsfFront.DOScaleX(1, 0.3f).SetEase(Ease.Linear));
 | |
|             tShowSQ.Join(mTsfHead.DOScale(1, 0.3f).SetEase(Ease.OutBack));
 | |
|             tShowSQ.Join(mTsfBtns.DOScale(1, 0.3f).SetEase(Ease.OutBack));
 | |
| 
 | |
|             tShowSQ.Play();
 | |
|         }
 | |
| 
 | |
|         public void ConfigSkin(MMODataSkin pData, int pAddCount)
 | |
|         {
 | |
|             mData = pData;
 | |
|             mAddCount = pAddCount;
 | |
| 
 | |
|             mImgIcon.sprite = MMOResourceManager.Instance.LoadRes<Sprite>(string.Format("MMOImage/SkinIcon/Skin{0:D3}", mData.SkinID));
 | |
|             mTxtName.text = mData.SkinName;
 | |
|             mTxtAddCount.text = "+" + mAddCount;
 | |
| 
 | |
|             int tOwnedCount = MMOUserData.Instance.GetSkinPieceCount(pData.SkinID);
 | |
|             mImgProgress.fillAmount = tOwnedCount / (float)mData.TotalCount;
 | |
|             mTxtProgress.text = string.Format("{0}/{1}", tOwnedCount, mData.TotalCount);
 | |
|         }
 | |
| 
 | |
|         private void OnClickDouble()
 | |
|         {
 | |
|             MMOInnerSDKManager.Instance.ShowRV(MMOEventValue.RvDoubleSkin, DoubleGet);
 | |
|         }
 | |
| 
 | |
|         private void DoubleGet(bool pResult)
 | |
|         {
 | |
|             if (pResult)
 | |
|             {
 | |
|                 MMOInnerSDKManager.Instance.LogClaimSkin(MMOEventValue.Double_Claim);
 | |
|                 MMOUserData.Instance.AddSkinPieceCount(mData.SkinID, mAddCount);
 | |
|                 mTxtAddCount.text = "+" + (mAddCount * 2);
 | |
| 
 | |
|                 Collect();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void OnClickClaim()
 | |
|         {
 | |
|             MMOInnerSDKManager.Instance.LogClaimSkin(MMOEventValue.Normal_Claim);
 | |
|             Collect();
 | |
|         }
 | |
| 
 | |
|         private void Collect()
 | |
|         {
 | |
|             mBtnDouble.enabled = false;
 | |
|             mBtnClaim.enabled = false;
 | |
| 
 | |
|             Sequence tCollectSQ = DOTween.Sequence();
 | |
| 
 | |
|             tCollectSQ.Append(mTsfCard.DOScale(0.2f, 0.5f).SetEase(Ease.InBack));
 | |
|             tCollectSQ.Join(mTsfHead.DOScale(0, 0.3f).SetEase(Ease.InBack));
 | |
|             tCollectSQ.Join(mTsfBtns.DOScale(0, 0.3f).SetEase(Ease.InBack));
 | |
|             tCollectSQ.AppendCallback(() => mGobSkin.SetActive(true));
 | |
|             tCollectSQ.Append(mTsfCard.DOJump(mGobSkin.transform.position, 100, 1, 0.8f));
 | |
|             tCollectSQ.Append(mTsfCard.DOScale(0, 0.3f));
 | |
|             //tCollectSQ.Join(mGobSkin.transform.DOScale(0, 0.3f));
 | |
|             tCollectSQ.AppendCallback(Close);
 | |
| 
 | |
|             tCollectSQ.Play();
 | |
|         }
 | |
|     }
 | |
| } |