96 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			96 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
| 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();
 | |
| 
 | |
|         if (!GameConfig.Instance.IsDebug)
 | |
|         {
 | |
|             mBtnSpeed.gameObject.SetActive(PlayerData.Instance.CurrentLevel >= 3);
 | |
|         }
 | |
| 
 | |
|         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;
 | |
|     }
 | |
| 
 | |
|     //for debug
 | |
|     public void ShowSpeedBtn(bool pShow)
 | |
|     {
 | |
|         mBtnSpeed.gameObject.SetActive(pShow);
 | |
|     }
 | |
| 
 | |
|     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());
 | |
|         }
 | |
|     }
 | |
| } |