| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | using UnityEngine.UI; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public class PanelGame : BasePanel | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     [SerializeField] Transform mCtnHp; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] Text mTxtSpeed; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnSpeed; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] Text mTxtInkPercent; | 
					
						
							|  |  |  |  |     [SerializeField] Image mImgInkPercent; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobX1; | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobX2; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mTplHudHp; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private List<HudHp> mHpBarList = new List<HudHp>(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void Awake() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnSpeed, OnClickSpeed); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void Update() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         for (int i = 0; i < mHpBarList.Count; i++) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (mHpBarList[i].gameObject.activeInHierarchy) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 mHpBarList[i].Refresh(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public override void OnOpen() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.OnOpen(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         if (!GameConfig.Instance.IsDebug) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mBtnSpeed.gameObject.SetActive(PlayerData.Instance.CurrentLevel >= 3); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         SetSpeedDisplay(); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public override void OnClose() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.OnClose(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         GameManager.Instance.GameSpeed = 1; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public HudHp CreateHudHp(Transform pOwnerTrans, float pHOffset, bool pIsRed, float pScale = 1) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         HudHp tHp = Instantiate(mTplHudHp, mCtnHp).GetComponent<HudHp>(); | 
					
						
							|  |  |  |  |         tHp.gameObject.SetActive(true); | 
					
						
							|  |  |  |  |         Utils.NormalizeGameObject(tHp.gameObject); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         tHp.Init(pOwnerTrans, UIManager.Instance.UICanvas, Camera.main, pHOffset); | 
					
						
							|  |  |  |  |         tHp.InitHp(pIsRed, pScale); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mHpBarList.Add(tHp); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return tHp; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     //for debug | 
					
						
							|  |  |  |  |     public void ShowSpeedBtn(bool pShow) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mBtnSpeed.gameObject.SetActive(pShow); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     private void SetSpeedDisplay() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mTxtSpeed.text = "x " + GameManager.Instance.GameSpeed; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mGobX1.SetActive(GameManager.Instance.GameSpeed == 1); | 
					
						
							|  |  |  |  |         mGobX2.SetActive(GameManager.Instance.GameSpeed == 2); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickSpeed() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         GameManager.Instance.GameSpeed = GameManager.Instance.GameSpeed == 1 ? 2 : 1; | 
					
						
							|  |  |  |  |         SetSpeedDisplay(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (GameManager.Instance.GameSpeed == 2) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             TKGSDKManager.Instance.LogEvent(Const.AdsEvent.SpeedUp, Const.AdsKey.Level, PlayerData.Instance.CurrentLevel.ToString()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |