DressUpView.cs 30 KB

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