71 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| using DG.Tweening;
 | |
| 
 | |
| public class PanelExtraCoin : BasePanel
 | |
| {
 | |
|     public Action<bool> DelExit;
 | |
| 
 | |
|     [SerializeField] CanvasGroup mCvsBg;
 | |
|     [SerializeField] RectTransform mRctBg;
 | |
| 
 | |
|     [SerializeField] RectTransform mRctChest;
 | |
|     [SerializeField] Text mTxtCoin;
 | |
| 
 | |
|     [SerializeField] Button mBtnClose;
 | |
|     [SerializeField] Button mBtnGet;
 | |
| 
 | |
|     private int mExtraCoin;
 | |
|     private bool mCoinGet;
 | |
| 
 | |
|     private void Awake()
 | |
|     {
 | |
|         UIUtils.BindBtn(mBtnClose, OnClickClose);
 | |
|         UIUtils.BindBtn(mBtnGet, OnClickGet);
 | |
|     }
 | |
| 
 | |
|     public override void OnOpen()
 | |
|     {
 | |
|         base.OnOpen();
 | |
|         mCvsBg.alpha = 0;
 | |
|         mRctBg.anchoredPosition = new Vector2(0, -160);
 | |
| 
 | |
|         mCvsBg.DOFade(1, 0.3f);
 | |
|         mRctBg.DOAnchorPosY(100, 0.3f);
 | |
| 
 | |
|         mExtraCoin = Mathf.RoundToInt((PlayerData.Instance.HumanPrice + PlayerData.Instance.MonsterPrice) * 1.25f);
 | |
|         mTxtCoin.text = UIUtils.NumForShort(mExtraCoin);
 | |
|         mCoinGet = false;
 | |
|         mBtnGet.gameObject.SetActive(true);
 | |
|     }
 | |
| 
 | |
|     private void OnClickClose()
 | |
|     {
 | |
|         mCvsBg.DOFade(0, 0.3f);
 | |
|         mRctBg.DOAnchorPosY(-160, 0.3f).onComplete = Exit;
 | |
|     }
 | |
| 
 | |
|     private void OnClickGet()
 | |
|     {
 | |
|         AdsUtils.PlayReward(TKGRVPositionName.RV_Get_MoveCoin, GetCoin);
 | |
|     }
 | |
| 
 | |
|     private void GetCoin()
 | |
|     {
 | |
|         mBtnGet.gameObject.SetActive(false);
 | |
|         mCoinGet = true;
 | |
|         PlayerData.Instance.Coin += mExtraCoin;
 | |
|         UIUtils.FlyCoin(mRctChest.position, mExtraCoin);
 | |
|         UIManager.Instance.GetUI<PanelMain>().RefreshButtons();
 | |
| 
 | |
|         TimerManager.Instance.Schedule(OnClickClose, 1.5f);
 | |
|     }
 | |
| 
 | |
|     private void Exit()
 | |
|     {
 | |
|         DelExit(mCoinGet);
 | |
|         Close();
 | |
|     }
 | |
| } |