ArenaDressUpFightView.cs 34 KB

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