DressUpFightView.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. using UI.DressUp;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. namespace GFGGame
  6. {
  7. public class DressUpFightView : BaseView
  8. {
  9. private UI_DressUpFightUI _ui;
  10. private int _fightID;
  11. private string _levelID;
  12. private float listType1X = 0;
  13. private float partsListX = 0;
  14. private DressUpListType currentListType;
  15. private int[] _currentList2;
  16. private GameObject _scenePrefab;
  17. private GameObject _sceneObject;
  18. private List<int> _currentList3;
  19. private int _currentMenuType;
  20. private StoryLevelCfg _levelCfg;
  21. private StoryFightCfg _fightCfg;
  22. private const int SORT_BY_HIGH_SCORE = 0;
  23. private const int SORT_BY_LOW_SCORE = 1;
  24. private int _scoreIndex = SORT_BY_HIGH_SCORE;
  25. private bool _guideMenu;
  26. private UI_TypeItem listTypeItem_SingleFight;
  27. private UI_TypeItem listTypeItem_BuyClothing;
  28. public override void Dispose()
  29. {
  30. if (_scenePrefab != null)
  31. {
  32. GameObject.Destroy(_scenePrefab);
  33. _scenePrefab = null;
  34. }
  35. UI_TypeItem.ClearProxy();
  36. UI_PartsListItem.ClearProxy();
  37. base.Dispose();
  38. }
  39. protected override void Init()
  40. {
  41. base.Init();
  42. packageName = UI_DressUpFightUI.PACKAGE_NAME;
  43. _ui = UI_DressUpFightUI.Create();
  44. viewCom = _ui.target;
  45. isfullScreen = true;
  46. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
  47. _ui.m_btnClose.width = GRoot.inst.width;
  48. _ui.m_btnClose.height = GRoot.inst.height;
  49. _ui.m_btnClose.AddRelation(GRoot.inst, RelationType.Size);
  50. }
  51. protected override void OnInit()
  52. {
  53. base.OnInit();
  54. _ui.m_groupTaskHint.visible = false;
  55. _ui.m_btnRepeal.visible = false;
  56. _ui.m_btnRenewal.visible = false;
  57. _ui.m_btnSearch.visible = true;
  58. // _ui.m_comboBox.items = new string[] { "我的套装一", "我的套装二", "我的套装三", "我的套装四", "我的套装五", "我的套装六" };
  59. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  60. InitLists();
  61. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  62. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  63. _ui.m_btnHome.onClick.Add(OnClickBtnHome);
  64. // _ui.m_btnClothingShop.onClick.Add(OnClickBtnClothingShop);
  65. // _ui.m_comboBox.onChanged.Add(OnComboBoxChanged);
  66. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  67. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  68. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  69. _ui.m_touchPad.onClick.Add(OnTouchPad);
  70. _ui.m_btnHint.onClick.Add(OnClickBtnHint);
  71. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  72. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  73. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  74. _ui.m_btnRecommend.onClick.Add(OnClickBtnRecommend);
  75. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  76. _ui.m_compNeed.target.onClick.Add(OnClickComNeed);
  77. _ui.m_compNeed.m_listTag.itemRenderer = RenderListTagItem;
  78. // _ui.m_btnShow.onClick.Add(OnClickBtnShow);
  79. // _ui.m_btnHide.onClick.Add(OnClickBtnHide);
  80. // _ui.m_loaShow.onClick.Add(OnClickLoaShow);
  81. _ui.m_btnHide.visible = false;
  82. _ui.m_loaShow.visible = false;
  83. _ui.m_btnShow.visible = false;
  84. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  85. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  86. // EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdatePartsListSort);
  87. EventAgent.AddEventListener(ConstMessage.CARD_CHOOSE, StartCalculateScore);
  88. }
  89. protected override void OnShown()
  90. {
  91. base.OnShown();
  92. StoryDataManager.usedRecommend = false;
  93. // _ui.m_comboBox.title = "我的套装";
  94. _ui.m_txtRecommendCount.SetVar("v1", "" + StoryDataManager.recommendCount).FlushVars();
  95. _ui.m_btnRecommend.enabled = StoryDataManager.recommendCount > 0;
  96. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  97. _levelID = (string)viewData;
  98. _levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  99. _fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  100. if (!string.IsNullOrEmpty(_fightCfg.music))
  101. {
  102. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(_fightCfg.music, "mp3"));
  103. }
  104. _ui.m_compNeed.target.visible = _fightCfg.needItemId > 0 || _fightCfg.needSuitId > 0 || _fightCfg.needTagsArr.Length > 0;
  105. if (_ui.m_compNeed.target.visible)
  106. {
  107. _ui.m_compNeed.m_c1.selectedIndex = 0;
  108. if (_fightCfg.needItemId > 0)
  109. {
  110. _ui.m_compNeed.m_txtNeedName.text = ItemUtil.GetItemName(_fightCfg.needItemId);
  111. _ui.m_compNeed.target.data = _fightCfg.needItemId;
  112. }
  113. else if (_fightCfg.needSuitId > 0)
  114. {
  115. _ui.m_compNeed.m_txtNeedName.text = ItemUtil.GetSuitName(_fightCfg.needSuitId);
  116. _ui.m_compNeed.target.data = _fightCfg.needSuitId;
  117. }
  118. else
  119. {
  120. _ui.m_compNeed.m_c1.selectedIndex = 1;
  121. _ui.m_compNeed.m_listTag.numItems = _fightCfg.needTagsArr.Length;
  122. }
  123. }
  124. StoryDataManager.currentScoreType = _fightCfg.scoreType;
  125. //一级菜单
  126. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  127. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 1;
  128. //_ui.m_comListType1.m_listType1.ResizeToFit(_ui.m_listType1.numItems);
  129. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  130. if (_ui.m_comListType1.m_listType.height > maxHeight)
  131. {
  132. _ui.m_comListType1.m_listType.height = maxHeight;
  133. }
  134. _ui.m_comListType1.target.x = _ui.target.width;
  135. _ui.m_comListType2.target.x = _ui.target.width;
  136. _ui.m_partsList.target.x = _ui.target.width;
  137. _ui.m_scoreType.url = "ui://CommonGame/kp_sx_" + _fightCfg.scoreType;
  138. this.showListType1();
  139. if (_sceneObject == null)
  140. {
  141. _sceneObject = GameObject.Instantiate(_scenePrefab);
  142. EquipDataCache.cacher.setSceneObj(_sceneObject);
  143. EquipDataCache.cacher.PutOnDefaultSuitSaved();
  144. }
  145. UpdateScore();
  146. EventAgent.AddEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateScore);
  147. if (GuideDataManager.GetGuideCount(ConstGuideId.SINGLE_FIGHT_GUIDE) <= 0)
  148. {
  149. _guideMenu = GuideController.TryGuideDressUpFightViewMenuType0(_ui.m_comListType1.m_listType);
  150. }
  151. else if (GuideDataManager.GetGuideCount(ConstGuideId.CLOTHING_SHOP_VIEW_BTN_BUY) <= 0)
  152. {
  153. GuideController.TryGuideDressUpFightViewBtnRecommend(_ui.m_compNeed.target, _ui.m_comListType1.m_listType);
  154. }
  155. else if (GuideDataManager.GetGuideCount(ConstGuideId.SEE_DRESS_TIPS) <= 0)
  156. {
  157. GuideController.TryGuideDressUpFightViewBtnHint(_ui.m_btnHint);
  158. }
  159. Timers.inst.AddUpdate(UpdateToCheckGuide);
  160. }
  161. protected override void OnHide()
  162. {
  163. base.OnHide();
  164. Timers.inst.Remove(UpdateToCheckGuide);
  165. GuideController.HideGuide();
  166. if (_sceneObject != null)
  167. {
  168. GameObject.Destroy(_sceneObject);
  169. _sceneObject = null;
  170. }
  171. EventAgent.RemoveEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateScore);
  172. _fightCfg = null;
  173. _levelCfg = null;
  174. listTypeItem_SingleFight = null;
  175. listTypeItem_BuyClothing = null;
  176. }
  177. private void OnClickBtnBack()
  178. {
  179. this.Hide();
  180. // ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter);
  181. ViewManager.GoBackFrom(ViewName.STORY_CHAPTER_VIEW);
  182. }
  183. private void OnClickBtnHome()
  184. {
  185. GameController.GoBackToMainView();
  186. }
  187. private void OnClickBtnClothingShop()
  188. {
  189. ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { null, _fightCfg.scoreType }, null, false, true);
  190. }
  191. private void OnClickListType1Item(EventContext context)
  192. {
  193. // GuideController.HideGuide();
  194. GObject typeItem = context.data as GObject;
  195. int order = (int)typeItem.data;
  196. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  197. if (item1.subMenusArr.Length > 0)
  198. {
  199. this.showListType2(item1.subMenusArr);
  200. }
  201. else
  202. {
  203. this.showListParts(item1.type);
  204. if (GuideDataManager.GetGuideCount(ConstGuideId.SINGLE_FIGHT_GUIDE) <= 0)
  205. {
  206. GuideController.TryGuideDressUpFightViewMenuPart0(_ui.m_partsList.m_list, "找到这条裙子了,换上看看吧");
  207. }
  208. else if (GuideDataManager.GetGuideCount(ConstGuideId.CLOTHING_SHOP_VIEW_BTN_BUY) <= 0)
  209. {
  210. GuideController.TryGuideDressUpFightViewMenuPart1(_ui.m_partsList.m_list, "点击换上吧");
  211. }
  212. }
  213. this.hideListType1();
  214. }
  215. private void OnClickListType2Item(EventContext context)
  216. {
  217. GObject typeItem = context.data as GObject;
  218. int order = (int)typeItem.data;
  219. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  220. this.showListParts(item2.type);
  221. this.hideListType2();
  222. }
  223. private void OnClickPartsListItem(EventContext context)
  224. {
  225. GObject listItem = context.data as GObject;
  226. int id = (int)listItem.data;
  227. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  228. {
  229. EquipDataCache.cacher.PutOnSuitCfg(id, false, true);
  230. }
  231. else
  232. {
  233. EquipDataCache.cacher.TryCancelSuit(id);
  234. EquipDataCache.cacher.AddOrRemove(id, true);
  235. UpdateListPartsSelected();
  236. GuideController.TryGuideDressUpFightViewBtnNext0(_ui.m_btnNext);
  237. }
  238. GuideController.TryCompleteGuide(ConstGuideId.CLOTHING_SHOP_VIEW_BTN_BUY);
  239. }
  240. private void OnTouchPad()
  241. {
  242. if (this.currentListType == DressUpListType.List3)
  243. {
  244. if (_currentList2 != null)
  245. {
  246. this.showListType2();
  247. }
  248. else
  249. {
  250. this.showListType1();
  251. }
  252. this.hideListParts();
  253. }
  254. else if (this.currentListType == DressUpListType.List2)
  255. {
  256. this.showListType1();
  257. this.hideListType2();
  258. }
  259. }
  260. private void OnClickBtnHint()
  261. {
  262. this.ShowTaskHint();
  263. GuideController.HideGuide();
  264. GuideController.TryCompleteGuide(ConstGuideId.SEE_DRESS_TIPS);
  265. }
  266. private void OnClickBtnDelete()
  267. {
  268. EquipDataCache.cacher.TakeOffAll();
  269. }
  270. private void OnClickBtnClose()
  271. {
  272. _ui.m_groupTaskHint.visible = false;
  273. }
  274. private void OnClickBtnNext()
  275. {
  276. if (EquipDataCache.cacher.score <= 0)
  277. {
  278. Alert.Show("只有换好衣服才能出门哦~")
  279. .SetRightButton(true, "好的");
  280. return;
  281. }
  282. if (CardDataManager.GetCardDicByRarity(0) != null)
  283. {
  284. ViewManager.Show<StoryCardChoose>(_fightCfg.scoreType);
  285. }
  286. else
  287. {
  288. StartCalculateScore();
  289. }
  290. }
  291. private void StartCalculateScore()
  292. {
  293. //不可移动代码位置
  294. bool hasFightTarget = _fightCfg.targetName != null && _fightCfg.targetName.Length > 0;
  295. this.Hide();
  296. if (hasFightTarget)
  297. {
  298. ViewManager.Show(ViewName.STORY_FIGHT_TARGET_VIEW);
  299. }
  300. else
  301. {
  302. ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_VIEW);
  303. }
  304. }
  305. private void OnClickBtnRecommend()
  306. {
  307. StoryDataManager.usedRecommend = true;
  308. EquipDataCache.cacher.PutOnRecommendItems();
  309. }
  310. private void InitLists()
  311. {
  312. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  313. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  314. listType1X = _ui.m_comListType1.target.x;
  315. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  316. //一级菜单
  317. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  318. }
  319. private void showListType1()
  320. {
  321. _currentList2 = null;
  322. currentListType = DressUpListType.List1;
  323. GTween.To(_ui.target.width, listType1X, 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 hideListType1()
  331. {
  332. GTween.To(listType1X, _ui.target.width, 0.5f)
  333. .SetTarget(_ui.m_comListType1.target)
  334. .OnUpdate((GTweener t) =>
  335. {
  336. _ui.m_comListType1.target.x = t.value.x;
  337. });
  338. }
  339. private void showListType2(int[] menuStrArr = null)
  340. {
  341. currentListType = DressUpListType.List2;
  342. if (menuStrArr != null && menuStrArr.Length > 0)
  343. {
  344. int len = menuStrArr.Length;
  345. _currentList2 = menuStrArr.Clone() as int[];
  346. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  347. _ui.m_comListType2.m_listType.numItems = len;
  348. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  349. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  350. if (_ui.m_comListType2.m_listType.height > maxHeight)
  351. {
  352. _ui.m_comListType2.m_listType.height = maxHeight;
  353. }
  354. }
  355. GTween.To(_ui.target.width, listType1X, 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 void hideListType2()
  363. {
  364. GTween.To(listType1X, _ui.target.width, 0.5f)
  365. .SetTarget(_ui.m_comListType2.target)
  366. .OnUpdate((GTweener t) =>
  367. {
  368. _ui.m_comListType2.target.x = t.value.x;
  369. });
  370. }
  371. private void showListParts(int type)
  372. {
  373. _currentMenuType = type;
  374. UpdatePartsListSort();
  375. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  376. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  377. if (_ui.m_partsList.m_list.height > maxHeight)
  378. {
  379. _ui.m_partsList.m_list.height = maxHeight;
  380. }
  381. currentListType = DressUpListType.List3;
  382. GTween.To(_ui.target.width, partsListX, 0.5f)
  383. .SetTarget(_ui.m_partsList)
  384. .OnUpdate((GTweener t) =>
  385. {
  386. _ui.m_partsList.target.x = t.value.x;
  387. });
  388. }
  389. private void OnComboBoxRarityChanged()
  390. {
  391. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  392. this.UpdatePartsListSort();
  393. }
  394. private void UpdatePartsListSort()
  395. {
  396. if (_currentMenuType == 0) return;
  397. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  398. {
  399. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  400. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  401. {
  402. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  403. }
  404. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  405. {
  406. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  407. }
  408. else
  409. {
  410. _currentList3.Reverse();
  411. }
  412. }
  413. else
  414. {
  415. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  416. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  417. {
  418. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3);
  419. }
  420. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  421. {
  422. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3);
  423. }
  424. else
  425. {
  426. _currentList3.Reverse();
  427. }
  428. }
  429. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  430. {
  431. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3, _currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG);
  432. }
  433. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  434. {
  435. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3, _currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG);
  436. }
  437. //必穿品放在列表最前面
  438. if (_fightCfg.needItemId > 0)
  439. {
  440. int index = _currentList3.IndexOf(_fightCfg.needItemId);
  441. if (index >= 0)
  442. {
  443. int item = _currentList3[index];
  444. _currentList3.Remove(_currentList3[index]);
  445. _currentList3.Insert(0, item);
  446. }
  447. }
  448. else if (_fightCfg.needSuitId > 0)
  449. {
  450. int index = _currentList3.IndexOf(_fightCfg.needSuitId);
  451. if (index >= 0)
  452. {
  453. int item = _currentList3[index];
  454. _currentList3.Remove(_currentList3[index]);
  455. _currentList3.Insert(0, item);
  456. }
  457. }
  458. _ui.m_partsList.m_list.RemoveChildrenToPool();
  459. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  460. }
  461. private void hideListParts()
  462. {
  463. GTween.To(partsListX, _ui.target.width, 0.5f)
  464. .SetTarget(_ui.m_partsList)
  465. .OnUpdate((GTweener t) =>
  466. {
  467. _ui.m_partsList.target.x = t.value.x;
  468. });
  469. }
  470. private void ListType1Item(int index, GObject item)
  471. {
  472. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  473. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  474. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  475. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  476. typeItem.target.data = item1.id;
  477. typeItem.m_imgNeed.visible = ItemUtil.CheckMenuType1(_fightCfg.needItemId, _fightCfg.needSuitId, item1.id);
  478. }
  479. private void ListType2Item(int index, GObject item)
  480. {
  481. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  482. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  483. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  484. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  485. typeItem.target.data = item2.id;
  486. var subType = ItemUtil.GetItemSubType(_fightCfg.needItemId);
  487. typeItem.m_imgNeed.visible = subType == item2.type;
  488. }
  489. private void ListPartsItem(int index, GObject item)
  490. {
  491. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  492. int id = (int)_currentList3[index];
  493. string iconRes = "";
  494. string partName = "";
  495. string ext = "png";
  496. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  497. {
  498. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  499. iconRes = suitCfg.res;
  500. partName = suitCfg.name;
  501. listItem.m_iconSelected.visible = false;
  502. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  503. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  504. }
  505. else
  506. {
  507. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  508. iconRes = itemCfg.res;
  509. partName = itemCfg.name;
  510. listItem.m_iconSelected.visible = EquipDataCache.cacher.CheckDressUpItemIsOn(id);
  511. listItem.m_txtScore.text = "" + DressUpMenuItemDataManager.GetItemScore(id);
  512. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  513. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType);
  514. }
  515. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  516. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + _fightCfg.scoreType;
  517. listItem.m_txtTitle.text = partName;
  518. listItem.target.data = id;
  519. listItem.m_imgNeed.visible = _fightCfg.needItemId == id || _fightCfg.needSuitId == id;
  520. }
  521. private void UpdateListPartsSelected()
  522. {
  523. int count = _ui.m_partsList.m_list.numChildren;
  524. for (int i = 0; i < count; i++)
  525. {
  526. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  527. int id = (int)listItem.target.data;
  528. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  529. {
  530. listItem.m_iconSelected.visible = false;
  531. }
  532. else
  533. {
  534. listItem.m_iconSelected.visible = EquipDataCache.cacher.CheckDressUpItemIsOn(id);
  535. }
  536. }
  537. }
  538. private void ShowTaskHint()
  539. {
  540. _ui.m_groupTaskHint.visible = true;
  541. _ui.m_txtHint.text = _levelCfg.hint;
  542. if (this._ui.m_txtHint.textHeight > this._ui.m_txtHint.textFormat.size * 2)
  543. {
  544. this._ui.m_txtHint.align = AlignType.Left;
  545. }
  546. else
  547. {
  548. this._ui.m_txtHint.align = AlignType.Center;
  549. }
  550. }
  551. private void UpdateScore()
  552. {
  553. _ui.m_txtScore.text = "" + EquipDataCache.cacher.score;
  554. // GuideController.TryGuideDressUpFightViewBtnNext(_ui.m_btnNext);
  555. }
  556. private void OnClickBtnSearch()
  557. {
  558. ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
  559. }
  560. // private void OnClickBtnShow()
  561. // {
  562. // Timers.inst.Remove(SetBtnShowVisable);
  563. // _ui.m_c1.selectedIndex = 0;
  564. // _ui.m_btnHide.visible = true;
  565. // _ui.m_loaShow.visible = false;
  566. // _ui.m_btnShow.visible = false;
  567. // }
  568. // private void OnClickBtnHide()
  569. // {
  570. // _ui.m_c1.selectedIndex = 1;
  571. // _ui.m_btnHide.visible = false;
  572. // _ui.m_btnShow.visible = true;
  573. // _ui.m_loaShow.visible = true;
  574. // Timers.inst.Add(2f, 1, SetBtnShowVisable);
  575. // }
  576. // private void OnClickLoaShow()
  577. // {
  578. // Timers.inst.Remove(SetBtnShowVisable);
  579. // _ui.m_btnShow.alpha = 1;
  580. // Timers.inst.Add(2f, 1, SetBtnShowVisable);
  581. // _ui.m_btnShow.enabled = true;
  582. // }
  583. private void SetBtnShowVisable(object param)
  584. {
  585. _ui.m_btnShow.enabled = false;
  586. GTween.To(1, 0, 0.3f).SetTarget(_ui.m_btnShow, TweenPropType.Alpha);
  587. }
  588. private void OnClickComNeed()
  589. {
  590. GuideController.HideGuide();
  591. if (_fightCfg.needItemId <= 0 && _fightCfg.needSuitId <= 0)
  592. {
  593. return;
  594. }
  595. if (_fightCfg.needSuitId > 0)
  596. {
  597. ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, new object[] { _ui.m_compNeed.target.data, new object[] { ViewName.DRESS_UP_FIGHT_VIEW, this.viewData } }, new object[] { ViewName.DRESS_UP_FIGHT_VIEW, this.viewData });
  598. }
  599. else
  600. {
  601. ViewManager.Show(ViewName.APPROACH_OF_ITEM_VIEW, new object[] { _ui.m_compNeed.target.data, new object[] { ViewName.DRESS_UP_FIGHT_VIEW, this.viewData } });
  602. }
  603. }
  604. private void RenderListTagItem(int index, GObject obj)
  605. {
  606. UI.CommonGame.UI_ListTagItem item = UI.CommonGame.UI_ListTagItem.Proxy(obj);
  607. string[] tag = _fightCfg.needTagsArr[index].Split('_');
  608. item.m_loaTag.url = ResPathUtil.GetCommonGameResPath("fzd_bqbq_" + tag[0]);
  609. item.m_txtTag.text = tag[1];
  610. }
  611. private void UpdateToCheckGuide(object param)
  612. {
  613. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  614. if (listTypeItem_SingleFight == null && GuideDataManager.GetGuideCountCopy(ConstGuideId.SINGLE_FIGHT) <= 0 || listTypeItem_BuyClothing == null && GuideDataManager.GetGuideCountCopy(ConstGuideId.BUY_CLOTHING) <= 0)
  615. {
  616. int len = _ui.m_comListType1.m_listType.numChildren;
  617. for (int i = 0; i < len; i++)
  618. {
  619. UI_TypeItem item = UI_TypeItem.Proxy(_ui.m_comListType1.m_listType.GetChildAt(i));
  620. if (item != null)
  621. {
  622. int menuID = (int)item.target.data;
  623. DressUpMenuItemCfg1 dressUpMenuItemCfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuID);
  624. if (GuideDataManager.GetGuideCountCopy(ConstGuideId.SINGLE_FIGHT) <= 0)
  625. {
  626. if (dressUpMenuItemCfg1.type == ConstDressUpItemType.LIAN_YI_QUN)
  627. {
  628. listTypeItem_SingleFight = item;
  629. _ui.m_comListType1.m_listType.ScrollToView(i);
  630. break;
  631. }
  632. }
  633. else if (GuideDataManager.GetGuideCountCopy(ConstGuideId.BUY_CLOTHING) <= 0)
  634. {
  635. int type = 0;
  636. if (_fightCfg.needItemId > 0) type = ItemUtil.GetItemSubType(_fightCfg.needItemId);
  637. if (_fightCfg.needSuitId > 0) type = ConstDressUpItemType.TAO_ZHUANG;
  638. if (dressUpMenuItemCfg1.type == type)
  639. {
  640. listTypeItem_BuyClothing = item;
  641. _ui.m_comListType1.m_listType.ScrollToView(i);
  642. break;
  643. }
  644. }
  645. }
  646. }
  647. }
  648. if (listTypeItem_SingleFight != null) GuideController.TryGuide(listTypeItem_SingleFight.target, ConstGuideId.SINGLE_FIGHT, 3, "点击相应的分类,可以快速找到服饰");
  649. GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.SINGLE_FIGHT, 4, "找到这条裙子了,换上看看吧");
  650. GuideController.TryGuide(_ui.m_btnNext, ConstGuideId.SINGLE_FIGHT, 5, "接下来验证一下,换上的服饰是否符合需求");
  651. GuideController.TryGuide(_ui.m_compNeed.target, ConstGuideId.BUY_CLOTHING, 1, "当提示有“必需品”时,需要穿上对应物品才能通关");
  652. if (listTypeItem_BuyClothing != null) GuideController.TryGuide(listTypeItem_BuyClothing.target, ConstGuideId.BUY_CLOTHING, 5, "在相应分类里就可以找到必需品啦");
  653. GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.BUY_CLOTHING, 6, "点击换上吧", true, 0);
  654. GuideController.TryCompleteGuide(ConstGuideId.BUY_CLOTHING, 6);
  655. GuideController.TryGuide(_ui.m_btnHint, ConstGuideId.TARGET_FIGHT, 1, "这次换装需要获得别人的认可呢");
  656. }
  657. }
  658. }