ArenaDressUpFightView.cs 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  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. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  808. listItem.m_imgNew.visible = isNew;
  809. if (isNew)
  810. {
  811. ItemProxy.ReqSetItemRead(id).Coroutine();
  812. }
  813. UI_PartsListItem.ProxyEnd();
  814. }
  815. private void UpdateSearchListPartsSelected()
  816. {
  817. int count = _ui.m_partsListSearch.m_list.numChildren;
  818. int suitId = MyDressUpHelper.dressUpObj.suitId;
  819. for (int i = 0; i < count; i++)
  820. {
  821. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsListSearch.m_list.GetChildAt(i));
  822. int id = (int)listItem.target.data;
  823. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  824. {
  825. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  826. }
  827. else
  828. {
  829. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  830. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  831. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  832. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  833. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  834. }
  835. UI_PartsListItem.ProxyEnd();
  836. }
  837. }
  838. private void UpdateListPartsSelected()
  839. {
  840. int count = _ui.m_partsList.m_list.numChildren;
  841. int suitId = MyDressUpHelper.dressUpObj.suitId;
  842. for (int i = 0; i < count; i++)
  843. {
  844. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  845. int id = (int)listItem.target.data;
  846. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  847. {
  848. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  849. }
  850. else
  851. {
  852. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  853. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  854. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  855. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  856. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  857. }
  858. UI_PartsListItem.ProxyEnd();
  859. }
  860. }
  861. private void UpdateListSuitPartsSelected()
  862. {
  863. int count = _ui.m_partsList2.m_list.numChildren;
  864. int suitId = MyDressUpHelper.dressUpObj.suitId;
  865. for (int i = 0; i < count; i++)
  866. {
  867. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  868. int id = (int)listItem.target.data;
  869. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  870. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  871. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  872. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  873. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  874. UI_PartsListItem.ProxyEnd();
  875. }
  876. }
  877. private void OnClickBtnSearch()
  878. {
  879. ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
  880. }
  881. private void OnClickBtnLastStep()
  882. {
  883. if (!MyDressUpHelper.OnClickBtnLastStep()) return;
  884. UpdateStepBtn(false);
  885. }
  886. private void OnClickBtnNextStep()
  887. {
  888. if (!MyDressUpHelper.OnClickBtnNextStep()) return;
  889. UpdateStepBtn(false);
  890. }
  891. private void SendLog()
  892. {
  893. }
  894. private void CheckGuide(object param)
  895. {
  896. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0
  897. || GuideDataManager.IsGuideFinish(ConstGuideId.AUTOPLAY_FIGHT) <= 0)
  898. {
  899. UpdateToCheckGuide(null);
  900. }
  901. else
  902. {
  903. Timers.inst.Remove(CheckGuide);
  904. }
  905. }
  906. protected override void UpdateToCheckGuide(object param)
  907. {
  908. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  909. }
  910. protected override void TryCompleteGuide()
  911. {
  912. base.TryCompleteGuide();
  913. }
  914. }
  915. }