ArenaDressUpFightView.cs 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. using UI.DressUp;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. using cfg.GfgCfg;
  6. namespace GFGGame
  7. {
  8. public class ArenaDressUpFightView : BaseWindow
  9. {
  10. private UI_ArenaDressUpFightUI _ui;
  11. // private DressUpObj _dressUpData = new DressUpObj();
  12. private ArenaDataManager _dataManager;
  13. private FightData _roleData;
  14. public List<int> _itemList; //记录打开界面时的穿戴数据(保存后会更新)
  15. private float listType1X = 0;
  16. private float partsListX = 0;
  17. private float partsListScrollingPosY = 0;
  18. private DressUpListType currentListType;
  19. private List<int> _currentList2;
  20. private GameObject _sceneObject;
  21. private List<int> _currentList3 = new List<int>();
  22. private List<int> _currentList4 = new List<int>();
  23. private int _currentMenuType;
  24. private int _currentSuitId;
  25. //暂存cardid
  26. private int cardId;
  27. // private StoryLevelCfg _levelCfg;
  28. // private StoryFightCfg _fightCfg;
  29. private const int SORT_BY_HIGH_SCORE = 0;
  30. private const int SORT_BY_LOW_SCORE = 1;
  31. private int _scoreIndex = SORT_BY_HIGH_SCORE;
  32. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  33. public override void Dispose()
  34. {
  35. if (_sceneObject != null)
  36. {
  37. PrefabManager.Instance.Restore(_sceneObject);
  38. _sceneObject = null;
  39. }
  40. for (int i = 0; i < _listLongPress.Count; i++)
  41. {
  42. _listLongPress[i].Dispose();
  43. }
  44. // _dressUpData.Dispose();
  45. if (_ui != null)
  46. {
  47. _ui.Dispose();
  48. _ui = null;
  49. }
  50. base.Dispose();
  51. }
  52. protected override void Init()
  53. {
  54. base.Init();
  55. packageName = UI_ArenaDressUpFightUI.PACKAGE_NAME;
  56. _ui = UI_ArenaDressUpFightUI.Create();
  57. viewCom = _ui.target;
  58. isfullScreen = true;
  59. isReturnView = true;
  60. }
  61. protected override void OnInit()
  62. {
  63. base.OnInit();
  64. _ui.m_btnLastStep.visible = true;
  65. _ui.m_btnNextStep.visible = true;
  66. _ui.m_btnSearch.visible = true;
  67. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  68. _ui.m_partsListSearch.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  69. InitLists();
  70. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  71. _ui.m_partsListSearch.m_comboBoxRarity.onChanged.Add(OnSearchComboBoxRarityChanged);
  72. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  73. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  74. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  75. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  76. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  77. _ui.m_partsListSearch.m_list.onClickItem.Add(OnClickSearchPartsListItem);
  78. _ui.m_touchPad.onClick.Add(OnTouchPad);
  79. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  80. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  81. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  82. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  83. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  84. // _ui.m_comValueInfo.m_btnFightScoreRule.onClick.Add(OnBtnFightScoreRule);
  85. _ui.m_comValueInfo.GetChild("btnFightScoreRule").onClick.Add(OnBtnFightScoreRule);
  86. _ui.m_grhCloseComFightScore.onClick.Add(OnCloseComFightScore);
  87. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  88. _ui.m_partsList2.m_imgTop.visible = true;
  89. _ui.m_partsList.m_imgTop.visible = false;
  90. }
  91. protected override void AddEventListener()
  92. {
  93. base.AddEventListener();
  94. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  95. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  96. EventAgent.AddEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  97. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  98. }
  99. protected override void RemoveEventListener()
  100. {
  101. base.RemoveEventListener();
  102. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  103. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  104. EventAgent.RemoveEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  105. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  106. }
  107. protected override void OnShown()
  108. {
  109. base.OnShown();
  110. _dataManager = ArenaDataManager.Instance;
  111. _roleData = _dataManager.DressupList[_dataManager.SelectThemeIndex];
  112. _itemList = new List<int>(_roleData.itemList);
  113. InstanceZonesDataManager.currentScoreType = _dataManager.ThemeList[_dataManager.SelectThemeIndex];
  114. InstanceZonesDataManager.currentFightTags = _dataManager.DressupList[_dataManager.SelectThemeIndex].tags;
  115. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  116. _ui.m_grhCloseComFightScore.visible = false;
  117. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  118. _ui.m_comListType1.m_listType.numItems = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList.Count - 3;
  119. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  120. if (_ui.m_comListType1.m_listType.height > maxHeight)
  121. {
  122. _ui.m_comListType1.m_listType.height = maxHeight;
  123. }
  124. _ui.m_comListType1.target.x = _ui.target.width;
  125. _ui.m_comListType2.target.x = _ui.target.width;
  126. _ui.m_partsList.target.x = _ui.target.width;
  127. _ui.m_partsList2.target.x = _ui.target.width;
  128. _ui.m_partsListSearch.target.x = _ui.target.width;
  129. this.showListType1();
  130. void SetupAfterInstantiate()
  131. {
  132. MyDressUpHelper.dressUpObj.PutOnItemList(_roleData.itemList);
  133. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  134. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  135. _ui.m_c1.selectedIndex = 0;
  136. UpdateStepBtn(true);
  137. UpdateValueInfo();
  138. SendLog();
  139. }
  140. if (_sceneObject == null)
  141. {
  142. PrefabManager.Instance.InstantiateAsync(
  143. ResPathUtil.GetPrefabPath("SceneArenaDressUpFight"),
  144. (go) =>
  145. {
  146. if (go != null)
  147. {
  148. _sceneObject = go;
  149. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, true);
  150. MyDressUpHelper.dressUpObj.AddOrRemove(180001, false);
  151. SetupAfterInstantiate();
  152. }
  153. else
  154. {
  155. Debug.LogError("场景对象异步加载失败: SceneArenaDressUpFight");
  156. }
  157. });
  158. }
  159. else
  160. {
  161. SetupAfterInstantiate();
  162. }
  163. cardId = _roleData.cardId;
  164. }
  165. protected override void OnHide()
  166. {
  167. base.OnHide();
  168. if (_sceneObject != null)
  169. {
  170. PrefabManager.Instance.Restore(_sceneObject);
  171. _sceneObject = null;
  172. }
  173. DressUpMenuItemDataManager.Clear();
  174. MyDressUpHelper.ResetMemory();
  175. _ui.m_grhCloseComFightScore.visible = false;
  176. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  177. }
  178. private void OnClickBtnBack()
  179. {
  180. bool isSave = _itemList.Count == MyDressUpHelper.dressUpObj.itemList.Count;
  181. if (isSave)
  182. {
  183. for (int i = 0; i < _itemList.Count; i++)
  184. {
  185. int itemId = MyDressUpHelper.dressUpObj.itemList[i];
  186. if (_itemList.IndexOf(itemId) < 0)
  187. {
  188. isSave = false;
  189. break;
  190. }
  191. }
  192. }
  193. if (!isSave)
  194. {
  195. AlertUI.Show("当前穿搭尚未保存,是否确定退出?")
  196. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  197. {
  198. _roleData.cardId = cardId;
  199. GoBackToView();
  200. });
  201. }
  202. else
  203. {
  204. GoBackToView();
  205. }
  206. }
  207. private void GoBackToView()
  208. {
  209. _roleData.itemList = _itemList;
  210. FightDataManager.Instance.SetItemScoreList(_roleData);
  211. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  212. //ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  213. //ViewManager.Show<ArenaDressInfoView>(new object[] { FightRoleType.MINE, 0, ArenaDataManager.Instance.DressupList, "" });
  214. this.Hide();
  215. }
  216. private void OnBtnFightScoreRule()
  217. {
  218. _ui.m_grhCloseComFightScore.visible = true;
  219. }
  220. private void OnCloseComFightScore()
  221. {
  222. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  223. _ui.m_grhCloseComFightScore.visible = false;
  224. }
  225. private void OnClickBtnHome()
  226. {
  227. AlertUI.Show("是否返回?")
  228. .SetLeftButton(true, "否")
  229. .SetRightButton(true, "是", (object data) => { GameController.GoBackToMainView(); });
  230. }
  231. private void UpdateValueInfo()
  232. {
  233. _roleData.itemList = MyDressUpHelper.dressUpObj.itemList;
  234. FightDataManager.Instance.SetItemScoreList(_roleData);
  235. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  236. ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo, _dataManager.SelectThemeIndex,
  237. _dataManager.DressupList);
  238. }
  239. private void OnClickListType1Item(EventContext context)
  240. {
  241. // GuideController.HideGuide();
  242. GObject typeItem = context.data as GObject;
  243. int order = (int)typeItem.data;
  244. DressUpMenuItemCfg1 item1 = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList[order - 1];
  245. if (item1.SubMenus.Count > 0)
  246. {
  247. this.showListType2(item1.SubMenus);
  248. }
  249. else
  250. {
  251. if (this.showListParts(item1.Type) == false)
  252. {
  253. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  254. return;
  255. }
  256. this.showListParts(item1.Type);
  257. }
  258. this.hideListType1();
  259. UpdateListPartsSelected();
  260. }
  261. private void OnClickListType2Item(EventContext context)
  262. {
  263. GObject typeItem = context.data as GObject;
  264. int order = (int)typeItem.data;
  265. DressUpMenuItemCfg2 item2 = CommonDataManager.Tables.TblDressUpMenuItemCfg2.DataList[order - 1];
  266. if (this.showListParts(item2.Type) == false)
  267. {
  268. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  269. return;
  270. }
  271. this.hideListType2();
  272. }
  273. private void OnClickSearchPartsListItem(EventContext context)
  274. {
  275. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  276. {
  277. return;
  278. }
  279. GObject listItem = context.data as GObject;
  280. int id = (int)listItem.data;
  281. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  282. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  283. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  284. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >=
  285. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount;
  286. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  287. {
  288. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  289. return;
  290. }
  291. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  292. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  293. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  294. UpdateStepBtn(true);
  295. // UpdateSearchListPartsSelected();
  296. UpdateValueInfo();
  297. }
  298. private void OnClickPartsListItem(EventContext context)
  299. {
  300. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  301. {
  302. return;
  303. }
  304. GObject listItem = context.data as GObject;
  305. int id = (int)listItem.data;
  306. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  307. {
  308. partsListScrollingPosY = _ui.m_partsList.m_list.scrollPane.scrollingPosY;
  309. this.showListParts2(id);
  310. this.hideListParts();
  311. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  312. }
  313. else
  314. {
  315. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  316. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  317. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  318. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >=
  319. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount;
  320. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  321. {
  322. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  323. return;
  324. }
  325. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  326. }
  327. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  328. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  329. UpdateStepBtn(true);
  330. // UpdateListPartsSelected();
  331. // UpdateListSuitPartsSelected();
  332. UpdateValueInfo();
  333. }
  334. private void OnClickSuitPartsListItem(EventContext context)
  335. {
  336. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  337. {
  338. return;
  339. }
  340. GObject listItem = (GObject)context.data as GObject;
  341. int id = (int)listItem.data;
  342. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  343. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  344. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  345. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >=
  346. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount;
  347. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  348. {
  349. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  350. return;
  351. }
  352. if (!DressUpMenuItemDataManager.CheckHasItem(id))
  353. {
  354. PromptController.Instance.ShowFloatTextPrompt("还未获得这件装扮");
  355. return;
  356. }
  357. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  358. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  359. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  360. UpdateStepBtn(true);
  361. // UpdateListSuitPartsSelected();
  362. UpdateValueInfo();
  363. }
  364. private void UpdateStepBtn(bool isAdd, int suitId = 0)
  365. {
  366. if (isAdd)
  367. {
  368. MyDressUpHelper.AddMemoryDressup();
  369. }
  370. _ui.m_btnLastStep.enabled = MyDressUpHelper.stepIndex > 0;
  371. _ui.m_btnNextStep.enabled = MyDressUpHelper.stepIndex < MyDressUpHelper.dressMemory.Count - 1;
  372. UpdateListPartsSelected();
  373. UpdateListSuitPartsSelected();
  374. UpdateSearchListPartsSelected();
  375. }
  376. private void OnLongPress(EventContext context)
  377. {
  378. LongPressGesture gesture = (LongPressGesture)context.sender;
  379. int itemId = (int)gesture.host.data;
  380. GoodsItemTipsController.ShowItemTips(itemId);
  381. }
  382. private void OnTouchPad()
  383. {
  384. if (this.currentListType == DressUpListType.List4)
  385. {
  386. this.hideListParts2();
  387. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  388. }
  389. else if (this.currentListType == DressUpListType.List3)
  390. {
  391. if (_currentList2 != null)
  392. {
  393. this.showListType2(_currentList2);
  394. }
  395. else
  396. {
  397. this.showListType1();
  398. }
  399. this.hideListParts();
  400. }
  401. else if (this.currentListType == DressUpListType.List2)
  402. {
  403. this.showListType1();
  404. this.hideListType2();
  405. }
  406. else if (this.currentListType == DressUpListType.List5)
  407. {
  408. this.showListType1();
  409. this.hideSearchListType();
  410. }
  411. }
  412. private void OnClickBtnDelete()
  413. {
  414. MyDressUpHelper.dressUpObj.TakeOffAll();
  415. _roleData.cardId = 0;
  416. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  417. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  418. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  419. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  420. UpdateStepBtn(true);
  421. // UpdateListPartsSelected();
  422. // UpdateListSuitPartsSelected();
  423. UpdateValueInfo();
  424. }
  425. private void OnClickBtnNext()
  426. {
  427. // if (!MyDressUpHelper.CheckPutOnFinish())
  428. // {
  429. // AlertUI.Show("换好衣服才能进行下一步哦~").SetRightButton(true, "好的");
  430. // }
  431. // else
  432. // {
  433. DressUpFinish();
  434. // }
  435. }
  436. private async void DressUpFinish()
  437. {
  438. if (CardDataManager.GetCardListByRoleType(0).Count > 0)
  439. {
  440. ViewManager.Show<StoryCardChoose>(InstanceZonesDataManager.currentScoreType);
  441. }
  442. else
  443. {
  444. List<long> fightScoreDatas =
  445. ArenaDataManager.Instance.GetFightScoreList(ArenaDataManager.Instance.DressupList);
  446. bool result = await ArenaSproxy.ReqChangeArenaDressup(_dataManager.SelectThemeIndex, 0,
  447. MyDressUpHelper.dressUpObj.itemList, fightScoreDatas);
  448. if (result)
  449. {
  450. _itemList = new List<int>(MyDressUpHelper.dressUpObj.itemList);
  451. PromptController.Instance.ShowFloatTextPrompt("保存成功");
  452. OnClickBtnBack();
  453. }
  454. }
  455. }
  456. // private void OnClickBtnRecommend()
  457. // {
  458. // if (this.currentListType == DressUpListType.List4)
  459. // {
  460. // this.hideListParts2();
  461. // this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  462. // }
  463. // MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(_currentSuitId);
  464. // MyDressUpHelper.PutOnRecommendItems2();
  465. // _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  466. // UpdateListPartsSelected();
  467. // UpdateListSuitPartsSelected();
  468. // }
  469. private void InitLists()
  470. {
  471. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  472. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  473. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  474. _ui.m_partsListSearch.m_list.itemRenderer = ListPartsItem;
  475. listType1X = _ui.m_comListType1.target.x;
  476. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  477. //一级菜单
  478. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  479. }
  480. private void showListType1()
  481. {
  482. _currentList2 = null;
  483. currentListType = DressUpListType.List1;
  484. _ui.m_comListType1.m_listType.numItems = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList.Count - 3;
  485. GTween.To(_ui.target.width, listType1X, 0.5f)
  486. .SetTarget(_ui.m_comListType1.target)
  487. .OnUpdate((GTweener t) => { _ui.m_comListType1.target.x = t.value.x; });
  488. }
  489. private void hideListType1()
  490. {
  491. GTween.To(listType1X, _ui.target.width, 0.5f)
  492. .SetTarget(_ui.m_comListType1.target)
  493. .OnUpdate((GTweener t) => { _ui.m_comListType1.target.x = t.value.x; });
  494. }
  495. private void showListType2(List<int> menuStrArr = null)
  496. {
  497. currentListType = DressUpListType.List2;
  498. if (menuStrArr != null && menuStrArr.Count > 0)
  499. {
  500. int len = menuStrArr.Count;
  501. _currentList2 = menuStrArr;
  502. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  503. _ui.m_comListType2.m_listType.numItems = len;
  504. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  505. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  506. if (_ui.m_comListType2.m_listType.height > maxHeight)
  507. {
  508. _ui.m_comListType2.m_listType.height = maxHeight;
  509. }
  510. }
  511. GTween.To(_ui.target.width, listType1X, 0.5f)
  512. .SetTarget(_ui.m_comListType2.target)
  513. .OnUpdate((GTweener t) => { _ui.m_comListType2.target.x = t.value.x; });
  514. }
  515. private void hideListType2()
  516. {
  517. GTween.To(listType1X, _ui.target.width, 0.5f)
  518. .SetTarget(_ui.m_comListType2.target)
  519. .OnUpdate((GTweener t) => { _ui.m_comListType2.target.x = t.value.x; });
  520. }
  521. private bool showListParts(int type, bool selectItem = false)
  522. {
  523. _currentMenuType = type;
  524. UpdatePartsListSort();
  525. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  526. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  527. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  528. if (_ui.m_partsList.m_list.height > maxHeight)
  529. {
  530. _ui.m_partsList.m_list.height = maxHeight;
  531. }
  532. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  533. {
  534. _ui.m_partsList.m_list.scrollPane.SetPosY(partsListScrollingPosY, false);
  535. partsListScrollingPosY = 0;
  536. }
  537. currentListType = DressUpListType.List3;
  538. GTween.To(_ui.target.width, partsListX, 0.5f)
  539. .SetTarget(_ui.m_partsList)
  540. .OnUpdate((GTweener t) => { _ui.m_partsList.target.x = t.value.x; });
  541. UpdateListPartsSelected();
  542. return true;
  543. }
  544. private void OnComboBoxRarityChanged()
  545. {
  546. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  547. this.UpdatePartsListSort();
  548. }
  549. private void OnSearchComboBoxRarityChanged()
  550. {
  551. _scoreIndex = _ui.m_partsListSearch.m_comboBoxRarity.selectedIndex;
  552. this.UpdateSearchList();
  553. }
  554. private void UpdatePartsListSort()
  555. {
  556. if (_currentMenuType == 0) return;
  557. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  558. {
  559. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  560. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  561. {
  562. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  563. }
  564. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  565. {
  566. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  567. }
  568. else
  569. {
  570. _currentList3.Reverse();
  571. }
  572. }
  573. else
  574. {
  575. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  576. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  577. {
  578. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3);
  579. }
  580. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  581. {
  582. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3);
  583. }
  584. else
  585. {
  586. _currentList3.Reverse();
  587. }
  588. }
  589. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  590. {
  591. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  592. }
  593. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  594. {
  595. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  596. }
  597. _ui.m_partsList.m_list.RemoveChildrenToPool();
  598. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  599. }
  600. private void UpdateSuitPartsListSort()
  601. {
  602. if (_currentMenuType == 0) return;
  603. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId, true));
  604. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  605. {
  606. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  607. }
  608. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  609. {
  610. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  611. }
  612. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  613. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  614. }
  615. private void hideListParts()
  616. {
  617. GTween.To(partsListX, _ui.target.width, 0.5f)
  618. .SetTarget(_ui.m_partsList)
  619. .OnUpdate((GTweener t) => { _ui.m_partsList.target.x = t.value.x; });
  620. }
  621. private void showListParts2(int suitId)
  622. {
  623. _currentSuitId = suitId;
  624. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  625. this.UpdateSuitPartsListSort();
  626. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  627. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y; // - DressUpView.BOTTOM_BLANK;
  628. if (_ui.m_partsList2.m_list.height > maxHeight)
  629. {
  630. _ui.m_partsList2.m_list.height = maxHeight;
  631. }
  632. currentListType = DressUpListType.List4;
  633. GTween.To(_ui.target.width, partsListX, 0.5f)
  634. .SetTarget(_ui.m_partsList2)
  635. .OnUpdate((GTweener t) => { _ui.m_partsList2.target.x = t.value.x; });
  636. }
  637. private void hideListParts2()
  638. {
  639. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  640. GTween.To(partsListX, _ui.target.width, 0.5f)
  641. .SetTarget(_ui.m_partsList2)
  642. .OnUpdate((GTweener t) => { _ui.m_partsList2.target.x = t.value.x; });
  643. }
  644. private void showSearchListType()
  645. {
  646. // _currentList2 = null;
  647. currentListType = DressUpListType.List5;
  648. GTween.To(_ui.target.width, partsListX, 0.5f)
  649. .SetTarget(_ui.m_partsListSearch.target)
  650. .OnUpdate((GTweener t) => { _ui.m_partsListSearch.target.x = t.value.x; });
  651. }
  652. private void hideSearchListType()
  653. {
  654. GTween.To(partsListX, _ui.target.width, 0.5f)
  655. .SetTarget(_ui.m_partsListSearch.target)
  656. .OnUpdate((GTweener t) => { _ui.m_partsListSearch.target.x = t.value.x; });
  657. }
  658. /*****************************************************************************************************/
  659. private void DressResetSerch()
  660. {
  661. if (currentListType == DressUpListType.List5)
  662. {
  663. OnTouchPad();
  664. }
  665. }
  666. private void UpdateSerch(EventContext context)
  667. {
  668. if (context.data.ToString() == ConstMessage.DRESS_SEARCH)
  669. {
  670. _currentList3 = DressUpMenuItemDataManager.DressSearch(false);
  671. }
  672. else if (context.data.ToString() == ConstMessage.DRESS_FILTER)
  673. {
  674. _currentList3 = DressUpMenuItemDataManager.DressFilter(false);
  675. }
  676. ViewManager.Hide<ModalStatusView>();
  677. UpdateSearchList();
  678. if (currentListType != DressUpListType.List5)
  679. {
  680. hideListParts();
  681. hideListParts2();
  682. hideListType1();
  683. hideListType2();
  684. showSearchListType();
  685. }
  686. _currentMenuType = 0;
  687. }
  688. private void UpdateSearchList()
  689. {
  690. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  691. {
  692. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3, true);
  693. }
  694. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  695. {
  696. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3, true);
  697. }
  698. _currentMenuType = 0;
  699. _ui.m_partsListSearch.m_list.numItems = _currentList3.Count;
  700. ;
  701. }
  702. private void ListType1Item(int index, GObject item)
  703. {
  704. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  705. DressUpMenuItemCfg1 item1 = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList[index];
  706. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.Id;
  707. typeItem.m_txtname.text = item1.Name;
  708. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  709. typeItem.target.data = item1.Id;
  710. typeItem.m_imgNeed.visible = false;
  711. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.Id);
  712. UI.DressUp.UI_TypeItem.ProxyEnd();
  713. }
  714. private void ListType2Item(int index, GObject item)
  715. {
  716. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  717. DressUpMenuItemCfg2 item2 =
  718. CommonDataManager.Tables.TblDressUpMenuItemCfg2.DataList[_currentList2[index] - 1];
  719. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.Id;
  720. typeItem.m_txtname.text = item2.Name;
  721. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  722. typeItem.target.data = item2.Id;
  723. // var subType = ItemUtilCS.GetItemSubType(_fightCfg.needItemId);
  724. typeItem.m_imgNeed.visible = false;
  725. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.Id);
  726. UI.DressUp.UI_TypeItem.ProxyEnd();
  727. }
  728. private void ListPartsItem(int index, GObject item)
  729. {
  730. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  731. int id = (int)_currentList3[index];
  732. string iconRes = "";
  733. string partName = "";
  734. string ext = "png";
  735. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  736. {
  737. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(id);
  738. iconRes = suitCfg.Res;
  739. partName = suitCfg.Name;
  740. listItem.m_iconSelected.visible = false;
  741. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  742. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  743. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.Rarity;
  744. listItem.m_imgNew.visible = false;
  745. }
  746. else
  747. {
  748. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  749. iconRes = itemCfg.Res;
  750. partName = itemCfg.Name;
  751. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  752. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id,
  753. InstanceZonesDataManager.currentScoreType, _roleData.tags);
  754. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.Rarity;
  755. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  756. listItem.m_imgNew.visible = isNew;
  757. if (isNew)
  758. {
  759. ItemProxy.ReqSetItemRead(id).Coroutine();
  760. }
  761. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  762. ext = ItemUtil.GetItemResExt(itemCfg.ItemType, itemCfg.SubType, true);
  763. }
  764. if (listItem.target.data == null)
  765. {
  766. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  767. longPressGesture.trigger = GameConfig.LongPressGestureTrigger;
  768. longPressGesture.once = true;
  769. longPressGesture.onAction.Add(OnLongPress);
  770. _listLongPress.Add(longPressGesture);
  771. }
  772. listItem.m_btnAni.visible = false;
  773. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  774. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + InstanceZonesDataManager.currentScoreType;
  775. listItem.m_txtTitle.text = partName;
  776. listItem.target.data = id;
  777. listItem.m_imgNeed.visible = false;
  778. UI_PartsListItem.ProxyEnd();
  779. }
  780. private void ListParts2Item(int index, GObject item)
  781. {
  782. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  783. int id = (int)_currentList4[index];
  784. string iconRes = "";
  785. string partName = "";
  786. string ext = "png";
  787. if (listItem.target.data == null)
  788. {
  789. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  790. longPressGesture.trigger = GameConfig.LongPressGestureTrigger;
  791. longPressGesture.once = true;
  792. longPressGesture.onAction.Add(OnLongPress);
  793. _listLongPress.Add(longPressGesture);
  794. }
  795. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  796. iconRes = itemCfg.Res;
  797. partName = itemCfg.Name;
  798. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  799. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.Rarity;
  800. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  801. ext = ItemUtil.GetItemResExt(itemCfg.ItemType, itemCfg.SubType, true);
  802. listItem.m_ScoreType.visible = true;
  803. // int mainScore;
  804. // int mainValuel;
  805. // ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  806. listItem.m_ScoreType.url =
  807. ResPathUtil.GetCommonGameResPath("kp_sx_" + InstanceZonesDataManager.currentScoreType);
  808. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id,
  809. InstanceZonesDataManager.currentScoreType,
  810. _dataManager.DressupList[_dataManager.SelectThemeIndex].tags);
  811. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  812. listItem.m_txtTitle.text = partName;
  813. listItem.target.data = id;
  814. // listItem.m_txtScore.visible = false;
  815. //listItem.m_ScoreType.visible = true;
  816. listItem.m_imgNeed.visible = false;
  817. listItem.m_btnAni.visible = false;
  818. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  819. listItem.m_imgNew.visible = isNew;
  820. if (isNew)
  821. {
  822. ItemProxy.ReqSetItemRead(id).Coroutine();
  823. }
  824. UI_PartsListItem.ProxyEnd();
  825. }
  826. private void UpdateSearchListPartsSelected()
  827. {
  828. int count = _ui.m_partsListSearch.m_list.numChildren;
  829. int suitId = MyDressUpHelper.dressUpObj.suitId;
  830. for (int i = 0; i < count; i++)
  831. {
  832. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsListSearch.m_list.GetChildAt(i));
  833. int id = (int)listItem.target.data;
  834. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  835. {
  836. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  837. }
  838. else
  839. {
  840. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id); //非套装金判断是否穿戴
  841. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  842. bool isSuit = !isSceneType && suitId > 0 &&
  843. SuitCfgArray.Instance.GetSuitIdOfItem(id) ==
  844. suitId; //非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  845. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn; //场景类, 若当前穿戴套装要判断item是否属已穿戴
  846. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  847. }
  848. UI_PartsListItem.ProxyEnd();
  849. }
  850. }
  851. private void UpdateListPartsSelected()
  852. {
  853. GList list;
  854. if (_ui.m_partsList.target.x == partsListX)
  855. {
  856. list = _ui.m_partsList.m_list;
  857. }
  858. else if (_ui.m_partsListSearch.target.x == partsListX)
  859. {
  860. list = _ui.m_partsListSearch.m_list;
  861. }
  862. else
  863. {
  864. return;
  865. }
  866. int count = list.numChildren;
  867. int suitId = MyDressUpHelper.dressUpObj.suitId;
  868. for (int i = 0; i < count; i++)
  869. {
  870. UI_PartsListItem listItem = UI_PartsListItem.Proxy(list.GetChildAt(i));
  871. int id = (int)listItem.target.data;
  872. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  873. {
  874. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  875. }
  876. else
  877. {
  878. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id); //非套装金判断是否穿戴
  879. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  880. bool isSuit = !isSceneType && suitId > 0 &&
  881. SuitCfgArray.Instance.GetSuitIdOfItem(id) ==
  882. suitId; //非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  883. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn; //场景类, 若当前穿戴套装要判断item是否属已穿戴
  884. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  885. }
  886. UI_PartsListItem.ProxyEnd();
  887. }
  888. }
  889. private void UpdateListSuitPartsSelected()
  890. {
  891. int count = _ui.m_partsList2.m_list.numChildren;
  892. int suitId = MyDressUpHelper.dressUpObj.suitId;
  893. for (int i = 0; i < count; i++)
  894. {
  895. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  896. int id = (int)listItem.target.data;
  897. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id); //非套装金判断是否穿戴
  898. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  899. bool isSuit =
  900. !isSceneType && suitId > 0 &&
  901. SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId; //非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  902. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn; //场景类, 若当前穿戴套装要判断item是否属已穿戴
  903. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  904. UI_PartsListItem.ProxyEnd();
  905. }
  906. }
  907. private void OnClickBtnSearch()
  908. {
  909. ViewManager.Show<DressFilterView>(false);
  910. }
  911. private void OnClickBtnLastStep()
  912. {
  913. if (!MyDressUpHelper.OnClickBtnLastStep()) return;
  914. UpdateStepBtn(false);
  915. }
  916. private void OnClickBtnNextStep()
  917. {
  918. if (!MyDressUpHelper.OnClickBtnNextStep()) return;
  919. UpdateStepBtn(false);
  920. }
  921. private void SendLog()
  922. {
  923. }
  924. }
  925. }