DressUpFightView.cs 41 KB

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