using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using System.Linq; using TableConfig; using EnhancedUI.EnhancedScroller; namespace Snxxz.UI { public class RunePanel : Window { [SerializeField] FunctionButtonGroup functionButtonGroup; [SerializeField] FunctionButton functionRuneMosaic; [SerializeField] FunctionButton functionRuneBreak; [SerializeField] FunctionButton functionRuneMixture; [SerializeField] Button leftBtn; [SerializeField] Button rightBtn; [SerializeField] Button closeBtn; RuneModel m_Model; RuneModel model { get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel()); } } protected override void BindController() { } protected override void AddListeners() { leftBtn.onClick.AddListener(functionButtonGroup.TriggerLast); rightBtn.onClick.AddListener(functionButtonGroup.TriggerNext); closeBtn.onClick.AddListener(CloseClick); functionRuneMosaic.onClick.AddListener(OnRuneMosaic); functionRuneBreak.onClick.AddListener(OnRuneBreak); functionRuneMixture.onClick.AddListener(OnRuneMixture); } private void OnRuneMixture() { CloseChild(); functionOrder = 2; if (windowState == WindowState.Opened) { WindowCenter.Instance.OpenWithoutAnimation(); } else { WindowCenter.Instance.Open(); } } private void OnRuneBreak() { CloseChild(); functionOrder = 1; if (windowState == WindowState.Opened) { WindowCenter.Instance.OpenWithoutAnimation(); } else { WindowCenter.Instance.Open(); } } private void OnRuneMosaic() { CloseChild(); functionOrder = 0; if (windowState == WindowState.Opened) { WindowCenter.Instance.OpenWithoutAnimation(); } else { WindowCenter.Instance.Open(); } } protected override void OnPreOpen() { model.JumpToComposeEvent += JumpToComposeEvent; CloseChild(); } protected override void OnActived() { base.OnActived(); functionButtonGroup.TriggerByOrder(functionOrder); } protected override void OnAfterOpen() { } protected override void OnPreClose() { model.JumpToComposeEvent -= JumpToComposeEvent; CloseChild(); } protected override void OnAfterClose() { if (!WindowJumpMgr.Instance.IsJumpState) { WindowCenter.Instance.Open(); } } private void CloseChild() { if (WindowCenter.Instance.CheckOpen()) { WindowCenter.Instance.CloseImmediately(); } if (WindowCenter.Instance.CheckOpen()) { WindowCenter.Instance.CloseImmediately(); } if (WindowCenter.Instance.CheckOpen()) { WindowCenter.Instance.CloseImmediately(); } } private void JumpToComposeEvent() { functionButtonGroup.TriggerByOrder(2); } } }