12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using Game;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Comp
- {
- public class LiftButtonComp : MonoBehaviour
- {
- private Button _button;
- private void Start()
- {
- _button = GetComponent<Button>();
- }
- private void Update()
- {
- if (GameCore.Instance.localPlayer == null) return;
- var lastHpPercent = (float)GameCore.Instance.localPlayer.runTimeHp / GameCore.Instance.localPlayer.hp;
- if (GameCore.Instance.GetCurState() != null && GameCore.Instance.battleState != null &&
- GameCore.Instance.GetCurState() == GameCore.Instance.battleState && GameCore.Instance.liftTimes > 0 )
- {
- #if UNITY_EDITOR
- _button.interactable = true;
- #else
- if(lastHpPercent <= 0.5f){
- _button.interactable = true;
- } else {
- _button.interactable = false;
- }
- #endif
- }
- else
- {
- _button.interactable = false;
- }
- }
- }
- }
|