ArenaDressUpFightView.cs 41 KB

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