DressUpView.cs 33 KB

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