123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.ClothingFoster;
- namespace GFGGame
- {
- public class ClothingListView : BaseWindow
- {
- private UI_ClothingListUI _ui;
- // private ValueBarController _valueBarController;
- private int _menuType = ConstSuitGuideTypeId.TYPE_1;
- private int[] _menuTypeDataArray;
- private List<int> _suitIds;
- public override void Dispose()
- {
- // if (_valueBarController != null)
- // {
- // _valueBarController.Dispose();
- // _valueBarController = null;
- // }
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_ClothingListUI.PACKAGE_NAME;
- _ui = UI_ClothingListUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- isReturnView = true;
- // _valueBarController = new ValueBarController(_ui.m_valueBar);
- _ui.m_listSuit.itemRenderer = ListSuitItemRenderer;
- _ui.m_comBoxSort.items = new string[] { "默认排序", "稀有度高", "稀有度低", "收集度高", "收集度低" };
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_comBoxSort.onChanged.Add(OnComboBoxSortChanged);
- _ui.m_btnHaveGot.onChanged.Add(OnClickBtnHaveGot);
- _ui.m_btnNotGet.onChanged.Add(OnClickBtnNotGet);
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
- }
- protected override void OnShown()
- {
- base.OnShown();
- // _valueBarController.OnShown();
- _ui.m_btnHaveGot.selected = true;
- _ui.m_btnNotGet.selected = true;
- SuitFosterProxy.SendGetSuitInfos().Coroutine();
- UpdateListSuit();
- Timers.inst.AddUpdate(CheckGuide);
- }
- protected override void OnHide()
- {
- base.OnHide();
- // _valueBarController.OnHide();
- Timers.inst.Remove(CheckGuide);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
- }
- private void OnClickBtnBack()
- {
- // this.Hide();
- ViewManager.GoBackFrom(typeof(ClothingListView).FullName);
- }
- private void OnClickListTypeItem()
- {
- UpdateListSuit();
- }
- private void OnComboBoxSortChanged()
- {
- UpdateListSuit();
- }
- private void OnClickBtnSwitch()
- {
- _menuType = 3 - _menuType;
- }
- private void OnClickBtnHaveGot()
- {
- if (!_ui.m_btnHaveGot.selected)
- {
- _ui.m_btnNotGet.selected = true;
- }
- UpdateListSuit();
- }
- private void OnClickBtnNotGet()
- {
- if (!_ui.m_btnNotGet.selected)
- {
- _ui.m_btnHaveGot.selected = true;
- }
- UpdateListSuit();
- }
- private void UpdateListSuit()
- {
- _ui.m_listSuit.RemoveChildrenToPool();
- _suitIds = SuitUtil.GetClothingFosterSuitIdList(_ui.m_btnNotGet.selected, _ui.m_btnHaveGot.selected, _ui.m_comBoxSort.selectedIndex);
- _ui.m_listSuit.numItems = _suitIds.Count;
- _ui.m_listSuit.scrollPane.ScrollTop();
- }
- private void ListSuitItemRenderer(int index, GObject item)
- {
- UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(item);
- int suitId = _suitIds[index];
- SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
- listItem.m_txtName.text = suitCfg.name;
- listItem.m_loaderPic.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
- RarityIconController.UpdateRarityIcon(listItem.m_rarity, suitId, false, true);
- listItem.target.data = suitId;
- UpdateSuitStatusView(listItem);
- UI_ListSuitItem.ProxyEnd();
- }
- private void UpdateSuitStatus(EventContext eventContext)
- {
- int num = _ui.m_listSuit.numChildren;
- for (int i = 0; i < num; i++)
- {
- UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(_ui.m_listSuit.GetChildAt(i));
- UpdateSuitStatusView(listItem);
- UI_ListSuitItem.ProxyEnd();
- }
- }
- private void UpdateSuitStatusView(UI_ListSuitItem listItem)
- {
- int suitId = (int)listItem.target.data;
- int count = 0;
- int totalCount = 0;
- DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
- listItem.m_progBar.max = totalCount;
- listItem.m_progBar.value = count;
- bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
- listItem.m_imgLock.visible = listItem.m_imgLockBg.visible = !haveSuit;
- listItem.m_bg.onClick.Clear();
- listItem.m_bg.onClick.Add(() =>
- {
- if (haveSuit)
- {
- ViewManager.Show<ClothingView>(new object[] { suitId, _suitIds });
- }
- else
- {
- ViewManager.Show<SuitPartsDetailView>(suitId);
- }
- });
- RedDotController.Instance.SetComRedDot(listItem.target, RedDotDataManager.Instance.GetClothingFosterRed(suitId) || RedDotDataManager.Instance.GetClothingRenewRed(suitId), "", 8, -3);
- }
- private void CheckGuide(object param)
- {
- if (GuideDataManager.IsGuideFinish(ConstGuideId.SUIT_LIST_VIEW) <= 0)
- {
- UpdateToCheckGuide(null);
- }
- else
- {
- Timers.inst.Remove(CheckGuide);
- }
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- int index = 0;
- for (int i = 0; i < _suitIds.Count; i++)
- {
- int suitId = _suitIds[i];
- bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
- if (haveSuit == true)
- {
- index = i;
- break;
- }
- }
- GuideController.TryGuide(_ui.m_listSuit, ConstGuideId.SUIT_LIST_VIEW, 3, "选择套装。", index);
- }
- }
- }
|