52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | |||
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using UnityEngine; | |||
|  | using UnityEngine.UI; | |||
|  | 
 | |||
|  | public class ResBar : MonoBehaviour | |||
|  | { | |||
|  |     public Action DelResRefresh; | |||
|  | 
 | |||
|  |     [SerializeField] ResShower mResShower; | |||
|  | 
 | |||
|  |     [SerializeField] Image mImgResIcon; | |||
|  | 
 | |||
|  |     [SerializeField] Sprite mSprNormal; | |||
|  |     [SerializeField] Sprite mSprRobux; | |||
|  | 
 | |||
|  |     [SerializeField] int mFlyDelta = 1; | |||
|  |     [SerializeField] int mFlyMin = 1; | |||
|  |     [SerializeField] int mFlyMax = 20; | |||
|  | 
 | |||
|  |     public void InitBar(int pRes, bool pShowRobux = true, Camera pMainCam = null, Camera pUICam = null) | |||
|  |     { | |||
|  |         mResShower.DelResRefresh = NotifyResRefresh; | |||
|  |         mResShower.Init(pMainCam, pUICam); | |||
|  |         RefreshRes(pRes); | |||
|  | 
 | |||
|  |         mImgResIcon.sprite = pShowRobux ? mSprRobux : mSprNormal; | |||
|  |         mImgResIcon.SetNativeSize(); | |||
|  |     } | |||
|  | 
 | |||
|  |     public void FlyRes(Vector3 pPos, int pAdd, int pFinal) | |||
|  |     { | |||
|  |         mResShower.FlyRes(pPos, Mathf.Clamp(pAdd, mFlyMin, mFlyMax), pAdd / mFlyDelta, pFinal); | |||
|  |     } | |||
|  | 
 | |||
|  |     public void PopRes(int pDelta, int pFinalDiamond) | |||
|  |     { | |||
|  |         mResShower.PopResChange(pDelta); | |||
|  |         RefreshRes(pFinalDiamond); | |||
|  |     } | |||
|  | 
 | |||
|  |     public void RefreshRes(int pDiamond) | |||
|  |     { | |||
|  |         mResShower.RefreshRes(pDiamond); | |||
|  |     } | |||
|  | 
 | |||
|  |     private void NotifyResRefresh() | |||
|  |     { | |||
|  |         DelResRefresh?.Invoke(); | |||
|  |     } | |||
|  | } |