DressUpFightView.cs 36 KB

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