| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | using UnityEngine.Events; | 
					
						
							|  |  |  |  | using UnityEngine.UI; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public static class UIUtils | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public static void BindBtn(Button pBtn, UnityAction pDel, AudioClipType pSound = AudioClipType.None) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         pBtn.onClick.AddListener(pDel); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         pSound = AudioClipType.Click; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         pBtn.onClick.AddListener(() => { AudioManager.Instance.PlaySound(pSound); }); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void ShowTips(string pTips) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         UIManager.Instance.OpenUI<PanelTips>().ShowTips(pTips); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void ShowNoAdsTip() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         ShowTips(LanguageConfig.Instance.GetText("NoAdsTip")); | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         MMOModule.Instance.ShowTip(LanguageConfig.Instance.GetText("NoAdsTip")); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void FlyDiamond(Vector3 pPos, int pAdd) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         PanelTopBar tTopUI = UIManager.Instance.GetUI<PanelTopBar>(); | 
					
						
							|  |  |  |  |         if (tTopUI != null) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tTopUI.FlyDiamond(pPos, pAdd); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void DropDiamond(int pDelta) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         PanelTopBar tTopUI = UIManager.Instance.GetUI<PanelTopBar>(); | 
					
						
							|  |  |  |  |         if (tTopUI != null) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tTopUI.PopDiamond(-pDelta); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void RefreshDiamond() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         PanelTopBar tTopUI = UIManager.Instance.GetUI<PanelTopBar>(); | 
					
						
							|  |  |  |  |         if (tTopUI != null) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tTopUI.RefreshDiamond(); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void FlyCoin(Vector3 pPos, int pAdd) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         PanelTopBar tTopUI = UIManager.Instance.GetUI<PanelTopBar>(); | 
					
						
							|  |  |  |  |         if (tTopUI != null) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tTopUI.FlyCoin(pPos, pAdd); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void DropCoin(int pDelta) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         PanelTopBar tTopUI = UIManager.Instance.GetUI<PanelTopBar>(); | 
					
						
							|  |  |  |  |         if (tTopUI != null) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tTopUI.PopCoin(-pDelta); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void RefreshCoin() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         PanelTopBar tTopUI = UIManager.Instance.GetUI<PanelTopBar>(); | 
					
						
							|  |  |  |  |         if (tTopUI != null) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tTopUI.RefreshCoin(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     const int BILLION = 1000000000; | 
					
						
							|  |  |  |  |     const int MILLION = 1000000; | 
					
						
							|  |  |  |  |     const int THOUSAND = 1000; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static string NumForShort(int pNum) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         string tNumStr = pNum.ToString(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         float tShortNum = 0; | 
					
						
							|  |  |  |  |         if (pNum >= BILLION) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tShortNum = pNum / (float)BILLION; | 
					
						
							|  |  |  |  |             tNumStr = (tShortNum - ((int)tShortNum)) >= 0.1f ? string.Format("{0:F1}B", tShortNum) : string.Format("{0}B", (int)tShortNum); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else if (pNum >= MILLION) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tShortNum = pNum / (float)MILLION; | 
					
						
							|  |  |  |  |             tNumStr = (tShortNum - ((int)tShortNum)) >= 0.1f ? string.Format("{0:F1}M", tShortNum) : string.Format("{0}M", (int)tShortNum); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else if (pNum >= THOUSAND * 10) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             tShortNum = pNum / (float)THOUSAND; | 
					
						
							|  |  |  |  |             tNumStr = (tShortNum - ((int)tShortNum)) >= 0.1f ? string.Format("{0:F1}K", tShortNum) : string.Format("{0}K", (int)tShortNum); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return tNumStr; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static void JumpText(Transform pTrans, string pText, Color pColor, int pFontSize = 50) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (GameConfig.Instance.JumpText) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             UIManager.Instance.GetUI<PanelGame>().CreateHudJumpText(pTrans, 1.5f, pText, pColor, pFontSize); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | } |