DressUpFightView.cs 38 KB

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