DressUpView.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. using UI.DressUp;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. using ET;
  6. namespace GFGGame
  7. {
  8. public class DressUpView : BaseView
  9. {
  10. public const int MAX_MEMORY_STEP = 20;//最大记录步数
  11. public const int BOTTOM_BLANK = 20;
  12. public const int RIGHT_BLANK = 36;
  13. private const int SORT_BY_HIGH_RARITY = 0;
  14. private const int SORT_BY_LOW_RARITY = 1;
  15. private const int SORT_BY_GET_TIME = 2;
  16. private UI_DressUpUI _ui;
  17. private float listType1X = 0;
  18. private float partsListX = 0;
  19. private DressUpListType currentListType;
  20. /// <summary>
  21. /// 子菜单列表
  22. /// </summary>
  23. private int[] _currentList2;
  24. private GameObject _scenePrefab;
  25. private GameObject _sceneObject;
  26. private List<int> _currentList3 = new List<int>();
  27. private List<int> _currentList4 = new List<int>();
  28. private int _currentMenuType;
  29. private int _currentSuitId;
  30. private int _rarityIndex = SORT_BY_HIGH_RARITY;
  31. private UI_TypeItem listTypeItem_FreedomDress;
  32. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  33. private int _stepIndex = -1;
  34. private List<CustomSuitData> _dressMemory = new List<CustomSuitData>();
  35. public override void Dispose()
  36. {
  37. if (_sceneObject != null)
  38. {
  39. GameObject.Destroy(_sceneObject);
  40. _sceneObject = null;
  41. }
  42. for (int i = 0; i < _listLongPress.Count; i++)
  43. {
  44. _listLongPress[i].Dispose();
  45. }
  46. _listLongPress.Clear();
  47. if (_ui != null)
  48. {
  49. _ui.Dispose();
  50. _ui = null;
  51. }
  52. base.Dispose();
  53. }
  54. protected override void Init()
  55. {
  56. base.Init();
  57. packageName = UI_DressUpUI.PACKAGE_NAME;
  58. _ui = UI_DressUpUI.Create();
  59. viewCom = _ui.target;
  60. isfullScreen = true;
  61. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
  62. }
  63. protected override void OnInit()
  64. {
  65. base.OnInit();
  66. _ui.m_btnLastStep.visible = false;
  67. _ui.m_btnNextStep.visible = false;
  68. _ui.m_btnSearch.visible = true;
  69. _ui.m_btnPhoto.visible = true;
  70. _ui.m_btnAction.visible = false;
  71. _ui.m_comboBox.items = new string[] { "我的套装一", "我的套装二", "我的套装三", "我的套装四", "我的套装五", "我的套装六" };
  72. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  73. InitLists();
  74. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  75. _ui.m_btnHome.onClick.Add(OnClickBtnHome);
  76. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  77. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  78. _ui.m_comboBox.onChanged.Add(OnComboBoxChanged);
  79. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  80. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  81. // _ui.m_partsList.m_list.SetVirtual();
  82. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  83. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  84. _ui.m_touchPad.onClick.Add(OnTouchPad);
  85. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  86. _ui.m_btnSave.onClick.Add(OnClickBtnSave);
  87. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  88. _ui.m_btnAction.onClick.Add(OnClickBtnAction);
  89. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  90. _ui.m_btnShow.onClick.Add(OnClickBtnShow);
  91. _ui.m_btnHide.onClick.Add(OnClickBtnHide);
  92. _ui.m_loaShow.onClick.Add(OnClickLoaShow);
  93. _ui.m_btnPhoto.onClick.Add(OnClickBtnPhoto);
  94. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  95. }
  96. protected override void AddEventListener()
  97. {
  98. base.AddEventListener();
  99. EventAgent.AddEventListener(ConstMessage.CLOSE_PHOTOGRAPHVIEW, UpdateScene);
  100. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  101. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  102. }
  103. protected override void OnShown()
  104. {
  105. base.OnShown();
  106. _rarityIndex = SORT_BY_HIGH_RARITY;
  107. // MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DRESS_UP, "mp3"));
  108. _ui.m_comListType1.target.x = _ui.target.width;
  109. _ui.m_comListType2.target.x = _ui.target.width;
  110. _ui.m_partsList.target.x = _ui.target.width;
  111. _ui.m_partsList2.target.x = _ui.target.width;
  112. this.showListType1();
  113. if (_sceneObject == null)
  114. {
  115. _sceneObject = GameObject.Instantiate(_scenePrefab);
  116. EquipDataCache.cacher.setSceneObj(_sceneObject);
  117. }
  118. _ui.m_comboBox.selectedIndex = CustomSuitDataManager.currentIndex;
  119. EquipDataCache.cacher.PutOnSuitSaved(CustomSuitDataManager.currentIndex);
  120. // UpdateStepBtn();
  121. AddMemoryDressup();
  122. Timers.inst.AddUpdate(CheckGuide);
  123. }
  124. protected override void OnHide()
  125. {
  126. base.OnHide();
  127. listTypeItem_FreedomDress = null;
  128. // MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  129. EquipDataCache.cacher.setSceneObj(_sceneObject);//在拍照界面断线返回登录,需要重新设置_sceneObject
  130. EquipDataCache.cacher.TakeOffAll();
  131. if (_sceneObject != null)
  132. {
  133. GameObject.Destroy(_sceneObject);
  134. _sceneObject = null;
  135. }
  136. Timers.inst.Remove(CheckGuide);
  137. }
  138. protected override void RemoveEventListener()
  139. {
  140. base.RemoveEventListener();
  141. EventAgent.RemoveEventListener(ConstMessage.CLOSE_PHOTOGRAPHVIEW, UpdateScene);
  142. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  143. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  144. }
  145. private void OnClickBtnBack()
  146. {
  147. Reset();
  148. this.Hide();
  149. ViewManager.Show(ViewName.MAINUI_VIEW);
  150. }
  151. private void OnClickBtnHome()
  152. {
  153. GameController.GoBackToMainView();
  154. Reset();
  155. }
  156. private void Reset()
  157. {
  158. DressUpMenuItemDataManager.dressFilterType = DressFilterType.None;
  159. DressUpMenuItemDataManager.Clear();
  160. DressUpMenuItemDataManager.dressSearchTxt = "";
  161. _stepIndex = -1;
  162. _dressMemory.Clear();
  163. }
  164. private void OnClickBtnLastStep()
  165. {
  166. if (_stepIndex - 1 < 0) return;
  167. _stepIndex--;
  168. EquipDataCache.cacher.PutOnSuitMemory(_dressMemory[_stepIndex]);
  169. _ui.m_comboBox.selectedIndex = _dressMemory[_stepIndex].pos;
  170. UpdateStepBtn();
  171. }
  172. private void OnClickBtnNextStep()
  173. {
  174. if (_stepIndex + 1 >= MAX_MEMORY_STEP) return;
  175. _stepIndex++;
  176. EquipDataCache.cacher.PutOnSuitMemory(_dressMemory[_stepIndex]);
  177. _ui.m_comboBox.selectedIndex = _dressMemory[_stepIndex].pos;
  178. UpdateStepBtn();
  179. }
  180. private void OnComboBoxChanged()
  181. {
  182. EquipDataCache.cacher.PutOnSuitSaved(_ui.m_comboBox.selectedIndex);
  183. }
  184. private void OnClickListType1Item(EventContext context)
  185. {
  186. GObject typeItem = (GObject)context.data as GObject;
  187. int order = (int)typeItem.data;
  188. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  189. if (item1.subMenusArr.Length > 0)
  190. {
  191. this.showListType2(item1.subMenusArr);
  192. }
  193. else
  194. {
  195. if (this.showListParts(item1.type) == false)
  196. {
  197. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  198. return;
  199. }
  200. }
  201. this.hideListType1();
  202. UpdateListPartsSelected();
  203. }
  204. private void OnClickListType2Item(EventContext context)
  205. {
  206. GObject typeItem = (GObject)context.data as GObject;
  207. int order = (int)typeItem.data;
  208. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  209. if (this.showListParts(item2.type) == false)
  210. {
  211. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  212. return;
  213. }
  214. this.hideListType2();
  215. }
  216. private void OnClickPartsListItem(EventContext context)
  217. {
  218. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  219. {
  220. return;
  221. }
  222. GObject listItem = (GObject)context.data as GObject;
  223. int id = (int)listItem.data;
  224. bool isSuit = SuitCfgManager.Instance.GetTotalCountOfOneSuit(id) > 0;
  225. if (isSuit)
  226. {
  227. this.showListParts2(id);
  228. this.hideListParts();
  229. EquipDataCache.cacher.PutOnSuitCfg(id, true, false);
  230. UpdateBtnAction();
  231. }
  232. else
  233. {
  234. EquipDataCache.cacher.TryCancelSuit(id);
  235. EquipDataCache.cacher.AddOrRemove(id, true);
  236. }
  237. UpdateListPartsSelected();
  238. UpdateListSuitPartsSelected(); ;
  239. AddMemoryDressup();
  240. }
  241. private void OnClickSuitPartsListItem(EventContext context)
  242. {
  243. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  244. {
  245. return;
  246. }
  247. GObject listItem = (GObject)context.data as GObject;
  248. int id = (int)listItem.data;
  249. EquipDataCache.cacher.TryCancelSuit(id);
  250. EquipDataCache.cacher.AddOrRemove(id, true);
  251. UpdateListSuitPartsSelected();
  252. UpdateBtnAction();
  253. AddMemoryDressup();
  254. }
  255. private void AddMemoryDressup()
  256. {
  257. return;
  258. _stepIndex++;
  259. if (_stepIndex == MAX_MEMORY_STEP)
  260. {
  261. _stepIndex = MAX_MEMORY_STEP - 1;
  262. _dressMemory.RemoveAt(0);
  263. }
  264. if (_dressMemory.Count > _stepIndex)
  265. {
  266. _dressMemory.RemoveRange(_stepIndex, _dressMemory.Count - _stepIndex);
  267. }
  268. CustomSuitData suitSavedData = EquipDataCache.cacher.GetCurSuitData(_ui.m_comboBox.selectedIndex);
  269. _dressMemory.Add(suitSavedData);
  270. UpdateStepBtn();
  271. }
  272. private void UpdateStepBtn()
  273. {
  274. _ui.m_btnLastStep.enabled = _stepIndex > 0;
  275. _ui.m_btnNextStep.enabled = _stepIndex < _dressMemory.Count - 1;
  276. }
  277. private void OnLongPress(EventContext context)
  278. {
  279. LongPressGesture gesture = (LongPressGesture)context.sender;
  280. int itemId = (int)gesture.host.data;
  281. GoodsItemTipsController.ShowItemTips(itemId);
  282. }
  283. private void OnTouchPad()
  284. {
  285. if (this.currentListType == DressUpListType.List4)
  286. {
  287. this.hideListParts2();
  288. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  289. }
  290. else if (this.currentListType == DressUpListType.List3)
  291. {
  292. if (_currentList2 != null)
  293. {
  294. this.showListType2(_currentList2);
  295. // _ui.m_comListType2.m_listType.numItems = _ui.m_comListType2.m_listType.numItems;
  296. }
  297. else
  298. {
  299. this.showListType1();
  300. }
  301. this.hideListParts();
  302. }
  303. else if (this.currentListType == DressUpListType.List2)
  304. {
  305. this.showListType1();
  306. this.hideListType2();
  307. }
  308. // _ui.m_comListType1.m_listType.numItems = _ui.m_comListType1.m_listType.numItems;
  309. // this.ShowSubList();
  310. }
  311. private void OnClickBtnDelete()
  312. {
  313. EquipDataCache.cacher.TakeOffAll();
  314. UpdateBtnAction();
  315. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  316. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  317. }
  318. private void OnClickBtnSave()
  319. {
  320. CustomSuitDataManager.SaveCurrentSuit(_ui.m_comboBox.selectedIndex);
  321. }
  322. private void OnComboBoxRarityChanged()
  323. {
  324. _rarityIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  325. this.UpdatePartsListSort();
  326. }
  327. private void OnClickBtnAction()
  328. {
  329. if (!_ui.m_btnAction.grayed)
  330. {
  331. EquipDataCache.cacher.ChangeAction();
  332. }
  333. }
  334. private void OnClickBtnSearch()
  335. {
  336. ViewManager.Show<DressFilterView>(true, new object[] { ViewName.DRESS_UP_VIEW });
  337. }
  338. private void InitLists()
  339. {
  340. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  341. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  342. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  343. listType1X = _ui.m_comListType1.target.x;
  344. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width - DressUpView.RIGHT_BLANK;
  345. //一级菜单
  346. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  347. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length;
  348. //_ui.m_comListType1.m_listType1.ResizeToFit(_ui.m_comListType1.m_listType1.numItems);
  349. float maxHeight = _ui.target.height - _ui.m_comListType1.target.y - DressUpView.BOTTOM_BLANK;
  350. if (_ui.m_comListType1.m_listType.height > maxHeight)
  351. {
  352. _ui.m_comListType1.m_listType.height = maxHeight;
  353. }
  354. }
  355. // private void ShowSubList()
  356. // {
  357. // _ui.m_comListType1.m_listType.numItems = _ui.m_comListType1.m_listType.numItems;
  358. // _ui.m_comListType2.m_listType.numItems = _ui.m_comListType2.m_listType.numItems;
  359. // }
  360. private void showListType1()
  361. {
  362. _currentList2 = null;
  363. currentListType = DressUpListType.List1;
  364. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length;
  365. GTween.To(_ui.target.width, listType1X, 0.5f)
  366. .SetTarget(_ui.m_comListType1.target)
  367. .OnUpdate((GTweener t) =>
  368. {
  369. _ui.m_comListType1.target.x = t.value.x;
  370. });
  371. }
  372. private void hideListType1()
  373. {
  374. GTween.To(listType1X, _ui.target.width, 0.5f)
  375. .SetTarget(_ui.m_comListType1.target)
  376. .OnUpdate((GTweener t) =>
  377. {
  378. _ui.m_comListType1.target.x = t.value.x;
  379. });
  380. }
  381. private void showListType2(int[] menuStrArr = null)
  382. {
  383. currentListType = DressUpListType.List2;
  384. if (menuStrArr != null && menuStrArr.Length > 0)
  385. {
  386. int len = menuStrArr.Length;
  387. _currentList2 = menuStrArr.Clone() as int[];
  388. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  389. _ui.m_comListType2.m_listType.numItems = len;
  390. //_ui.m_comListType2.m_listType2.ResizeToFit(_ui.m_comListType2.m_listType2.numItems);
  391. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  392. if (_ui.m_comListType2.m_listType.height > maxHeight)
  393. {
  394. _ui.m_comListType2.m_listType.height = maxHeight;
  395. }
  396. }
  397. GTween.To(_ui.target.width, listType1X, 0.5f)
  398. .SetTarget(_ui.m_comListType2.target)
  399. .OnUpdate((GTweener t) =>
  400. {
  401. _ui.m_comListType2.target.x = t.value.x;
  402. });
  403. }
  404. private void hideListType2()
  405. {
  406. GTween.To(listType1X, _ui.target.width, 0.5f)
  407. .SetTarget(_ui.m_comListType2.target)
  408. .OnUpdate((GTweener t) =>
  409. {
  410. _ui.m_comListType2.target.x = t.value.x;
  411. });
  412. }
  413. private bool showListParts(int type, bool selectItem = false)
  414. {
  415. _currentMenuType = type;
  416. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  417. {
  418. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  419. if (_rarityIndex >= SORT_BY_GET_TIME)
  420. {
  421. _rarityIndex = SORT_BY_HIGH_RARITY;
  422. }
  423. }
  424. else
  425. {
  426. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  427. }
  428. this.UpdatePartsListSort();
  429. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  430. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  431. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;// - DressUpView.BOTTOM_BLANK;
  432. if (_ui.m_partsList.m_list.height > maxHeight)
  433. {
  434. _ui.m_partsList.m_list.height = maxHeight;
  435. }
  436. if (selectItem)
  437. {
  438. int itemId = EquipDataCache.cacher.GetItemIdBuyType(_currentMenuType);
  439. if (itemId > 0)
  440. {
  441. int index = _currentList3.IndexOf(itemId);
  442. _ui.m_partsList.m_list.ScrollToView(index);
  443. }
  444. }
  445. currentListType = DressUpListType.List3;
  446. GTween.To(_ui.target.width, partsListX, 0.5f)
  447. .SetTarget(_ui.m_partsList)
  448. .OnUpdate((GTweener t) =>
  449. {
  450. _ui.m_partsList.target.x = t.value.x;
  451. });
  452. UpdateBtnAction();
  453. UpdateListPartsSelected();
  454. return true;
  455. }
  456. private void hideListParts()
  457. {
  458. // _currentMenuType = 0;
  459. UpdateBtnAction();
  460. GTween.To(partsListX, _ui.target.width, 0.5f)
  461. .SetTarget(_ui.m_partsList)
  462. .OnUpdate((GTweener t) =>
  463. {
  464. _ui.m_partsList.target.x = t.value.x;
  465. });
  466. }
  467. private void showListParts2(int suitId)
  468. {
  469. _currentSuitId = suitId;
  470. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  471. if (_rarityIndex >= SORT_BY_GET_TIME)
  472. {
  473. _rarityIndex = SORT_BY_HIGH_RARITY;
  474. }
  475. this.UpdateSuitPartsListSort();
  476. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  477. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  478. if (_ui.m_partsList2.m_list.height > maxHeight)
  479. {
  480. _ui.m_partsList2.m_list.height = maxHeight;
  481. }
  482. currentListType = DressUpListType.List4;
  483. GTween.To(_ui.target.width, partsListX, 0.5f)
  484. .SetTarget(_ui.m_partsList2)
  485. .OnUpdate((GTweener t) =>
  486. {
  487. _ui.m_partsList2.target.x = t.value.x;
  488. });
  489. UpdateBtnAction();
  490. }
  491. private void hideListParts2()
  492. {
  493. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  494. UpdateBtnAction();
  495. GTween.To(partsListX, _ui.target.width, 0.5f)
  496. .SetTarget(_ui.m_partsList2)
  497. .OnUpdate((GTweener t) =>
  498. {
  499. _ui.m_partsList2.target.x = t.value.x;
  500. });
  501. }
  502. /****************************************************************************************************************************/
  503. private void ListType1Item(int index, GObject item)
  504. {
  505. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  506. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  507. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  508. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  509. typeItem.target.data = item1.id;
  510. typeItem.m_imgNeed.visible = false;
  511. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  512. UI_TypeItem.ProxyEnd();
  513. }
  514. private void ListType2Item(int index, GObject item)
  515. {
  516. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  517. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  518. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  519. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  520. typeItem.target.data = item2.id;
  521. typeItem.m_imgNeed.visible = false;
  522. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  523. UI_TypeItem.ProxyEnd();
  524. }
  525. private void ListPartsItem(int index, GObject item)
  526. {
  527. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  528. int id = (int)_currentList3[index];
  529. string iconRes = "";
  530. string partName = "";
  531. string ext = "png";
  532. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  533. {
  534. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  535. iconRes = suitCfg.res;
  536. partName = suitCfg.name;
  537. listItem.m_iconSelected.visible = false;
  538. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  539. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  540. listItem.m_ScoreType.visible = false;
  541. listItem.m_imgNew.visible = false;
  542. }
  543. else
  544. {
  545. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  546. iconRes = itemCfg.res;
  547. partName = itemCfg.name;
  548. listItem.m_iconSelected.visible = EquipDataCache.cacher.CheckDressUpItemIsOn(id);
  549. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  550. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  551. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  552. listItem.m_ScoreType.visible = true;
  553. int mainScore;
  554. int mainValuel;
  555. ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  556. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + mainScore);
  557. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  558. listItem.m_imgNew.visible = isNew;
  559. if (isNew)
  560. {
  561. ItemProxy.ReqSetItemRead(id).Coroutine();
  562. }
  563. // DressUpMenuItemDataManager.RemoveNewDressItem(_currentMenuType, id);
  564. }
  565. if (listItem.target.data == null)
  566. {
  567. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  568. longPressGesture.once = true;
  569. longPressGesture.onAction.Add(OnLongPress);
  570. _listLongPress.Add(longPressGesture);
  571. }
  572. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  573. listItem.m_txtTitle.text = partName;
  574. listItem.target.data = id;
  575. listItem.m_txtScore.visible = false;
  576. //listItem.m_ScoreType.visible = true;
  577. listItem.m_imgNeed.visible = false;
  578. UI_PartsListItem.ProxyEnd();
  579. }
  580. private void ListParts2Item(int index, GObject item)
  581. {
  582. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  583. int id = (int)_currentList4[index];
  584. string iconRes = "";
  585. string partName = "";
  586. string ext = "png";
  587. if (listItem.target.data == null)
  588. {
  589. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  590. longPressGesture.once = true;
  591. longPressGesture.onAction.Add(OnLongPress);
  592. _listLongPress.Add(longPressGesture);
  593. }
  594. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  595. iconRes = itemCfg.res;
  596. partName = itemCfg.name;
  597. listItem.m_iconSelected.visible = !_ui.m_btnAction.grayed || EquipDataCache.cacher.CheckDressUpItemIsOn(id);
  598. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  599. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  600. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  601. listItem.m_ScoreType.visible = true;
  602. int mainScore;
  603. int mainValuel;
  604. ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  605. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + mainScore);
  606. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  607. listItem.m_txtTitle.text = partName;
  608. listItem.target.data = id;
  609. listItem.m_txtScore.visible = false;
  610. //listItem.m_ScoreType.visible = true;
  611. listItem.m_imgNeed.visible = false;
  612. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  613. listItem.m_imgNew.visible = isNew;
  614. if (isNew)
  615. {
  616. ItemProxy.ReqSetItemRead(id).Coroutine();
  617. }
  618. UI_PartsListItem.ProxyEnd();
  619. }
  620. private void UpdateListPartsSelected()
  621. {
  622. int count = _ui.m_partsList.m_list.numChildren;
  623. int suitId = EquipDataCache.cacher.CheckCurDressIsSuit();
  624. for (int i = 0; i < count; i++)
  625. {
  626. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  627. int id = (int)listItem.target.data;
  628. if (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG)
  629. {
  630. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  631. }
  632. else
  633. {
  634. bool isPutOn = EquipDataCache.cacher.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  635. bool isSuit = !DressUpMenuItemDataManager.CheckIsSceneType(id) && suitId > 0 && SuitCfgManager.Instance.GetItemSuitId(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  636. isSuit = !DressUpMenuItemDataManager.CheckIsSceneType(id) && suitId > 0 && suitId == id;
  637. bool isSceneSuit = DressUpMenuItemDataManager.CheckIsSceneType(id) && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  638. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  639. }
  640. UI_PartsListItem.ProxyEnd();
  641. }
  642. }
  643. private void UpdateListSuitPartsSelected()
  644. {
  645. int count = _ui.m_partsList2.m_list.numChildren;
  646. int suitId = EquipDataCache.cacher.CheckCurDressIsSuit();
  647. for (int i = 0; i < count; i++)
  648. {
  649. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  650. int id = (int)listItem.target.data;
  651. bool isPutOn = EquipDataCache.cacher.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  652. bool isSuit = !DressUpMenuItemDataManager.CheckIsSceneType(id) && suitId > 0 && SuitCfgManager.Instance.GetItemSuitId(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  653. bool isSceneSuit = DressUpMenuItemDataManager.CheckIsSceneType(id) && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  654. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  655. UI_PartsListItem.ProxyEnd();
  656. }
  657. }
  658. private void UpdatePartsListSort()
  659. {
  660. if (_currentMenuType == 0) return;
  661. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  662. {
  663. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  664. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  665. {
  666. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  667. }
  668. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  669. {
  670. _currentList3 = SuitUtil.SortSuitListByLowRarity(_currentList3);
  671. }
  672. else
  673. {
  674. _currentList3.Reverse();
  675. }
  676. }
  677. else
  678. {
  679. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  680. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  681. {
  682. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighRarity(_currentList3);
  683. }
  684. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  685. {
  686. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowRarity(_currentList3);
  687. }
  688. else
  689. {
  690. _currentList3.Reverse();
  691. }
  692. }
  693. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  694. {
  695. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3, _currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG);
  696. }
  697. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  698. {
  699. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3, _currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG);
  700. }
  701. _ui.m_partsList.m_list.RemoveChildrenToPool();
  702. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  703. }
  704. private void UpdateSuitPartsListSort()
  705. {
  706. if (_currentMenuType == 0) return;
  707. _currentList4 = new List<int>(SuitCfgManager.Instance.GetSuitItems(_currentSuitId));
  708. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  709. {
  710. _currentList4 = DressUpMenuItemDataManager.SortItemListByHighRarity(_currentList4);
  711. }
  712. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  713. {
  714. _currentList4 = DressUpMenuItemDataManager.SortItemListByLowRarity(_currentList4);
  715. }
  716. else
  717. {
  718. _currentList4.Reverse();
  719. }
  720. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  721. {
  722. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4, false);
  723. }
  724. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  725. {
  726. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4, false);
  727. }
  728. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  729. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  730. }
  731. private void UpdateBtnAction()
  732. {
  733. _ui.m_btnAction.visible = (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG) || this.currentListType == DressUpListType.List4;
  734. if (_ui.m_btnAction.visible)
  735. {
  736. _ui.m_btnAction.grayed = !EquipDataCache.cacher.HasSuitPicRes;
  737. }
  738. }
  739. private void OnClickBtnShow()
  740. {
  741. Timers.inst.Remove(SetBtnShowVisable);
  742. _ui.m_c1.selectedIndex = 0;
  743. _ui.m_btnHide.visible = true;
  744. _ui.m_btnShow.visible = false;
  745. _ui.m_loaShow.visible = false;
  746. }
  747. private void OnClickBtnHide()
  748. {
  749. _ui.m_c1.selectedIndex = 1;
  750. _ui.m_btnHide.visible = false;
  751. _ui.m_btnShow.visible = true;
  752. _ui.m_loaShow.visible = true;
  753. Timers.inst.Add(2f, 1, SetBtnShowVisable);
  754. }
  755. private void OnClickLoaShow()
  756. {
  757. Timers.inst.Remove(SetBtnShowVisable);
  758. _ui.m_btnShow.alpha = 1;
  759. Timers.inst.Add(2f, 1, SetBtnShowVisable);
  760. _ui.m_btnShow.enabled = true;
  761. }
  762. private void OnClickBtnPhoto()
  763. {
  764. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.PAI_ZHAO, 1);
  765. if (!ViewManager.Show<PhotographView>())
  766. {
  767. return;
  768. }
  769. _ui.target.visible = false;
  770. this._sceneObject.gameObject.SetActive(false);
  771. }
  772. private void UpdateScene()
  773. {
  774. _ui.target.visible = true;
  775. this._sceneObject.gameObject.SetActive(true);
  776. EquipDataCache.cacher.setSceneObj(_sceneObject);
  777. }
  778. private void SetBtnShowVisable(object param)
  779. {
  780. _ui.m_btnShow.enabled = false;
  781. GTween.To(1, 0, 0.3f).SetTarget(_ui.m_btnShow, TweenPropType.Alpha);
  782. }
  783. private bool CheckListCount(int type)
  784. {
  785. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  786. {
  787. return DressUpMenuSuitDataManager.GetSuitIDList().Count > 0;
  788. }
  789. else
  790. {
  791. return DressUpMenuItemDataManager.getItemDatasByType(type).Count > 0;
  792. }
  793. }
  794. private void CheckGuide(object param)
  795. {
  796. if (GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0
  797. || GuideDataManager.IsGuideFinish(ConstGuideId.PHOTOGRAPH) <= 0)
  798. {
  799. UpdateToCheckGuide(null);
  800. }
  801. else
  802. {
  803. Timers.inst.Remove(CheckGuide);
  804. }
  805. }
  806. protected override void UpdateToCheckGuide(object param)
  807. {
  808. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  809. if (listTypeItem_FreedomDress == null && GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0)
  810. {
  811. int len = _ui.m_comListType1.m_listType.numChildren;
  812. for (int i = 0; i < len; i++)
  813. {
  814. UI_TypeItem item = UI_TypeItem.Proxy(_ui.m_comListType1.m_listType.GetChildAt(i));
  815. if (item != null)
  816. {
  817. int menuID = (int)item.target.data;
  818. DressUpMenuItemCfg1 dressUpMenuItemCfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuID);
  819. if (dressUpMenuItemCfg1.type == ConstDressUpItemType.TAO_ZHUANG)
  820. {
  821. listTypeItem_FreedomDress = item;
  822. _ui.m_comListType1.m_listType.ScrollToView(i);
  823. break;
  824. }
  825. }
  826. UI_TypeItem.ProxyEnd();
  827. }
  828. }
  829. if (listTypeItem_FreedomDress != null) GuideController.TryGuide(listTypeItem_FreedomDress.target, ConstGuideId.FREEDOM_DRESS, 3, "套装分类里,可以查看集齐成套的服饰。");
  830. GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.FREEDOM_DRESS, 4, "点击一键换上。", 0, true, 330);
  831. GuideController.TryGuide(_ui.m_btnSave, ConstGuideId.FREEDOM_DRESS, 5, "搭配好的服饰,可以保存随时查看。");
  832. GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.FREEDOM_DRESS, 6, "保存成功,回主界面看看吧。");
  833. GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 6);
  834. GuideController.TryGuide(_ui.m_btnPhoto, ConstGuideId.PHOTOGRAPH, 1, "完成心水搭配后,可以拍照留下纪念哦。");
  835. }
  836. }
  837. }