ArenaDressUpFightView.cs 41 KB

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