ArenaDressUpFightView.cs 34 KB

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