DressUpView.cs 32 KB

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