ArenaDressUpFightView.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  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. public FightData _roleData;
  19. // private int _fightID;
  20. // private int _levelID;
  21. private float listType1X = 0;
  22. private float partsListX = 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_btnSearch.visible = true;
  69. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  70. InitLists();
  71. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  72. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  73. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  74. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  75. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  76. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  77. _ui.m_touchPad.onClick.Add(OnTouchPad);
  78. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  79. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  80. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  81. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  82. _ui.m_partsList2.m_imgTop.visible = true;
  83. _ui.m_partsList.m_imgTop.visible = false;
  84. }
  85. protected override void AddEventListener()
  86. {
  87. base.AddEventListener();
  88. // EventAgent.AddEventListener(ConstMessage.CARD_CHOOSE, StartCalculateScore);
  89. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  90. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  91. // EventAgent.AddEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateValueInfo);
  92. }
  93. protected override void OnShown()
  94. {
  95. base.OnShown();
  96. _dataManager = ArenaDataManager.Instance;
  97. _roleData = _dataManager.DressupList[_dataManager.SelectThemeIndex];
  98. InstanceZonesDataManager.currentScoreType = _dataManager.ThemeList[_dataManager.SelectThemeIndex];
  99. InstanceZonesDataManager.currentFightTags = _dataManager.DressupList[_dataManager.SelectThemeIndex].tags;
  100. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  101. //一级菜单
  102. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  103. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  104. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  105. if (_ui.m_comListType1.m_listType.height > maxHeight)
  106. {
  107. _ui.m_comListType1.m_listType.height = maxHeight;
  108. }
  109. _ui.m_comListType1.target.x = _ui.target.width;
  110. _ui.m_comListType2.target.x = _ui.target.width;
  111. _ui.m_partsList.target.x = _ui.target.width;
  112. _ui.m_partsList2.target.x = _ui.target.width;
  113. this.showListType1();
  114. if (_sceneObject == null)
  115. {
  116. _sceneObject = GameObject.Instantiate(_scenePrefab);
  117. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
  118. GameObject copyObj = _sceneObject.transform.Find("CopyRole").gameObject;
  119. _dressUpData.setSceneObj(copyObj);
  120. }
  121. MyDressUpHelper.dressUpObj.PutOnItemList(_roleData.itemList);
  122. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  123. UpdateValueInfo();
  124. SendLog();
  125. Timers.inst.AddUpdate(CheckGuide);
  126. }
  127. protected override void OnHide()
  128. {
  129. base.OnHide();
  130. if (_sceneObject != null)
  131. {
  132. GameObject.Destroy(_sceneObject);
  133. _sceneObject = null;
  134. }
  135. DressUpMenuItemDataManager.Clear();
  136. Timers.inst.Remove(CheckGuide);
  137. }
  138. protected override void RemoveEventListener()
  139. {
  140. base.RemoveEventListener();
  141. // EventAgent.RemoveEventListener(ConstMessage.CARD_CHOOSE, StartCalculateScore);
  142. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  143. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  144. // EventAgent.RemoveEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateValueInfo);
  145. }
  146. private void OnClickBtnBack()
  147. {
  148. if (!MyDressUpHelper.CheckPutOnFinish())
  149. {
  150. AlertUI.Show("当前主题尚未穿戴完整,是否确定退出?")
  151. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  152. {
  153. ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  154. });
  155. }
  156. else
  157. {
  158. ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  159. }
  160. }
  161. private void OnClickBtnHome()
  162. {
  163. AlertUI.Show("是否返回?")
  164. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  165. {
  166. GameController.GoBackToMainView();
  167. });
  168. }
  169. private void UpdateValueInfo()
  170. {
  171. FightDataManager.Instance.SetItemScoreList(_roleData);
  172. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  173. ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo.target, _dataManager.SelectThemeIndex, _dataManager.DressupList);
  174. }
  175. private void OnClickListType1Item(EventContext context)
  176. {
  177. // GuideController.HideGuide();
  178. GObject typeItem = context.data as GObject;
  179. int order = (int)typeItem.data;
  180. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  181. if (item1.subMenusArr.Length > 0)
  182. {
  183. this.showListType2(item1.subMenusArr);
  184. }
  185. else
  186. {
  187. if (this.showListParts(item1.type) == false)
  188. {
  189. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  190. return;
  191. }
  192. this.showListParts(item1.type);
  193. }
  194. this.hideListType1();
  195. UpdateListPartsSelected();
  196. }
  197. private void OnClickListType2Item(EventContext context)
  198. {
  199. GObject typeItem = context.data as GObject;
  200. int order = (int)typeItem.data;
  201. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  202. if (this.showListParts(item2.type) == false)
  203. {
  204. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  205. return;
  206. }
  207. this.hideListType2();
  208. }
  209. private void OnClickPartsListItem(EventContext context)
  210. {
  211. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  212. {
  213. return;
  214. }
  215. GObject listItem = context.data as GObject;
  216. int id = (int)listItem.data;
  217. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  218. {
  219. this.showListParts2(id);
  220. this.hideListParts();
  221. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  222. }
  223. else
  224. {
  225. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  226. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  227. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  228. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  229. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  230. {
  231. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  232. return;
  233. }
  234. MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(id);
  235. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  236. }
  237. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  238. UpdateListPartsSelected();
  239. UpdateListSuitPartsSelected();
  240. UpdateValueInfo();
  241. }
  242. private void OnClickSuitPartsListItem(EventContext context)
  243. {
  244. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  245. {
  246. return;
  247. }
  248. GObject listItem = (GObject)context.data as GObject;
  249. int id = (int)listItem.data;
  250. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  251. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  252. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  253. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  254. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  255. {
  256. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  257. return;
  258. }
  259. MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(id);
  260. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  261. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  262. UpdateListSuitPartsSelected();
  263. UpdateValueInfo();
  264. }
  265. private void OnLongPress(EventContext context)
  266. {
  267. LongPressGesture gesture = (LongPressGesture)context.sender;
  268. int itemId = (int)gesture.host.data;
  269. GoodsItemTipsController.ShowItemTips(itemId);
  270. }
  271. private void OnTouchPad()
  272. {
  273. if (this.currentListType == DressUpListType.List4)
  274. {
  275. this.hideListParts2();
  276. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  277. }
  278. else if (this.currentListType == DressUpListType.List3)
  279. {
  280. if (_currentList2 != null)
  281. {
  282. this.showListType2(_currentList2);
  283. }
  284. else
  285. {
  286. this.showListType1();
  287. }
  288. this.hideListParts();
  289. }
  290. else if (this.currentListType == DressUpListType.List2)
  291. {
  292. this.showListType1();
  293. this.hideListType2();
  294. }
  295. }
  296. private void OnClickBtnDelete()
  297. {
  298. MyDressUpHelper.dressUpObj.TakeOffAll();
  299. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  300. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  301. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  302. UpdateListPartsSelected();
  303. UpdateListSuitPartsSelected();
  304. }
  305. private void OnClickBtnNext()
  306. {
  307. if (!MyDressUpHelper.CheckPutOnFinish())
  308. {
  309. AlertUI.Show("换好衣服才能进行下一步哦~").SetRightButton(true, "好的");
  310. }
  311. else
  312. {
  313. Timers.inst.StartCoroutine(ScreenShotTex());
  314. }
  315. }
  316. private IEnumerator ScreenShotTex()
  317. {
  318. _dressUpData.TakeOffAll();
  319. _dressUpData.PutOnItemList(MyDressUpHelper.dressUpObj.itemList);
  320. Camera camera = _sceneObject.transform.Find("FightCamera").gameObject.GetComponent<Camera>();
  321. ArenaDataManager.Instance.TextureDic[_dataManager.SelectThemeIndex] = FightDataManager.Instance.GetPrintscreenNTexture(camera);
  322. yield return new WaitForEndOfFrame();
  323. DressUpFinish();
  324. }
  325. private void DressUpFinish()
  326. {
  327. if (CardDataManager.GetCardListByRarity(0).Count > 0)
  328. {
  329. ViewManager.Show<StoryCardChoose>(InstanceZonesDataManager.currentScoreType);
  330. }
  331. else
  332. {
  333. ArenaSproxy.ReqChangeArenaDressup(_dataManager.SelectThemeIndex, 0, MyDressUpHelper.dressUpObj.itemList).Coroutine();
  334. }
  335. }
  336. private void OnClickBtnRecommend()
  337. {
  338. if (this.currentListType == DressUpListType.List4)
  339. {
  340. this.hideListParts2();
  341. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  342. }
  343. MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(_currentSuitId);
  344. MyDressUpHelper.PutOnRecommendItems2();
  345. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  346. UpdateListPartsSelected();
  347. UpdateListSuitPartsSelected();
  348. }
  349. private void InitLists()
  350. {
  351. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  352. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  353. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  354. listType1X = _ui.m_comListType1.target.x;
  355. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  356. //一级菜单
  357. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  358. }
  359. private void showListType1()
  360. {
  361. _currentList2 = null;
  362. currentListType = DressUpListType.List1;
  363. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  364. GTween.To(_ui.target.width, listType1X, 0.5f)
  365. .SetTarget(_ui.m_comListType1.target)
  366. .OnUpdate((GTweener t) =>
  367. {
  368. _ui.m_comListType1.target.x = t.value.x;
  369. });
  370. }
  371. private void hideListType1()
  372. {
  373. GTween.To(listType1X, _ui.target.width, 0.5f)
  374. .SetTarget(_ui.m_comListType1.target)
  375. .OnUpdate((GTweener t) =>
  376. {
  377. _ui.m_comListType1.target.x = t.value.x;
  378. });
  379. }
  380. private void showListType2(int[] menuStrArr = null)
  381. {
  382. currentListType = DressUpListType.List2;
  383. if (menuStrArr != null && menuStrArr.Length > 0)
  384. {
  385. int len = menuStrArr.Length;
  386. _currentList2 = menuStrArr.Clone() as int[];
  387. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  388. _ui.m_comListType2.m_listType.numItems = len;
  389. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  390. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  391. if (_ui.m_comListType2.m_listType.height > maxHeight)
  392. {
  393. _ui.m_comListType2.m_listType.height = maxHeight;
  394. }
  395. }
  396. GTween.To(_ui.target.width, listType1X, 0.5f)
  397. .SetTarget(_ui.m_comListType2.target)
  398. .OnUpdate((GTweener t) =>
  399. {
  400. _ui.m_comListType2.target.x = t.value.x;
  401. });
  402. }
  403. private void hideListType2()
  404. {
  405. GTween.To(listType1X, _ui.target.width, 0.5f)
  406. .SetTarget(_ui.m_comListType2.target)
  407. .OnUpdate((GTweener t) =>
  408. {
  409. _ui.m_comListType2.target.x = t.value.x;
  410. });
  411. }
  412. private bool showListParts(int type, bool selectItem = false)
  413. {
  414. _currentMenuType = type;
  415. UpdatePartsListSort();
  416. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  417. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  418. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  419. if (_ui.m_partsList.m_list.height > maxHeight)
  420. {
  421. _ui.m_partsList.m_list.height = maxHeight;
  422. }
  423. if (selectItem)
  424. {
  425. int itemId = MyDressUpHelper.dressUpObj.GetItemIdBuyType(_currentMenuType);
  426. if (itemId > 0)
  427. {
  428. int index = _currentList3.IndexOf(itemId);
  429. if (index >= 0 && index < _ui.m_partsList.m_list.numItems)
  430. {
  431. _ui.m_partsList.m_list.ScrollToView(index);
  432. }
  433. }
  434. }
  435. currentListType = DressUpListType.List3;
  436. GTween.To(_ui.target.width, partsListX, 0.5f)
  437. .SetTarget(_ui.m_partsList)
  438. .OnUpdate((GTweener t) =>
  439. {
  440. _ui.m_partsList.target.x = t.value.x;
  441. });
  442. UpdateListPartsSelected();
  443. return true;
  444. }
  445. private void OnComboBoxRarityChanged()
  446. {
  447. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  448. this.UpdatePartsListSort();
  449. }
  450. private void UpdatePartsListSort()
  451. {
  452. if (_currentMenuType == 0) return;
  453. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  454. {
  455. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  456. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  457. {
  458. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  459. }
  460. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  461. {
  462. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  463. }
  464. else
  465. {
  466. _currentList3.Reverse();
  467. }
  468. }
  469. else
  470. {
  471. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  472. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  473. {
  474. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3);
  475. }
  476. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  477. {
  478. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3);
  479. }
  480. else
  481. {
  482. _currentList3.Reverse();
  483. }
  484. }
  485. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  486. {
  487. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  488. }
  489. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  490. {
  491. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  492. }
  493. _ui.m_partsList.m_list.RemoveChildrenToPool();
  494. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  495. }
  496. private void UpdateSuitPartsListSort()
  497. {
  498. if (_currentMenuType == 0) return;
  499. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId, true));
  500. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  501. {
  502. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  503. }
  504. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  505. {
  506. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  507. }
  508. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  509. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  510. }
  511. private void hideListParts()
  512. {
  513. GTween.To(partsListX, _ui.target.width, 0.5f)
  514. .SetTarget(_ui.m_partsList)
  515. .OnUpdate((GTweener t) =>
  516. {
  517. _ui.m_partsList.target.x = t.value.x;
  518. });
  519. }
  520. private void showListParts2(int suitId)
  521. {
  522. _currentSuitId = suitId;
  523. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  524. this.UpdateSuitPartsListSort();
  525. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  526. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  527. if (_ui.m_partsList2.m_list.height > maxHeight)
  528. {
  529. _ui.m_partsList2.m_list.height = maxHeight;
  530. }
  531. currentListType = DressUpListType.List4;
  532. GTween.To(_ui.target.width, partsListX, 0.5f)
  533. .SetTarget(_ui.m_partsList2)
  534. .OnUpdate((GTweener t) =>
  535. {
  536. _ui.m_partsList2.target.x = t.value.x;
  537. });
  538. }
  539. private void hideListParts2()
  540. {
  541. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  542. GTween.To(partsListX, _ui.target.width, 0.5f)
  543. .SetTarget(_ui.m_partsList2)
  544. .OnUpdate((GTweener t) =>
  545. {
  546. _ui.m_partsList2.target.x = t.value.x;
  547. });
  548. }
  549. private void ListType1Item(int index, GObject item)
  550. {
  551. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  552. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  553. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  554. typeItem.m_txtname.text = item1.name;
  555. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  556. typeItem.target.data = item1.id;
  557. typeItem.m_imgNeed.visible = false;
  558. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  559. UI.DressUp.UI_TypeItem.ProxyEnd();
  560. }
  561. private void ListType2Item(int index, GObject item)
  562. {
  563. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  564. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  565. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  566. typeItem.m_txtname.text = item2.name;
  567. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  568. typeItem.target.data = item2.id;
  569. // var subType = ItemUtilCS.GetItemSubType(_fightCfg.needItemId);
  570. typeItem.m_imgNeed.visible = false;
  571. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  572. UI.DressUp.UI_TypeItem.ProxyEnd();
  573. }
  574. private void ListPartsItem(int index, GObject item)
  575. {
  576. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  577. int id = (int)_currentList3[index];
  578. string iconRes = "";
  579. string partName = "";
  580. string ext = "png";
  581. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  582. {
  583. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  584. iconRes = suitCfg.res;
  585. partName = suitCfg.name;
  586. listItem.m_iconSelected.visible = false;
  587. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  588. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  589. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  590. listItem.m_imgNew.visible = false;
  591. }
  592. else
  593. {
  594. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  595. iconRes = itemCfg.res;
  596. partName = itemCfg.name;
  597. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  598. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _roleData.tags);
  599. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  600. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  601. listItem.m_imgNew.visible = isNew;
  602. if (isNew)
  603. {
  604. ItemProxy.ReqSetItemRead(id).Coroutine();
  605. }
  606. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  607. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  608. }
  609. if (listItem.target.data == null)
  610. {
  611. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  612. longPressGesture.once = true;
  613. longPressGesture.onAction.Add(OnLongPress);
  614. _listLongPress.Add(longPressGesture);
  615. }
  616. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  617. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + InstanceZonesDataManager.currentScoreType;
  618. listItem.m_txtTitle.text = partName;
  619. listItem.target.data = id;
  620. listItem.m_imgNeed.visible = false;
  621. UI_PartsListItem.ProxyEnd();
  622. }
  623. private void ListParts2Item(int index, GObject item)
  624. {
  625. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  626. int id = (int)_currentList4[index];
  627. string iconRes = "";
  628. string partName = "";
  629. string ext = "png";
  630. if (listItem.target.data == null)
  631. {
  632. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  633. longPressGesture.once = true;
  634. longPressGesture.onAction.Add(OnLongPress);
  635. _listLongPress.Add(longPressGesture);
  636. }
  637. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  638. iconRes = itemCfg.res;
  639. partName = itemCfg.name;
  640. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  641. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  642. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  643. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  644. listItem.m_ScoreType.visible = true;
  645. // int mainScore;
  646. // int mainValuel;
  647. // ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  648. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + InstanceZonesDataManager.currentScoreType);
  649. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _dataManager.DressupList[_dataManager.SelectThemeIndex].tags);
  650. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  651. listItem.m_txtTitle.text = partName;
  652. listItem.target.data = id;
  653. // listItem.m_txtScore.visible = false;
  654. //listItem.m_ScoreType.visible = true;
  655. listItem.m_imgNeed.visible = false;
  656. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  657. listItem.m_imgNew.visible = isNew;
  658. if (isNew)
  659. {
  660. ItemProxy.ReqSetItemRead(id).Coroutine();
  661. }
  662. UI_PartsListItem.ProxyEnd();
  663. }
  664. private void UpdateListPartsSelected()
  665. {
  666. int count = _ui.m_partsList.m_list.numChildren;
  667. int suitId = MyDressUpHelper.dressUpObj.suitId;
  668. for (int i = 0; i < count; i++)
  669. {
  670. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  671. int id = (int)listItem.target.data;
  672. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  673. {
  674. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  675. }
  676. else
  677. {
  678. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  679. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  680. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  681. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  682. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  683. }
  684. UI_PartsListItem.ProxyEnd();
  685. }
  686. }
  687. private void UpdateListSuitPartsSelected()
  688. {
  689. int count = _ui.m_partsList2.m_list.numChildren;
  690. int suitId = MyDressUpHelper.dressUpObj.suitId;
  691. for (int i = 0; i < count; i++)
  692. {
  693. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  694. int id = (int)listItem.target.data;
  695. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  696. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  697. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  698. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  699. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  700. UI_PartsListItem.ProxyEnd();
  701. }
  702. }
  703. private void OnClickBtnSearch()
  704. {
  705. ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
  706. }
  707. private void SendLog()
  708. {
  709. }
  710. private void CheckGuide(object param)
  711. {
  712. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0
  713. || GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0
  714. || GuideDataManager.IsGuideFinish(ConstGuideId.AUTOPLAY_FIGHT) <= 0)
  715. {
  716. UpdateToCheckGuide(null);
  717. }
  718. else
  719. {
  720. Timers.inst.Remove(CheckGuide);
  721. }
  722. }
  723. protected override void UpdateToCheckGuide(object param)
  724. {
  725. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  726. }
  727. protected override void TryCompleteGuide()
  728. {
  729. base.TryCompleteGuide();
  730. }
  731. }
  732. }