DressUpFightView.cs 39 KB

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