| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 | 
							- using FairyGUI;
 
- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UI.FieldGuide;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     /// <summary>
 
-     /// 服装图鉴界面
 
-     /// </summary>
 
-     public class DressUpGuideView : BaseWindow
 
-     {
 
-         private UI_DressUpGuideUI _ui;
 
-         private List<int> _itemIdList;
 
-         private bool _startInAnim;
 
-         private bool first = true;
 
-         // 上次点击单选按钮的index
 
-         private struct LastClickIndex
 
-         {
 
-             public int typeIndex;   // 菜单类型:一级/二级
 
-             public int index;
 
-         }
 
-         private LastClickIndex _lastClickIndex;
 
-         private int[] _currentList2;
 
-         public override void Dispose()
 
-         {
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_DressUpGuideUI.PACKAGE_NAME;
 
-             _ui = UI_DressUpGuideUI.Create();
 
-             this.viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("quanping_moren_bg");
 
-             _itemIdList = new List<int>();
 
-             _startInAnim = true;
 
-             _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_listType1.onClickItem.Add(OnClickListType1Item);
 
-             _ui.m_listType2.onClickItem.Add(OnClickListType2Item);
 
-             _ui.m_listDressUp.itemRenderer = RenderListDressUpItem;
 
-             _ui.m_listDressUp.onClickItem.Add(OnClickListDressUpItem);
 
-             _ui.m_listDressUp.SetVirtual();
 
-             _ui.m_btnAccessories.onClick.Add(OnClickBtnAllAccessories);
 
-         }
 
-         protected override void AddEventListener()
 
-         {
 
-             base.AddEventListener();
 
-             EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, FilterItems);
 
-             EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, FilterItems);
 
-             EventAgent.AddEventListener(ConstMessage.DRESS_PART_LOAD_FINISHED, LoadFinished);
 
-         }
 
-         protected override void RemoveEventListener()
 
-         {
 
-             base.RemoveEventListener();
 
-             EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, FilterItems);
 
-             EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, FilterItems);
 
-             EventAgent.RemoveEventListener(ConstMessage.DRESS_PART_LOAD_FINISHED, LoadFinished);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             _ui.m_listType1.selectedIndex = 0;
 
-             _ui.m_c1.selectedIndex = 0;
 
-             _ui.m_listType1.scrollPane.SetPercX(0,false);
 
-             if (DressUpMenuItemDataManager.isLoading)
 
-             {
 
-                 ViewManager.Show<ModalStatusView>("加载中...");
 
-             }
 
-             else
 
-             {
 
-                 UpdateItemIdListByType1(0);
 
-                 UpdateItemListUI();
 
-             }
 
-             if (_startInAnim)
 
-             {
 
-                 _startInAnim = false;
 
-                 _ui.m_In.Play();
 
-             }
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             _itemIdList.Clear();
 
-             _currentList2 = null;
 
-             DressUpMenuItemDataManager.Clear();
 
-         }
 
-         /// <summary>
 
-         /// 一级菜单的点击
 
-         /// </summary>
 
-         /// <param name="index"></param>
 
-         /// <param name="item"></param>
 
-         private void OnClickListType1Item(EventContext context)
 
-         {
 
-             GObject gObject = context.data as GObject;
 
-             int index = _ui.m_listType1.GetChildIndex(gObject);
 
-             if(_lastClickIndex.typeIndex == 1 && _lastClickIndex.index == index)
 
-             {
 
-                 return;
 
-             }
 
-             UpdateItemIdListByType1(index);
 
-             UpdateItemListUI();
 
-             _ui.m_Refresh.Play();
 
-         }
 
-         private void RenderListDressUpItem(int index, GObject item)
 
-         {
 
-             UI_ListDressUpPartsItem listItem = UI_ListDressUpPartsItem.Proxy(item);
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemIdList[index]);
 
-             listItem.m_icon.url = ResPathUtil.GetIconPath(itemCfg.res, "png");
 
-             listItem.m_txtTitle.text = itemCfg.name;
 
-             listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
 
-             listItem.m_unlockMask.visible = !DressUpMenuItemDataManager.CheckHasItem(itemCfg.id);
 
-             RarityIconController.UpdateRarityIcon(listItem.m_rarity, _itemIdList[index], false);
 
-             listItem.target.data = _itemIdList[index];
 
-             UI_ListDressUpPartsItem.ProxyEnd();
 
-         }
 
-         private void OnClickListDressUpItem(EventContext eventContext)
 
-         {
 
-             int id = (int)(eventContext.data as GObject).data;
 
-             object[] goBackDatas = ViewManager.GetGoBackDatas(typeof(CardGuideView).Name);
 
-             object[] sourceDatas = new object[] { id, goBackDatas, 1 };
 
-             GoodsItemTipsController.ShowItemTips(id, sourceDatas, DressUpMenuItemDataManager.CheckHasItem(id));
 
-         }
 
-         /// <summary>
 
-         /// 二级菜单的点击
 
-         /// </summary>
 
-         /// <param name="index"></param>
 
-         /// <param name="item"></param>
 
-         private void OnClickListType2Item(EventContext eventContext)
 
-         {
 
-             GObject gObject = eventContext.data as GObject;
 
-             int index = _ui.m_listType2.GetChildIndex(gObject);
 
-             if (_lastClickIndex.typeIndex == 2 && _lastClickIndex.index == index)
 
-             {
 
-                 return;
 
-             }
 
-             UpdateItemIdListByType2(index);
 
-             UpdateItemListUI();
 
-             _ui.m_Refresh.Play();
 
-         }
 
-         private void OnClickBtnAllAccessories()
 
-         {
 
-             // 点击饰品按钮回到一级菜单时,需要更新为 全部饰品 选项
 
-             UpdateItemIdListByType2(0);
 
-             UpdateItemListUI();
 
-             ShowListType1();
 
-         }
 
-         /// <summary>
 
-         /// 根据一级菜单的按钮点击,更新itemIDList
 
-         /// </summary>
 
-         /// <param name="index">点击按钮的index</param>
 
-         private void UpdateItemIdListByType1(int index)
 
-         {
 
-             _lastClickIndex.typeIndex = 1;
 
-             _lastClickIndex.index = index;
 
-             // 点击了“全部服装”
 
-             if (index == 0)
 
-             {
 
-                 _itemIdList = DressUpMenuItemDataManager.GetAllDressUpGuideIdListBySubType(0);
 
-             }
 
-             else
 
-             {
 
-                 DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index - 1];
 
-                 // 存在二级菜单
 
-                 if (item1.subMenusArr.Length > 0)
 
-                 {
 
-                     _itemIdList.Clear();
 
-                     _currentList2 = item1.subMenusArr.Clone() as int[];
 
-                     for (int i = 0; i < item1.subMenusArr.Length; i++)
 
-                     {
 
-                         DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[i] - 1];
 
-                         _itemIdList.AddRange(DressUpMenuItemDataManager.GetAllDressUpGuideIdListBySubType(item2.type, false));
 
-                     }
 
-                     DressUpMenuItemDataManager.SortDressUpGuideIdList(_itemIdList);
 
-                     ShowListType2();
 
-                 }
 
-                 else
 
-                 {
 
-                     _itemIdList = DressUpMenuItemDataManager.GetAllDressUpGuideIdListBySubType(item1.type);
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 根据二级菜单的按钮点击,更新itemIDList
 
-         /// </summary>
 
-         /// <param name="index">点击按钮的index</param>
 
-         private void UpdateItemIdListByType2(int index)
 
-         {
 
-             _lastClickIndex.typeIndex = 2;
 
-             _lastClickIndex.index = index;
 
-             if (index == 0)
 
-             {
 
-                 _itemIdList.Clear();
 
-                 for (int i = 0; i < _currentList2.Length; i++)
 
-                 {
 
-                     DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[i] - 1];
 
-                     _itemIdList.AddRange(DressUpMenuItemDataManager.GetAllDressUpGuideIdListBySubType(item2.type, false));
 
-                 }
 
-                 DressUpMenuItemDataManager.SortDressUpGuideIdList(_itemIdList);
 
-             }
 
-             else
 
-             {
 
-                 DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index - 1] - 1];
 
-                 _itemIdList = DressUpMenuItemDataManager.GetAllDressUpGuideIdListBySubType(item2.type);
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 更新散件列表UI,及收集度
 
-         /// </summary>
 
-         private void UpdateItemListUI(bool refreshProgress = true)
 
-         {
 
-             int haveCount = 0;
 
-             int totalCount = 0;
 
-             _ui.m_listDressUp.numItems = _itemIdList.Count;
 
-             _ui.m_listDressUp.scrollPane.ScrollTop();
 
-             if (refreshProgress)
 
-             {
 
-                 for (int i = 0; i < _itemIdList.Count; i++)
 
-                 {
 
-                     if (DressUpMenuItemDataManager.CheckHasItem(_itemIdList[i]))
 
-                     {
 
-                         ++haveCount;
 
-                     }
 
-                     ++totalCount;
 
-                 }
 
-                 UpdateProgress(haveCount, totalCount);
 
-             }
 
-         }
 
-         private void ShowListType2()
 
-         {
 
-             _ui.m_c1.selectedIndex = 1;
 
-             _ui.m_listType2.selectedIndex = 0;
 
-             _ui.m_listType2.scrollPane.SetPercX(0, false);
 
-             _lastClickIndex.typeIndex = 2;
 
-             _lastClickIndex.index = 0;
 
-         }
 
-         private void ShowListType1()
 
-         {
 
-             _ui.m_c1.selectedIndex = 0;
 
-             _currentList2 = null;
 
-         }
 
-         /// <summary>
 
-         /// 更新收集进度
 
-         /// </summary>
 
-         private void UpdateProgress(int haveCount, int totalCount)
 
-         {
 
-             _ui.m_progressBar.target.max = totalCount;
 
-             _ui.m_progressBar.target.value = haveCount;
 
-             _ui.m_progressBar.m_title1.SetVar("value", haveCount.ToString()).SetVar("max", totalCount.ToString()).FlushVars();
 
-             _ui.m_progressBar.m_rate.SetVar("rate", FieldGuideView.ProgressCalculate(haveCount, totalCount).ToString()).FlushVars();
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             _startInAnim = true;
 
-             ViewManager.GoBackFrom(typeof(DressUpGuideView).FullName);
 
-         }
 
-         private void OnClickBtnSearch()
 
-         {
 
-             ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
 
-         }
 
-         private void FilterItems(EventContext context)
 
-         {
 
-             // 过滤之前,需要更新_itemIdList为全部物品
 
-             if (_lastClickIndex.typeIndex == 1)
 
-             {
 
-                 UpdateItemIdListByType1(_lastClickIndex.index);
 
-             }
 
-             else if(_lastClickIndex.typeIndex == 2)
 
-             {
 
-                 UpdateItemIdListByType2(_lastClickIndex.index);
 
-             }
 
-             if (context.data.ToString() == ConstMessage.DRESS_SEARCH)
 
-             {
 
-                 _itemIdList = DressUpMenuItemDataManager.DressSearch(_itemIdList);
 
-             }
 
-             else if(context.data.ToString() == ConstMessage.DRESS_FILTER)
 
-             {
 
-                 _itemIdList = DressUpMenuItemDataManager.DressFilter(_itemIdList);
 
-             }
 
-             ViewManager.Hide<ModalStatusView>();
 
-             UpdateItemListUI(false);
 
-             _ui.m_Refresh.Play();
 
-         }
 
-         private void LoadFinished()
 
-         {
 
-             UpdateItemIdListByType1(0);
 
-             UpdateItemListUI();
 
-             ViewManager.Hide<ModalStatusView>();
 
-         }
 
-     }
 
- }
 
 
  |