using System; using Framework; using Gameplay.Common; using Gameplay.Skill; using PhxhSDK; using UnityEngine; using UnityEngine.UI; public class UICommandSkillNode: UINode { public Image Image_CMSkillNormal; public Image Image_SkillProgress; public UIButtonEx Button_CMSkillPress; public Image Image_CMSkillReady; private UIWindow _bindWindow; private float _curCdProgress; private bool _isInCd; private int _skillID; public override void OnAwake() { Button_CMSkillPress.AddOutDragListener(OnOutDrag); Button_CMSkillPress.AddPointUpListener(OnPointUp); } public override void SetData(object data) { _skillID = (int)data; Init(); } public override void OnUpdate() { _curCdProgress = SkillManager.instance.playerSkillManager.GetCDProgress(_skillID); if (!_isInCd) { if (_curCdProgress > 0.001f) { ChangeState(true); } return; } if (_isInCd) { if (_curCdProgress <= 0.001f) { ChangeState(false); return; } RefreshNode(); } } public void BindWindow(UIWindow window) { _bindWindow = window; } public void Init() { _Init(); } private void _Init() { Button_CMSkillPress.gameObject.SetActive(true); Image_CMSkillNormal.gameObject.SetActive(false); } private void RefreshNode() { var playerSkillData = TableManager.Instance.Tables.PlayerSkillConfig.GetOrDefault(_skillID); if (playerSkillData != null) { var fill = (1 - _curCdProgress) * UI_StartBtn_CMSBtnController.PROGRESS_FULL; Image_SkillProgress.fillAmount = fill; } } private void ChangeState(bool state) { _isInCd = state; Image_CMSkillNormal.gameObject.SetActive(state); Button_CMSkillPress.gameObject.SetActive(!state); } private void OnOutDrag() { try { //InputManager.Instance.enabled = false; CameraController.FingerMoveEnable = false; var data = new EDReadyPlayerSkill{playerSkillId = _skillID}; EventManager.Instance.Send(EventManager.EventName.Guide_PreparaPlayerSkill); EventManager.Instance.Send(EventManager.EventName.INFIGHT_PLAYER_SKILL_READYUSE, data); var window = (UI_StartBtn_CMSBtnController)_bindWindow; if (!TeamManager.IsHideAllUI) { TeamManager.IsHideAllUI = true; } window.OnOutDragNode(); } catch (Exception e) { DebugUtil.LogError(e); //InputManager.Instance.enabled = true; throw; } } private void OnPointUp() { CameraController.FingerMoveEnable = true; var window = (UI_StartBtn_CMSBtnController)_bindWindow; window.OnPointUp(); } }