ArenaDressUpFightView.cs 41 KB

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