ArenaDressUpFightView.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  1. using UI.DressUp;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. using cfg.GfgCfg;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class ArenaDressUpFightView : BaseWindow
  10. {
  11. private UI_ArenaDressUpFightUI _ui;
  12. // private DressUpObj _dressUpData = new DressUpObj();
  13. private ArenaDataManager _dataManager;
  14. private FightData _roleData;
  15. public List<int> _itemList; //记录打开界面时的穿戴数据(保存后会更新)
  16. private float listType1X = 0;
  17. private float partsListX = 0;
  18. private float partsListScrollingPosY = 0;
  19. private DressUpListType currentListType;
  20. private List<int> _currentList2;
  21. private GameObject _sceneObject;
  22. private List<int> _currentList3 = new List<int>();
  23. private List<int> _currentList4 = new List<int>();
  24. private int _currentMenuType;
  25. private int _currentSuitId;
  26. //暂存cardid
  27. private int cardId;
  28. // private StoryLevelCfg _levelCfg;
  29. // private StoryFightCfg _fightCfg;
  30. private const int SORT_BY_HIGH_SCORE = 0;
  31. private const int SORT_BY_LOW_SCORE = 1;
  32. private int _scoreIndex = SORT_BY_HIGH_SCORE;
  33. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  34. public override void Dispose()
  35. {
  36. if (_sceneObject != null)
  37. {
  38. PrefabManager.Instance.Restore(_sceneObject);
  39. _sceneObject = null;
  40. }
  41. for (int i = 0; i < _listLongPress.Count; i++)
  42. {
  43. _listLongPress[i].Dispose();
  44. }
  45. // _dressUpData.Dispose();
  46. if (_ui != null)
  47. {
  48. _ui.Dispose();
  49. _ui = null;
  50. }
  51. base.Dispose();
  52. }
  53. protected override void Init()
  54. {
  55. base.Init();
  56. packageName = UI_ArenaDressUpFightUI.PACKAGE_NAME;
  57. _ui = UI_ArenaDressUpFightUI.Create();
  58. viewCom = _ui.target;
  59. isfullScreen = true;
  60. isReturnView = true;
  61. }
  62. protected override void OnInit()
  63. {
  64. base.OnInit();
  65. _ui.m_btnLastStep.visible = true;
  66. _ui.m_btnNextStep.visible = true;
  67. _ui.m_btnSearch.visible = true;
  68. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  69. _ui.m_partsListSearch.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  70. InitLists();
  71. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  72. _ui.m_partsListSearch.m_comboBoxRarity.onChanged.Add(OnSearchComboBoxRarityChanged);
  73. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  74. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  75. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  76. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  77. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  78. _ui.m_partsListSearch.m_list.onClickItem.Add(OnClickSearchPartsListItem);
  79. _ui.m_touchPad.onClick.Add(OnTouchPad);
  80. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  81. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  82. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  83. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  84. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  85. // _ui.m_comValueInfo.m_btnFightScoreRule.onClick.Add(OnBtnFightScoreRule);
  86. _ui.m_comValueInfo.GetChild("btnFightScoreRule").onClick.Add(OnBtnFightScoreRule);
  87. _ui.m_grhCloseComFightScore.onClick.Add(OnCloseComFightScore);
  88. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  89. _ui.m_partsList2.m_imgTop.visible = true;
  90. _ui.m_partsList.m_imgTop.visible = false;
  91. }
  92. protected override void AddEventListener()
  93. {
  94. base.AddEventListener();
  95. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  96. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  97. EventAgent.AddEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  98. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  99. }
  100. protected override void RemoveEventListener()
  101. {
  102. base.RemoveEventListener();
  103. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  104. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  105. EventAgent.RemoveEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  106. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  107. }
  108. protected override void OnShown()
  109. {
  110. base.OnShown();
  111. _dataManager = ArenaDataManager.Instance;
  112. _roleData = _dataManager.DressupList[_dataManager.SelectThemeIndex];
  113. _itemList = new List<int>(_roleData.itemList);
  114. InstanceZonesDataManager.currentScoreType = _dataManager.ThemeList[_dataManager.SelectThemeIndex];
  115. InstanceZonesDataManager.currentFightTags = _dataManager.DressupList[_dataManager.SelectThemeIndex].tags;
  116. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  117. _ui.m_grhCloseComFightScore.visible = false;
  118. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  119. _ui.m_comListType1.m_listType.numItems = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList.Count - 3;
  120. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  121. if (_ui.m_comListType1.m_listType.height > maxHeight)
  122. {
  123. _ui.m_comListType1.m_listType.height = maxHeight;
  124. }
  125. _ui.m_comListType1.target.x = _ui.target.width;
  126. _ui.m_comListType2.target.x = _ui.target.width;
  127. _ui.m_partsList.target.x = _ui.target.width;
  128. _ui.m_partsList2.target.x = _ui.target.width;
  129. _ui.m_partsListSearch.target.x = _ui.target.width;
  130. this.showListType1();
  131. void SetupAfterInstantiate()
  132. {
  133. MyDressUpHelper.dressUpObj.PutOnItemList(_roleData.itemList);
  134. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  135. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  136. _ui.m_c1.selectedIndex = 0;
  137. UpdateStepBtn(true);
  138. UpdateValueInfo();
  139. SendLog();
  140. }
  141. if (_sceneObject == null)
  142. {
  143. PrefabManager.Instance.InstantiateAsync(
  144. ResPathUtil.GetPrefabPath("SceneArenaDressUpFight"),
  145. (go) =>
  146. {
  147. if (go != null)
  148. {
  149. _sceneObject = go;
  150. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, true);
  151. MyDressUpHelper.dressUpObj.AddOrRemove(180001, false);
  152. SetupAfterInstantiate();
  153. }
  154. else
  155. {
  156. Debug.LogError("场景对象异步加载失败: SceneArenaDressUpFight");
  157. }
  158. });
  159. }
  160. else
  161. {
  162. SetupAfterInstantiate();
  163. }
  164. cardId = _roleData.cardId;
  165. }
  166. protected override void OnHide()
  167. {
  168. base.OnHide();
  169. if (_sceneObject != null)
  170. {
  171. PrefabManager.Instance.Restore(_sceneObject);
  172. _sceneObject = null;
  173. }
  174. DressUpMenuItemDataManager.Clear();
  175. MyDressUpHelper.ResetMemory();
  176. _ui.m_grhCloseComFightScore.visible = false;
  177. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  178. }
  179. private void OnClickBtnBack()
  180. {
  181. bool isSave = _itemList.Count == MyDressUpHelper.dressUpObj.itemList.Count;
  182. if (isSave)
  183. {
  184. for (int i = 0; i < _itemList.Count; i++)
  185. {
  186. int itemId = MyDressUpHelper.dressUpObj.itemList[i];
  187. if (_itemList.IndexOf(itemId) < 0)
  188. {
  189. isSave = false;
  190. break;
  191. }
  192. }
  193. }
  194. if (!isSave)
  195. {
  196. AlertUI.Show("当前穿搭尚未保存,是否确定退出?")
  197. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  198. {
  199. _roleData.cardId = cardId;
  200. GoBackToView();
  201. });
  202. }
  203. else
  204. {
  205. GoBackToView();
  206. }
  207. }
  208. private void GoBackToView()
  209. {
  210. _roleData.itemList = _itemList;
  211. FightDataManager.Instance.SetItemScoreList(_roleData);
  212. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  213. //ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  214. //ViewManager.Show<ArenaDressInfoView>(new object[] { FightRoleType.MINE, 0, ArenaDataManager.Instance.DressupList, "" });
  215. this.Hide();
  216. }
  217. private void OnBtnFightScoreRule()
  218. {
  219. _ui.m_grhCloseComFightScore.visible = true;
  220. }
  221. private void OnCloseComFightScore()
  222. {
  223. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  224. _ui.m_grhCloseComFightScore.visible = false;
  225. }
  226. private void OnClickBtnHome()
  227. {
  228. AlertUI.Show("是否返回?")
  229. .SetLeftButton(true, "否")
  230. .SetRightButton(true, "是", (object data) => { GameController.GoBackToMainView(); });
  231. }
  232. private void UpdateValueInfo()
  233. {
  234. _roleData.itemList = MyDressUpHelper.dressUpObj.itemList;
  235. FightDataManager.Instance.SetItemScoreList(_roleData);
  236. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  237. ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo, _dataManager.SelectThemeIndex,
  238. _dataManager.DressupList);
  239. }
  240. private void OnClickListType1Item(EventContext context)
  241. {
  242. // GuideController.HideGuide();
  243. GObject typeItem = context.data as GObject;
  244. int order = (int)typeItem.data;
  245. DressUpMenuItemCfg1 item1 = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList[order - 1];
  246. if (item1.SubMenus.Count > 0)
  247. {
  248. this.showListType2(item1.SubMenus);
  249. }
  250. else
  251. {
  252. if (this.showListParts(item1.Type) == false)
  253. {
  254. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  255. return;
  256. }
  257. this.showListParts(item1.Type);
  258. }
  259. this.hideListType1();
  260. UpdateListPartsSelected();
  261. }
  262. private void OnClickListType2Item(EventContext context)
  263. {
  264. GObject typeItem = context.data as GObject;
  265. int order = (int)typeItem.data;
  266. DressUpMenuItemCfg2 item2 = CommonDataManager.Tables.TblDressUpMenuItemCfg2.DataList[order - 1];
  267. if (this.showListParts(item2.Type) == false)
  268. {
  269. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  270. return;
  271. }
  272. this.hideListType2();
  273. }
  274. private void OnClickSearchPartsListItem(EventContext context)
  275. {
  276. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  277. {
  278. return;
  279. }
  280. GObject listItem = context.data as GObject;
  281. int id = (int)listItem.data;
  282. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  283. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  284. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  285. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >=
  286. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount;
  287. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  288. {
  289. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  290. return;
  291. }
  292. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  293. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  294. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  295. UpdateStepBtn(true);
  296. // UpdateSearchListPartsSelected();
  297. UpdateValueInfo();
  298. }
  299. private void OnClickPartsListItem(EventContext context)
  300. {
  301. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  302. {
  303. return;
  304. }
  305. GObject listItem = context.data as GObject;
  306. int id = (int)listItem.data;
  307. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  308. {
  309. partsListScrollingPosY = _ui.m_partsList.m_list.scrollPane.scrollingPosY;
  310. this.showListParts2(id);
  311. this.hideListParts();
  312. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  313. }
  314. else
  315. {
  316. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  317. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  318. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  319. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >=
  320. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount;
  321. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  322. {
  323. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  324. return;
  325. }
  326. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  327. }
  328. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  329. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  330. UpdateStepBtn(true);
  331. // UpdateListPartsSelected();
  332. // UpdateListSuitPartsSelected();
  333. UpdateValueInfo();
  334. }
  335. private void OnClickSuitPartsListItem(EventContext context)
  336. {
  337. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  338. {
  339. return;
  340. }
  341. GObject listItem = (GObject)context.data as GObject;
  342. int id = (int)listItem.data;
  343. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  344. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  345. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  346. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >=
  347. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount;
  348. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  349. {
  350. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  351. return;
  352. }
  353. if (!DressUpMenuItemDataManager.CheckHasItem(id))
  354. {
  355. PromptController.Instance.ShowFloatTextPrompt("还未获得这件装扮");
  356. return;
  357. }
  358. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  359. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  360. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  361. UpdateStepBtn(true);
  362. // UpdateListSuitPartsSelected();
  363. UpdateValueInfo();
  364. }
  365. private void UpdateStepBtn(bool isAdd, int suitId = 0)
  366. {
  367. if (isAdd)
  368. {
  369. MyDressUpHelper.AddMemoryDressup();
  370. }
  371. _ui.m_btnLastStep.enabled = MyDressUpHelper.stepIndex > 0;
  372. _ui.m_btnNextStep.enabled = MyDressUpHelper.stepIndex < MyDressUpHelper.dressMemory.Count - 1;
  373. UpdateListPartsSelected();
  374. UpdateListSuitPartsSelected();
  375. UpdateSearchListPartsSelected();
  376. }
  377. private void OnLongPress(EventContext context)
  378. {
  379. LongPressGesture gesture = (LongPressGesture)context.sender;
  380. int itemId = (int)gesture.host.data;
  381. GoodsItemTipsController.ShowItemTips(itemId);
  382. }
  383. private void OnTouchPad()
  384. {
  385. if (this.currentListType == DressUpListType.List4)
  386. {
  387. this.hideListParts2();
  388. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  389. }
  390. else if (this.currentListType == DressUpListType.List3)
  391. {
  392. if (_currentList2 != null)
  393. {
  394. this.showListType2(_currentList2);
  395. }
  396. else
  397. {
  398. this.showListType1();
  399. }
  400. this.hideListParts();
  401. }
  402. else if (this.currentListType == DressUpListType.List2)
  403. {
  404. this.showListType1();
  405. this.hideListType2();
  406. }
  407. else if (this.currentListType == DressUpListType.List5)
  408. {
  409. this.showListType1();
  410. this.hideSearchListType();
  411. }
  412. }
  413. private void OnClickBtnDelete()
  414. {
  415. MyDressUpHelper.dressUpObj.TakeOffAll();
  416. _roleData.cardId = 0;
  417. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  418. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  419. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(),
  420. CommonDataManager.Tables.TblGlobalCfg.DressLimitCount);
  421. UpdateStepBtn(true);
  422. // UpdateListPartsSelected();
  423. // UpdateListSuitPartsSelected();
  424. UpdateValueInfo();
  425. }
  426. private void OnClickBtnNext()
  427. {
  428. // if (!MyDressUpHelper.CheckPutOnFinish())
  429. // {
  430. // AlertUI.Show("换好衣服才能进行下一步哦~").SetRightButton(true, "好的");
  431. // }
  432. // else
  433. // {
  434. DressUpFinish();
  435. // }
  436. }
  437. private async void DressUpFinish()
  438. {
  439. if (CardDataManager.GetCardListByRoleType(0).Count > 0)
  440. {
  441. ViewManager.Show<StoryCardChoose>(InstanceZonesDataManager.currentScoreType);
  442. }
  443. else
  444. {
  445. List<long> fightScoreDatas =
  446. ArenaDataManager.Instance.GetFightScoreList(ArenaDataManager.Instance.DressupList);
  447. bool result = await ArenaSproxy.ReqChangeArenaDressup(_dataManager.SelectThemeIndex, 0,
  448. MyDressUpHelper.dressUpObj.itemList, fightScoreDatas);
  449. if (result)
  450. {
  451. _itemList = new List<int>(MyDressUpHelper.dressUpObj.itemList);
  452. PromptController.Instance.ShowFloatTextPrompt("保存成功");
  453. OnClickBtnBack();
  454. }
  455. }
  456. }
  457. // private void OnClickBtnRecommend()
  458. // {
  459. // if (this.currentListType == DressUpListType.List4)
  460. // {
  461. // this.hideListParts2();
  462. // this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  463. // }
  464. // MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(_currentSuitId);
  465. // MyDressUpHelper.PutOnRecommendItems2();
  466. // _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  467. // UpdateListPartsSelected();
  468. // UpdateListSuitPartsSelected();
  469. // }
  470. private void InitLists()
  471. {
  472. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  473. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  474. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  475. _ui.m_partsListSearch.m_list.itemRenderer = ListPartsItem;
  476. listType1X = _ui.m_comListType1.target.x;
  477. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  478. //一级菜单
  479. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  480. }
  481. private void showListType1()
  482. {
  483. _currentList2 = null;
  484. currentListType = DressUpListType.List1;
  485. _ui.m_comListType1.m_listType.numItems = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList.Count - 3;
  486. GTween.To(_ui.target.width, listType1X, 0.5f)
  487. .SetTarget(_ui.m_comListType1.target)
  488. .OnUpdate((GTweener t) => { _ui.m_comListType1.target.x = t.value.x; });
  489. }
  490. private void hideListType1()
  491. {
  492. GTween.To(listType1X, _ui.target.width, 0.5f)
  493. .SetTarget(_ui.m_comListType1.target)
  494. .OnUpdate((GTweener t) => { _ui.m_comListType1.target.x = t.value.x; });
  495. }
  496. private void showListType2(List<int> menuStrArr = null)
  497. {
  498. currentListType = DressUpListType.List2;
  499. if (menuStrArr != null && menuStrArr.Count > 0)
  500. {
  501. int len = menuStrArr.Count;
  502. _currentList2 = menuStrArr;
  503. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  504. _ui.m_comListType2.m_listType.numItems = len;
  505. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  506. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  507. if (_ui.m_comListType2.m_listType.height > maxHeight)
  508. {
  509. _ui.m_comListType2.m_listType.height = maxHeight;
  510. }
  511. }
  512. GTween.To(_ui.target.width, listType1X, 0.5f)
  513. .SetTarget(_ui.m_comListType2.target)
  514. .OnUpdate((GTweener t) => { _ui.m_comListType2.target.x = t.value.x; });
  515. }
  516. private void hideListType2()
  517. {
  518. GTween.To(listType1X, _ui.target.width, 0.5f)
  519. .SetTarget(_ui.m_comListType2.target)
  520. .OnUpdate((GTweener t) => { _ui.m_comListType2.target.x = t.value.x; });
  521. }
  522. private bool showListParts(int type, bool selectItem = false)
  523. {
  524. _currentMenuType = type;
  525. UpdatePartsListSort();
  526. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  527. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  528. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  529. if (_ui.m_partsList.m_list.height > maxHeight)
  530. {
  531. _ui.m_partsList.m_list.height = maxHeight;
  532. }
  533. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  534. {
  535. _ui.m_partsList.m_list.scrollPane.SetPosY(partsListScrollingPosY, false);
  536. partsListScrollingPosY = 0;
  537. }
  538. currentListType = DressUpListType.List3;
  539. GTween.To(_ui.target.width, partsListX, 0.5f)
  540. .SetTarget(_ui.m_partsList)
  541. .OnUpdate((GTweener t) => { _ui.m_partsList.target.x = t.value.x; });
  542. UpdateListPartsSelected();
  543. return true;
  544. }
  545. private void OnComboBoxRarityChanged()
  546. {
  547. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  548. this.UpdatePartsListSort();
  549. }
  550. private void OnSearchComboBoxRarityChanged()
  551. {
  552. _scoreIndex = _ui.m_partsListSearch.m_comboBoxRarity.selectedIndex;
  553. this.UpdateSearchList();
  554. }
  555. private void UpdatePartsListSort()
  556. {
  557. if (_currentMenuType == 0) return;
  558. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  559. {
  560. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  561. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  562. {
  563. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  564. }
  565. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  566. {
  567. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  568. }
  569. else
  570. {
  571. _currentList3.Reverse();
  572. }
  573. }
  574. else
  575. {
  576. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  577. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  578. {
  579. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3);
  580. }
  581. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  582. {
  583. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3);
  584. }
  585. else
  586. {
  587. _currentList3.Reverse();
  588. }
  589. }
  590. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  591. {
  592. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  593. }
  594. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  595. {
  596. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  597. }
  598. _ui.m_partsList.m_list.RemoveChildrenToPool();
  599. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  600. }
  601. private void UpdateSuitPartsListSort()
  602. {
  603. if (_currentMenuType == 0) return;
  604. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId, true));
  605. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  606. {
  607. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  608. }
  609. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  610. {
  611. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  612. }
  613. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  614. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  615. }
  616. private void hideListParts()
  617. {
  618. GTween.To(partsListX, _ui.target.width, 0.5f)
  619. .SetTarget(_ui.m_partsList)
  620. .OnUpdate((GTweener t) => { _ui.m_partsList.target.x = t.value.x; });
  621. }
  622. private void showListParts2(int suitId)
  623. {
  624. _currentSuitId = suitId;
  625. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  626. this.UpdateSuitPartsListSort();
  627. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  628. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y; // - DressUpView.BOTTOM_BLANK;
  629. if (_ui.m_partsList2.m_list.height > maxHeight)
  630. {
  631. _ui.m_partsList2.m_list.height = maxHeight;
  632. }
  633. currentListType = DressUpListType.List4;
  634. GTween.To(_ui.target.width, partsListX, 0.5f)
  635. .SetTarget(_ui.m_partsList2)
  636. .OnUpdate((GTweener t) => { _ui.m_partsList2.target.x = t.value.x; });
  637. }
  638. private void hideListParts2()
  639. {
  640. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  641. GTween.To(partsListX, _ui.target.width, 0.5f)
  642. .SetTarget(_ui.m_partsList2)
  643. .OnUpdate((GTweener t) => { _ui.m_partsList2.target.x = t.value.x; });
  644. }
  645. private void showSearchListType()
  646. {
  647. // _currentList2 = null;
  648. currentListType = DressUpListType.List5;
  649. GTween.To(_ui.target.width, partsListX, 0.5f)
  650. .SetTarget(_ui.m_partsListSearch.target)
  651. .OnUpdate((GTweener t) => { _ui.m_partsListSearch.target.x = t.value.x; });
  652. }
  653. private void hideSearchListType()
  654. {
  655. GTween.To(partsListX, _ui.target.width, 0.5f)
  656. .SetTarget(_ui.m_partsListSearch.target)
  657. .OnUpdate((GTweener t) => { _ui.m_partsListSearch.target.x = t.value.x; });
  658. }
  659. /*****************************************************************************************************/
  660. private void DressResetSerch()
  661. {
  662. if (currentListType == DressUpListType.List5)
  663. {
  664. OnTouchPad();
  665. }
  666. }
  667. private void UpdateSerch(EventContext context)
  668. {
  669. if (context.data.ToString() == ConstMessage.DRESS_SEARCH)
  670. {
  671. _currentList3 = DressUpMenuItemDataManager.DressSearch(false);
  672. }
  673. else if (context.data.ToString() == ConstMessage.DRESS_FILTER)
  674. {
  675. _currentList3 = DressUpMenuItemDataManager.DressFilter(false);
  676. }
  677. ViewManager.Hide<ModalStatusView>();
  678. UpdateSearchList();
  679. if (currentListType != DressUpListType.List5)
  680. {
  681. hideListParts();
  682. hideListParts2();
  683. hideListType1();
  684. hideListType2();
  685. showSearchListType();
  686. }
  687. _currentMenuType = 0;
  688. }
  689. private void UpdateSearchList()
  690. {
  691. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  692. {
  693. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3, true);
  694. }
  695. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  696. {
  697. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3, true);
  698. }
  699. _currentMenuType = 0;
  700. _ui.m_partsListSearch.m_list.numItems = _currentList3.Count;
  701. ;
  702. }
  703. private void ListType1Item(int index, GObject item)
  704. {
  705. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  706. DressUpMenuItemCfg1 item1 = CommonDataManager.Tables.TblDressUpMenuItemCfg1.DataList[index];
  707. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.Id;
  708. typeItem.m_txtname.text = item1.Name;
  709. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  710. typeItem.target.data = item1.Id;
  711. typeItem.m_imgNeed.visible = false;
  712. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.Id);
  713. UI.DressUp.UI_TypeItem.ProxyEnd();
  714. }
  715. private void ListType2Item(int index, GObject item)
  716. {
  717. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  718. DressUpMenuItemCfg2 item2 =
  719. CommonDataManager.Tables.TblDressUpMenuItemCfg2.DataList[_currentList2[index] - 1];
  720. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.Id;
  721. typeItem.m_txtname.text = item2.Name;
  722. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  723. typeItem.target.data = item2.Id;
  724. // var subType = ItemUtilCS.GetItemSubType(_fightCfg.needItemId);
  725. typeItem.m_imgNeed.visible = false;
  726. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.Id);
  727. UI.DressUp.UI_TypeItem.ProxyEnd();
  728. }
  729. private void ListPartsItem(int index, GObject item)
  730. {
  731. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  732. int id = (int)_currentList3[index];
  733. string iconRes = "";
  734. string partName = "";
  735. string ext = "png";
  736. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  737. {
  738. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(id);
  739. iconRes = suitCfg.Res;
  740. partName = suitCfg.Name;
  741. listItem.m_iconSelected.visible = false;
  742. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  743. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  744. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.Rarity;
  745. listItem.m_imgNew.visible = false;
  746. }
  747. else
  748. {
  749. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  750. iconRes = itemCfg.Res;
  751. partName = itemCfg.Name;
  752. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  753. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id,
  754. InstanceZonesDataManager.currentScoreType, _roleData.tags);
  755. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.Rarity;
  756. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  757. listItem.m_imgNew.visible = isNew;
  758. if (isNew)
  759. {
  760. ItemProxy.ReqSetItemRead(id).Coroutine();
  761. }
  762. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  763. ext = ItemUtil.GetItemResExt(itemCfg.ItemType, itemCfg.SubType, true);
  764. }
  765. if (listItem.target.data == null)
  766. {
  767. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  768. longPressGesture.trigger = GameConfig.LongPressGestureTrigger;
  769. longPressGesture.once = true;
  770. longPressGesture.onAction.Add(OnLongPress);
  771. _listLongPress.Add(longPressGesture);
  772. }
  773. listItem.m_btnAni.visible = false;
  774. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  775. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + InstanceZonesDataManager.currentScoreType;
  776. listItem.m_txtTitle.text = partName;
  777. listItem.target.data = id;
  778. listItem.m_imgNeed.visible = false;
  779. UI_PartsListItem.ProxyEnd();
  780. }
  781. private void ListParts2Item(int index, GObject item)
  782. {
  783. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  784. int id = (int)_currentList4[index];
  785. string iconRes = "";
  786. string partName = "";
  787. string ext = "png";
  788. if (listItem.target.data == null)
  789. {
  790. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  791. longPressGesture.trigger = GameConfig.LongPressGestureTrigger;
  792. longPressGesture.once = true;
  793. longPressGesture.onAction.Add(OnLongPress);
  794. _listLongPress.Add(longPressGesture);
  795. }
  796. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  797. iconRes = itemCfg.Res;
  798. partName = itemCfg.Name;
  799. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  800. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.Rarity;
  801. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  802. ext = ItemUtil.GetItemResExt(itemCfg.ItemType, itemCfg.SubType, true);
  803. listItem.m_ScoreType.visible = true;
  804. // int mainScore;
  805. // int mainValuel;
  806. // ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  807. listItem.m_ScoreType.url =
  808. ResPathUtil.GetCommonGameResPath("kp_sx_" + InstanceZonesDataManager.currentScoreType);
  809. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id,
  810. InstanceZonesDataManager.currentScoreType,
  811. _dataManager.DressupList[_dataManager.SelectThemeIndex].tags);
  812. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  813. listItem.m_txtTitle.text = partName;
  814. listItem.target.data = id;
  815. // listItem.m_txtScore.visible = false;
  816. //listItem.m_ScoreType.visible = true;
  817. listItem.m_imgNeed.visible = false;
  818. listItem.m_btnAni.visible = false;
  819. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  820. listItem.m_imgNew.visible = isNew;
  821. if (isNew)
  822. {
  823. ItemProxy.ReqSetItemRead(id).Coroutine();
  824. }
  825. UI_PartsListItem.ProxyEnd();
  826. }
  827. private void UpdateSearchListPartsSelected()
  828. {
  829. int count = _ui.m_partsListSearch.m_list.numChildren;
  830. int suitId = MyDressUpHelper.dressUpObj.suitId;
  831. for (int i = 0; i < count; i++)
  832. {
  833. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsListSearch.m_list.GetChildAt(i));
  834. int id = (int)listItem.target.data;
  835. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  836. {
  837. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  838. }
  839. else
  840. {
  841. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id); //非套装金判断是否穿戴
  842. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  843. bool isSuit = !isSceneType && suitId > 0 &&
  844. SuitCfgArray.Instance.GetSuitIdOfItem(id) ==
  845. suitId; //非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  846. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn; //场景类, 若当前穿戴套装要判断item是否属已穿戴
  847. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  848. }
  849. UI_PartsListItem.ProxyEnd();
  850. }
  851. }
  852. private void UpdateListPartsSelected()
  853. {
  854. GList list;
  855. if (_ui.m_partsList.target.x == partsListX)
  856. {
  857. list = _ui.m_partsList.m_list;
  858. }
  859. else if (_ui.m_partsListSearch.target.x == partsListX)
  860. {
  861. list = _ui.m_partsListSearch.m_list;
  862. }
  863. else
  864. {
  865. return;
  866. }
  867. int count = list.numChildren;
  868. int suitId = MyDressUpHelper.dressUpObj.suitId;
  869. for (int i = 0; i < count; i++)
  870. {
  871. UI_PartsListItem listItem = UI_PartsListItem.Proxy(list.GetChildAt(i));
  872. int id = (int)listItem.target.data;
  873. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  874. {
  875. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  876. }
  877. else
  878. {
  879. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id); //非套装金判断是否穿戴
  880. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  881. bool isSuit = !isSceneType && suitId > 0 &&
  882. SuitCfgArray.Instance.GetSuitIdOfItem(id) ==
  883. suitId; //非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  884. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn; //场景类, 若当前穿戴套装要判断item是否属已穿戴
  885. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  886. }
  887. UI_PartsListItem.ProxyEnd();
  888. }
  889. }
  890. private void UpdateListSuitPartsSelected()
  891. {
  892. int count = _ui.m_partsList2.m_list.numChildren;
  893. int suitId = MyDressUpHelper.dressUpObj.suitId;
  894. for (int i = 0; i < count; i++)
  895. {
  896. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  897. int id = (int)listItem.target.data;
  898. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id); //非套装金判断是否穿戴
  899. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  900. bool isSuit =
  901. !isSceneType && suitId > 0 &&
  902. SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId; //非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  903. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn; //场景类, 若当前穿戴套装要判断item是否属已穿戴
  904. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  905. UI_PartsListItem.ProxyEnd();
  906. }
  907. }
  908. private void OnClickBtnSearch()
  909. {
  910. ViewManager.Show<DressFilterView>(false);
  911. }
  912. private void OnClickBtnLastStep()
  913. {
  914. if (!MyDressUpHelper.OnClickBtnLastStep()) return;
  915. UpdateStepBtn(false);
  916. }
  917. private void OnClickBtnNextStep()
  918. {
  919. if (!MyDressUpHelper.OnClickBtnNextStep()) return;
  920. UpdateStepBtn(false);
  921. }
  922. private void SendLog()
  923. {
  924. }
  925. }
  926. }