ArenaDressUpFightView.cs 41 KB

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