DressUpView.cs 32 KB

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