using System.Collections.Generic; using ET; using FairyGUI; using UI.Travel; using UnityEngine; namespace GFGGame { public class TravelDressupView : BaseWindow { private UI_TravelDressupUI _ui; private List _selectTravelSuitIds = new List(); private List _travelSuitIds = new List(); public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_TravelDressupUI.PACKAGE_NAME; _ui = UI_TravelDressupUI.Create(); this.viewCom = _ui.target; isfullScreen = true; _ui.m_btnCancle.onClick.Add(Hide); _ui.m_btnGo.onClick.Add(OnBtnGoClick); _ui.m_comDress0.target.onClick.Add(OnComDressClick0); _ui.m_comDress1.target.onClick.Add(OnComDressClick); _ui.m_comDress2.target.onClick.Add(OnComDressClick); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj"); } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); UpdateView(); } protected override void OnHide() { base.OnHide(); _selectTravelSuitIds.Clear(); _travelSuitIds.Clear(); if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void UpdateView() { _travelSuitIds = new List(DressUpMenuSuitDataManager.TravelSuitIDList.ToArray()); for (int i = 0; i < _selectTravelSuitIds.Count; i++) { if (_travelSuitIds.IndexOf(_selectTravelSuitIds[i]) >= 0) { _travelSuitIds.Remove(_selectTravelSuitIds[i]); } } _ui.m_list.numItems = _travelSuitIds.Count; } private void RenderListItem(int index, GObject obj) { TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(_travelSuitIds[index]); UI_ListDressItem item = UI_ListDressItem.Proxy(obj); item.target.data = _travelSuitIds[index]; UI_ListDressItem.ProxyEnd(); } private void OnListItemClick(EventContext context) { if (_selectTravelSuitIds.Count >= 2) { PromptController.Instance.ShowFloatTextPrompt("行囊已满"); return; } int travelSuitId = (int)(context.data as GObject).data; _selectTravelSuitIds.Add(travelSuitId); UpdateView(); } private void OnComDressClick0() { PromptController.Instance.ShowFloatTextPrompt("必带服装不能取消"); } private void OnComDressClick(EventContext context) { int travelSuitId = (int)(context.sender as GObject).data; _selectTravelSuitIds.Remove(travelSuitId); UpdateView(); } private async void OnBtnGoClick() { if (_selectTravelSuitIds.Count < 2) { PromptController.Instance.ShowFloatTextPrompt("需带齐服装才能出发"); return; } bool result = await TravelSProxy.ReqGoTravel(_selectTravelSuitIds); if (result) { this.Hide(); } } } }