ArenaDressUpFightView.cs 34 KB

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