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