DressUpFightView.cs 36 KB

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