ArenaDressUpFightView.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  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 async void DressUpFinish()
  326. {
  327. if (CardDataManager.GetCardListByRarity(0).Count > 0)
  328. {
  329. ViewManager.Show<StoryCardChoose>(InstanceZonesDataManager.currentScoreType);
  330. }
  331. else
  332. {
  333. bool result = await ArenaSproxy.ReqChangeArenaDressup(_dataManager.SelectThemeIndex, 0, MyDressUpHelper.dressUpObj.itemList);
  334. if (result)
  335. {
  336. PromptController.Instance.ShowFloatTextPrompt("保存成功");
  337. }
  338. }
  339. }
  340. private void OnClickBtnRecommend()
  341. {
  342. if (this.currentListType == DressUpListType.List4)
  343. {
  344. this.hideListParts2();
  345. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  346. }
  347. MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(_currentSuitId);
  348. MyDressUpHelper.PutOnRecommendItems2();
  349. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  350. UpdateListPartsSelected();
  351. UpdateListSuitPartsSelected();
  352. }
  353. private void InitLists()
  354. {
  355. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  356. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  357. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  358. listType1X = _ui.m_comListType1.target.x;
  359. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  360. //一级菜单
  361. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  362. }
  363. private void showListType1()
  364. {
  365. _currentList2 = null;
  366. currentListType = DressUpListType.List1;
  367. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  368. GTween.To(_ui.target.width, listType1X, 0.5f)
  369. .SetTarget(_ui.m_comListType1.target)
  370. .OnUpdate((GTweener t) =>
  371. {
  372. _ui.m_comListType1.target.x = t.value.x;
  373. });
  374. }
  375. private void hideListType1()
  376. {
  377. GTween.To(listType1X, _ui.target.width, 0.5f)
  378. .SetTarget(_ui.m_comListType1.target)
  379. .OnUpdate((GTweener t) =>
  380. {
  381. _ui.m_comListType1.target.x = t.value.x;
  382. });
  383. }
  384. private void showListType2(int[] menuStrArr = null)
  385. {
  386. currentListType = DressUpListType.List2;
  387. if (menuStrArr != null && menuStrArr.Length > 0)
  388. {
  389. int len = menuStrArr.Length;
  390. _currentList2 = menuStrArr.Clone() as int[];
  391. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  392. _ui.m_comListType2.m_listType.numItems = len;
  393. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  394. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  395. if (_ui.m_comListType2.m_listType.height > maxHeight)
  396. {
  397. _ui.m_comListType2.m_listType.height = maxHeight;
  398. }
  399. }
  400. GTween.To(_ui.target.width, listType1X, 0.5f)
  401. .SetTarget(_ui.m_comListType2.target)
  402. .OnUpdate((GTweener t) =>
  403. {
  404. _ui.m_comListType2.target.x = t.value.x;
  405. });
  406. }
  407. private void hideListType2()
  408. {
  409. GTween.To(listType1X, _ui.target.width, 0.5f)
  410. .SetTarget(_ui.m_comListType2.target)
  411. .OnUpdate((GTweener t) =>
  412. {
  413. _ui.m_comListType2.target.x = t.value.x;
  414. });
  415. }
  416. private bool showListParts(int type, bool selectItem = false)
  417. {
  418. _currentMenuType = type;
  419. UpdatePartsListSort();
  420. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  421. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  422. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  423. if (_ui.m_partsList.m_list.height > maxHeight)
  424. {
  425. _ui.m_partsList.m_list.height = maxHeight;
  426. }
  427. if (selectItem)
  428. {
  429. int itemId = MyDressUpHelper.dressUpObj.GetItemIdBuyType(_currentMenuType);
  430. if (itemId > 0)
  431. {
  432. int index = _currentList3.IndexOf(itemId);
  433. if (index >= 0 && index < _ui.m_partsList.m_list.numItems)
  434. {
  435. _ui.m_partsList.m_list.ScrollToView(index);
  436. }
  437. }
  438. }
  439. currentListType = DressUpListType.List3;
  440. GTween.To(_ui.target.width, partsListX, 0.5f)
  441. .SetTarget(_ui.m_partsList)
  442. .OnUpdate((GTweener t) =>
  443. {
  444. _ui.m_partsList.target.x = t.value.x;
  445. });
  446. UpdateListPartsSelected();
  447. return true;
  448. }
  449. private void OnComboBoxRarityChanged()
  450. {
  451. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  452. this.UpdatePartsListSort();
  453. }
  454. private void UpdatePartsListSort()
  455. {
  456. if (_currentMenuType == 0) return;
  457. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  458. {
  459. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  460. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  461. {
  462. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  463. }
  464. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  465. {
  466. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  467. }
  468. else
  469. {
  470. _currentList3.Reverse();
  471. }
  472. }
  473. else
  474. {
  475. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  476. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  477. {
  478. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3);
  479. }
  480. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  481. {
  482. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3);
  483. }
  484. else
  485. {
  486. _currentList3.Reverse();
  487. }
  488. }
  489. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  490. {
  491. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  492. }
  493. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  494. {
  495. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  496. }
  497. _ui.m_partsList.m_list.RemoveChildrenToPool();
  498. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  499. }
  500. private void UpdateSuitPartsListSort()
  501. {
  502. if (_currentMenuType == 0) return;
  503. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId, true));
  504. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  505. {
  506. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  507. }
  508. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  509. {
  510. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  511. }
  512. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  513. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  514. }
  515. private void hideListParts()
  516. {
  517. GTween.To(partsListX, _ui.target.width, 0.5f)
  518. .SetTarget(_ui.m_partsList)
  519. .OnUpdate((GTweener t) =>
  520. {
  521. _ui.m_partsList.target.x = t.value.x;
  522. });
  523. }
  524. private void showListParts2(int suitId)
  525. {
  526. _currentSuitId = suitId;
  527. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  528. this.UpdateSuitPartsListSort();
  529. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  530. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  531. if (_ui.m_partsList2.m_list.height > maxHeight)
  532. {
  533. _ui.m_partsList2.m_list.height = maxHeight;
  534. }
  535. currentListType = DressUpListType.List4;
  536. GTween.To(_ui.target.width, partsListX, 0.5f)
  537. .SetTarget(_ui.m_partsList2)
  538. .OnUpdate((GTweener t) =>
  539. {
  540. _ui.m_partsList2.target.x = t.value.x;
  541. });
  542. }
  543. private void hideListParts2()
  544. {
  545. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  546. GTween.To(partsListX, _ui.target.width, 0.5f)
  547. .SetTarget(_ui.m_partsList2)
  548. .OnUpdate((GTweener t) =>
  549. {
  550. _ui.m_partsList2.target.x = t.value.x;
  551. });
  552. }
  553. private void ListType1Item(int index, GObject item)
  554. {
  555. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  556. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  557. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  558. typeItem.m_txtname.text = item1.name;
  559. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  560. typeItem.target.data = item1.id;
  561. typeItem.m_imgNeed.visible = false;
  562. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  563. UI.DressUp.UI_TypeItem.ProxyEnd();
  564. }
  565. private void ListType2Item(int index, GObject item)
  566. {
  567. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  568. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  569. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  570. typeItem.m_txtname.text = item2.name;
  571. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  572. typeItem.target.data = item2.id;
  573. // var subType = ItemUtilCS.GetItemSubType(_fightCfg.needItemId);
  574. typeItem.m_imgNeed.visible = false;
  575. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  576. UI.DressUp.UI_TypeItem.ProxyEnd();
  577. }
  578. private void ListPartsItem(int index, GObject item)
  579. {
  580. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  581. int id = (int)_currentList3[index];
  582. string iconRes = "";
  583. string partName = "";
  584. string ext = "png";
  585. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  586. {
  587. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  588. iconRes = suitCfg.res;
  589. partName = suitCfg.name;
  590. listItem.m_iconSelected.visible = false;
  591. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  592. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  593. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  594. listItem.m_imgNew.visible = false;
  595. }
  596. else
  597. {
  598. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  599. iconRes = itemCfg.res;
  600. partName = itemCfg.name;
  601. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  602. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _roleData.tags);
  603. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  604. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  605. listItem.m_imgNew.visible = isNew;
  606. if (isNew)
  607. {
  608. ItemProxy.ReqSetItemRead(id).Coroutine();
  609. }
  610. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  611. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  612. }
  613. if (listItem.target.data == null)
  614. {
  615. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  616. longPressGesture.once = true;
  617. longPressGesture.onAction.Add(OnLongPress);
  618. _listLongPress.Add(longPressGesture);
  619. }
  620. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  621. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + InstanceZonesDataManager.currentScoreType;
  622. listItem.m_txtTitle.text = partName;
  623. listItem.target.data = id;
  624. listItem.m_imgNeed.visible = false;
  625. UI_PartsListItem.ProxyEnd();
  626. }
  627. private void ListParts2Item(int index, GObject item)
  628. {
  629. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  630. int id = (int)_currentList4[index];
  631. string iconRes = "";
  632. string partName = "";
  633. string ext = "png";
  634. if (listItem.target.data == null)
  635. {
  636. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  637. longPressGesture.once = true;
  638. longPressGesture.onAction.Add(OnLongPress);
  639. _listLongPress.Add(longPressGesture);
  640. }
  641. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  642. iconRes = itemCfg.res;
  643. partName = itemCfg.name;
  644. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  645. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  646. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  647. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  648. listItem.m_ScoreType.visible = true;
  649. // int mainScore;
  650. // int mainValuel;
  651. // ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  652. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + InstanceZonesDataManager.currentScoreType);
  653. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _dataManager.DressupList[_dataManager.SelectThemeIndex].tags);
  654. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  655. listItem.m_txtTitle.text = partName;
  656. listItem.target.data = id;
  657. // listItem.m_txtScore.visible = false;
  658. //listItem.m_ScoreType.visible = true;
  659. listItem.m_imgNeed.visible = false;
  660. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  661. listItem.m_imgNew.visible = isNew;
  662. if (isNew)
  663. {
  664. ItemProxy.ReqSetItemRead(id).Coroutine();
  665. }
  666. UI_PartsListItem.ProxyEnd();
  667. }
  668. private void UpdateListPartsSelected()
  669. {
  670. int count = _ui.m_partsList.m_list.numChildren;
  671. int suitId = MyDressUpHelper.dressUpObj.suitId;
  672. for (int i = 0; i < count; i++)
  673. {
  674. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  675. int id = (int)listItem.target.data;
  676. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  677. {
  678. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  679. }
  680. else
  681. {
  682. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  683. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  684. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  685. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  686. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  687. }
  688. UI_PartsListItem.ProxyEnd();
  689. }
  690. }
  691. private void UpdateListSuitPartsSelected()
  692. {
  693. int count = _ui.m_partsList2.m_list.numChildren;
  694. int suitId = MyDressUpHelper.dressUpObj.suitId;
  695. for (int i = 0; i < count; i++)
  696. {
  697. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  698. int id = (int)listItem.target.data;
  699. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  700. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  701. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  702. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  703. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  704. UI_PartsListItem.ProxyEnd();
  705. }
  706. }
  707. private void OnClickBtnSearch()
  708. {
  709. ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
  710. }
  711. private void SendLog()
  712. {
  713. }
  714. private void CheckGuide(object param)
  715. {
  716. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0
  717. || GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0
  718. || GuideDataManager.IsGuideFinish(ConstGuideId.AUTOPLAY_FIGHT) <= 0)
  719. {
  720. UpdateToCheckGuide(null);
  721. }
  722. else
  723. {
  724. Timers.inst.Remove(CheckGuide);
  725. }
  726. }
  727. protected override void UpdateToCheckGuide(object param)
  728. {
  729. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  730. }
  731. protected override void TryCompleteGuide()
  732. {
  733. base.TryCompleteGuide();
  734. }
  735. }
  736. }