ArenaDressUpFightView.cs 41 KB

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