ArenaDressUpFightView.cs 42 KB

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