53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using DG.Tweening;
 | |
| 
 | |
| public class SellSlot : MonoBehaviour
 | |
| {
 | |
|     public int CurPrice => mCurSellPrice;
 | |
| 
 | |
|     [SerializeField] TextMesh mTxtSellTag;
 | |
|     [SerializeField] TextMesh mTxtSellPrice;
 | |
|     [SerializeField] MeshRenderer mRdrPlane;
 | |
|     [SerializeField] Material mMatNormal;
 | |
|     [SerializeField] Material mMatTouched;
 | |
| 
 | |
|     private int mCurSellPrice;
 | |
| 
 | |
|     public void Show(bool pShow)
 | |
|     {
 | |
|         transform.DOMove(new Vector3(0, 0, pShow ? -14 : -25), 0.2f).SetEase(Ease.Linear);
 | |
| 
 | |
|         PanelMain tUIMain = UIManager.Instance.GetUI<PanelMain>();
 | |
|         if (tUIMain != null)
 | |
|         {
 | |
|             tUIMain.ShowBottom(!pShow);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void SetSellPrice(int pPrice)
 | |
|     {
 | |
|         mCurSellPrice = pPrice;
 | |
| 
 | |
|         mTxtSellTag.text = LanguageConfig.Instance.GetText("Sell");
 | |
|         mTxtSellPrice.text = "+" + UIUtils.NumForShort(mCurSellPrice);
 | |
|     }
 | |
| 
 | |
|     public void SetTouched(bool pTouched)
 | |
|     {
 | |
|         mRdrPlane.material = pTouched ? mMatTouched : mMatNormal;
 | |
|     }
 | |
| 
 | |
|     public void Sell()
 | |
|     {
 | |
|         AudioManager.Instance.PlaySound(AudioClipType.GetCoin);
 | |
|         PlayerData.Instance.Coin += mCurSellPrice;
 | |
|         UIUtils.FlyCoin(new Vector3(540, 480, 0), mCurSellPrice);
 | |
| 
 | |
|         UIManager.Instance.GetUI<PanelMain>().RefreshButtons();
 | |
| 
 | |
|         SetTouched(false);
 | |
|         SetSellPrice(0);
 | |
|     }
 | |
| } |