DressUpView.cs 32 KB

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