DressUpView.cs 34 KB

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