DressUpFightView.cs 38 KB

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