DressUpFightView.cs 37 KB

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