ArenaDressUpFightView.cs 41 KB

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