ArenaDressUpFightView.cs 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. using UI.DressUp;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. using System;
  6. using ET;
  7. using System.Collections;
  8. using System.Threading.Tasks;
  9. using UI.Arena;
  10. using UI.CommonGame;
  11. namespace GFGGame
  12. {
  13. public class ArenaDressUpFightView : BaseView
  14. {
  15. private UI_ArenaDressUpFightUI _ui;
  16. // private DressUpObj _dressUpData = new DressUpObj();
  17. private ArenaDataManager _dataManager;
  18. private FightData _roleData;
  19. public List<int> _itemList;//记录打开界面时的穿戴数据(保存后会更新)
  20. private float listType1X = 0;
  21. private float partsListX = 0;
  22. private float partsListScrollingPosY = 0;
  23. private DressUpListType currentListType;
  24. private int[] _currentList2;
  25. private GameObject _scenePrefab;
  26. private GameObject _sceneObject;
  27. private List<int> _currentList3 = new List<int>();
  28. private List<int> _currentList4 = new List<int>();
  29. private int _currentMenuType;
  30. private int _currentSuitId;
  31. // private StoryLevelCfg _levelCfg;
  32. // private StoryFightCfg _fightCfg;
  33. private const int SORT_BY_HIGH_SCORE = 0;
  34. private const int SORT_BY_LOW_SCORE = 1;
  35. private int _scoreIndex = SORT_BY_HIGH_SCORE;
  36. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  37. public override void Dispose()
  38. {
  39. if (_sceneObject != null)
  40. {
  41. GameObject.Destroy(_sceneObject);
  42. _sceneObject = null;
  43. }
  44. for (int i = 0; i < _listLongPress.Count; i++)
  45. {
  46. _listLongPress[i].Dispose();
  47. }
  48. // _dressUpData.Dispose();
  49. if (_ui != null)
  50. {
  51. _ui.Dispose();
  52. _ui = null;
  53. }
  54. base.Dispose();
  55. }
  56. protected override void Init()
  57. {
  58. base.Init();
  59. packageName = UI_ArenaDressUpFightUI.PACKAGE_NAME;
  60. _ui = UI_ArenaDressUpFightUI.Create();
  61. viewCom = _ui.target;
  62. isfullScreen = true;
  63. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArenaDressUpFight"));
  64. }
  65. protected override void OnInit()
  66. {
  67. base.OnInit();
  68. _ui.m_btnLastStep.visible = true;
  69. _ui.m_btnNextStep.visible = true;
  70. _ui.m_btnSearch.visible = true;
  71. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  72. _ui.m_partsListSearch.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  73. InitLists();
  74. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  75. _ui.m_partsListSearch.m_comboBoxRarity.onChanged.Add(OnSearchComboBoxRarityChanged);
  76. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  77. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  78. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  79. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  80. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  81. _ui.m_partsListSearch.m_list.onClickItem.Add(OnClickSearchPartsListItem);
  82. _ui.m_touchPad.onClick.Add(OnTouchPad);
  83. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  84. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  85. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  86. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  87. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  88. // _ui.m_comValueInfo.m_btnFightScoreRule.onClick.Add(OnBtnFightScoreRule);
  89. _ui.m_comValueInfo.GetChild("btnFightScoreRule").onClick.Add(OnBtnFightScoreRule);
  90. _ui.m_grhCloseComFightScore.onClick.Add(OnCloseComFightScore);
  91. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  92. _ui.m_partsList2.m_imgTop.visible = true;
  93. _ui.m_partsList.m_imgTop.visible = false;
  94. }
  95. protected override void AddEventListener()
  96. {
  97. base.AddEventListener();
  98. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  99. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  100. EventAgent.AddEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  101. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  102. }
  103. protected override void OnShown()
  104. {
  105. base.OnShown();
  106. _dataManager = ArenaDataManager.Instance;
  107. _roleData = _dataManager.DressupList[_dataManager.SelectThemeIndex];
  108. _itemList = new List<int>(_roleData.itemList);
  109. InstanceZonesDataManager.currentScoreType = _dataManager.ThemeList[_dataManager.SelectThemeIndex];
  110. InstanceZonesDataManager.currentFightTags = _dataManager.DressupList[_dataManager.SelectThemeIndex].tags;
  111. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  112. _ui.m_grhCloseComFightScore.visible = false;
  113. //一级菜单
  114. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  115. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  116. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  117. if (_ui.m_comListType1.m_listType.height > maxHeight)
  118. {
  119. _ui.m_comListType1.m_listType.height = maxHeight;
  120. }
  121. _ui.m_comListType1.target.x = _ui.target.width;
  122. _ui.m_comListType2.target.x = _ui.target.width;
  123. _ui.m_partsList.target.x = _ui.target.width;
  124. _ui.m_partsList2.target.x = _ui.target.width;
  125. this.showListType1();
  126. if (_sceneObject == null)
  127. {
  128. _sceneObject = GameObject.Instantiate(_scenePrefab);
  129. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
  130. // GameObject copyObj = _sceneObject.transform.Find("CopyRole").gameObject;
  131. // _dressUpData.setSceneObj(copyObj);
  132. }
  133. MyDressUpHelper.dressUpObj.PutOnItemList(_roleData.itemList);
  134. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  135. UpdateStepBtn(true);
  136. UpdateValueInfo();
  137. SendLog();
  138. Timers.inst.AddUpdate(CheckGuide);
  139. }
  140. protected override void OnHide()
  141. {
  142. base.OnHide();
  143. if (_sceneObject != null)
  144. {
  145. GameObject.Destroy(_sceneObject);
  146. _sceneObject = null;
  147. }
  148. // _dressUpData.TakeOffAll();
  149. // _dressUpData = null;
  150. DressUpMenuItemDataManager.Clear();
  151. MyDressUpHelper.ResetMemory();
  152. Timers.inst.Remove(CheckGuide);
  153. _ui.m_grhCloseComFightScore.visible = false;
  154. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  155. }
  156. protected override void RemoveEventListener()
  157. {
  158. base.RemoveEventListener();
  159. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  160. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  161. EventAgent.RemoveEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  162. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  163. }
  164. private void OnClickBtnBack()
  165. {
  166. bool isSave = _itemList.Count == MyDressUpHelper.dressUpObj.itemList.Count;
  167. if (isSave)
  168. {
  169. for (int i = 0; i < _itemList.Count; i++)
  170. {
  171. int itemId = MyDressUpHelper.dressUpObj.itemList[i];
  172. if (_itemList.IndexOf(itemId) < 0)
  173. {
  174. isSave = false;
  175. break;
  176. }
  177. }
  178. }
  179. if (!isSave)
  180. {
  181. AlertUI.Show("当前穿搭尚未保存,是否确定退出?")
  182. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  183. {
  184. GoBackToView();
  185. });
  186. }
  187. else
  188. {
  189. GoBackToView();
  190. }
  191. }
  192. private void GoBackToView()
  193. {
  194. _roleData.itemList = _itemList;
  195. FightDataManager.Instance.SetItemScoreList(_roleData);
  196. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  197. ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  198. }
  199. private void OnBtnFightScoreRule()
  200. {
  201. _ui.m_grhCloseComFightScore.visible = true;
  202. }
  203. private void OnCloseComFightScore()
  204. {
  205. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  206. _ui.m_grhCloseComFightScore.visible = false;
  207. }
  208. private void OnClickBtnHome()
  209. {
  210. AlertUI.Show("是否返回?")
  211. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  212. {
  213. GameController.GoBackToMainView();
  214. });
  215. }
  216. private void UpdateValueInfo()
  217. {
  218. _roleData.itemList = MyDressUpHelper.dressUpObj.itemList;
  219. FightDataManager.Instance.SetItemScoreList(_roleData);
  220. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  221. ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo, _dataManager.SelectThemeIndex, _dataManager.DressupList);
  222. }
  223. private void OnClickListType1Item(EventContext context)
  224. {
  225. // GuideController.HideGuide();
  226. GObject typeItem = context.data as GObject;
  227. int order = (int)typeItem.data;
  228. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  229. if (item1.subMenusArr.Length > 0)
  230. {
  231. this.showListType2(item1.subMenusArr);
  232. }
  233. else
  234. {
  235. if (this.showListParts(item1.type) == false)
  236. {
  237. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  238. return;
  239. }
  240. this.showListParts(item1.type);
  241. }
  242. this.hideListType1();
  243. UpdateListPartsSelected();
  244. }
  245. private void OnClickListType2Item(EventContext context)
  246. {
  247. GObject typeItem = context.data as GObject;
  248. int order = (int)typeItem.data;
  249. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  250. if (this.showListParts(item2.type) == false)
  251. {
  252. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  253. return;
  254. }
  255. this.hideListType2();
  256. }
  257. private void OnClickSearchPartsListItem(EventContext context)
  258. {
  259. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  260. {
  261. return;
  262. }
  263. GObject listItem = context.data as GObject;
  264. int id = (int)listItem.data;
  265. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  266. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  267. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  268. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  269. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  270. {
  271. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  272. return;
  273. }
  274. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  275. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  276. UpdateStepBtn(true);
  277. // UpdateSearchListPartsSelected();
  278. UpdateValueInfo();
  279. }
  280. private void OnClickPartsListItem(EventContext context)
  281. {
  282. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  283. {
  284. return;
  285. }
  286. GObject listItem = context.data as GObject;
  287. int id = (int)listItem.data;
  288. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  289. {
  290. partsListScrollingPosY = _ui.m_partsList.m_list.scrollPane.scrollingPosY;
  291. this.showListParts2(id);
  292. this.hideListParts();
  293. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  294. }
  295. else
  296. {
  297. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  298. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  299. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  300. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  301. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  302. {
  303. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  304. return;
  305. }
  306. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  307. }
  308. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  309. UpdateStepBtn(true);
  310. // UpdateListPartsSelected();
  311. // UpdateListSuitPartsSelected();
  312. UpdateValueInfo();
  313. }
  314. private void OnClickSuitPartsListItem(EventContext context)
  315. {
  316. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  317. {
  318. return;
  319. }
  320. GObject listItem = (GObject)context.data as GObject;
  321. int id = (int)listItem.data;
  322. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  323. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  324. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  325. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  326. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  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_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. }