DressUpView.cs 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. using UI.DressUp;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. using ET;
  6. namespace GFGGame
  7. {
  8. public class DressUpView : BaseView
  9. {
  10. public const int MAX_MEMORY_STEP = 20;//最大记录步数
  11. public const int BOTTOM_BLANK = 20;
  12. public const int RIGHT_BLANK = 36;
  13. private const int SORT_BY_HIGH_RARITY = 0;
  14. private const int SORT_BY_LOW_RARITY = 1;
  15. private const int SORT_BY_GET_TIME = 2;
  16. private UI_DressUpUI _ui;
  17. private float listType1X = 0;
  18. private float partsListX = 0;
  19. private DressUpListType currentListType;
  20. /// <summary>
  21. /// 子菜单列表
  22. /// </summary>
  23. private int[] _currentList2;
  24. private GameObject _scenePrefab;
  25. private GameObject _sceneObject;
  26. private List<int> _currentList3 = new List<int>();
  27. private List<int> _currentList4 = new List<int>();
  28. private int _currentMenuType;
  29. private int _currentSuitId;
  30. private bool _isNormalSuitType = false;//当前套装部件列表是否为普通动作列表
  31. private int _rarityIndex = SORT_BY_HIGH_RARITY;
  32. private UI_TypeItem listTypeItem_FreedomDress;
  33. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  34. private int _stepIndex = -1;
  35. private List<CustomSuitData> _dressMemory = new List<CustomSuitData>();
  36. public override void Dispose()
  37. {
  38. if (_sceneObject != null)
  39. {
  40. GameObject.Destroy(_sceneObject);
  41. _sceneObject = null;
  42. }
  43. for (int i = 0; i < _listLongPress.Count; i++)
  44. {
  45. _listLongPress[i].Dispose();
  46. }
  47. _listLongPress.Clear();
  48. if (_ui != null)
  49. {
  50. _ui.Dispose();
  51. _ui = null;
  52. }
  53. base.Dispose();
  54. }
  55. protected override void Init()
  56. {
  57. base.Init();
  58. packageName = UI_DressUpUI.PACKAGE_NAME;
  59. _ui = UI_DressUpUI.Create();
  60. viewCom = _ui.target;
  61. isfullScreen = true;
  62. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
  63. }
  64. protected override void OnInit()
  65. {
  66. base.OnInit();
  67. _ui.m_btnLastStep.visible = false;
  68. _ui.m_btnNextStep.visible = false;
  69. _ui.m_btnSearch.visible = true;
  70. _ui.m_btnPhoto.visible = true;
  71. _ui.m_btnAction.visible = false;
  72. _ui.m_comboBox.items = new string[] { "我的套装一", "我的套装二", "我的套装三", "我的套装四", "我的套装五", "我的套装六" };
  73. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  74. InitLists();
  75. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  76. _ui.m_btnHome.onClick.Add(OnClickBtnHome);
  77. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  78. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  79. _ui.m_comboBox.onChanged.Add(OnComboBoxChanged);
  80. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  81. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  82. // _ui.m_partsList.m_list.SetVirtual();
  83. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  84. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  85. _ui.m_touchPad.onClick.Add(OnTouchPad);
  86. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  87. _ui.m_btnSave.onClick.Add(OnClickBtnSave);
  88. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  89. _ui.m_btnAction.onClick.Add(OnClickBtnAction);
  90. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  91. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  92. _ui.m_btnShow.onClick.Add(OnClickBtnShow);
  93. _ui.m_btnHide.onClick.Add(OnClickBtnHide);
  94. _ui.m_loaShow.onClick.Add(OnClickLoaShow);
  95. _ui.m_btnPhoto.onClick.Add(OnClickBtnPhoto);
  96. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  97. _ui.m_partsList2.m_imgTop.visible = true;
  98. _ui.m_partsList.m_imgTop.visible = false;
  99. }
  100. protected override void AddEventListener()
  101. {
  102. base.AddEventListener();
  103. EventAgent.AddEventListener(ConstMessage.CLOSE_PHOTOGRAPHVIEW, UpdateScene);
  104. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  105. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  106. }
  107. protected override void OnShown()
  108. {
  109. base.OnShown();
  110. if (this.viewData != null)
  111. {
  112. _ui.m_c2.selectedIndex = (int)this.viewData;
  113. }
  114. _rarityIndex = SORT_BY_HIGH_RARITY;
  115. // MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DRESS_UP, "mp3"));
  116. _ui.m_comListType1.target.x = _ui.target.width;
  117. _ui.m_comListType2.target.x = _ui.target.width;
  118. _ui.m_partsList.target.x = _ui.target.width;
  119. _ui.m_partsList2.target.x = _ui.target.width;
  120. this.showListType1();
  121. if (_sceneObject == null)
  122. {
  123. _sceneObject = GameObject.Instantiate(_scenePrefab);
  124. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
  125. }
  126. _ui.m_comboBox.selectedIndex = CustomSuitDataManager.currentIndex;
  127. MyDressUpHelper.PutOnSuitSavedByPos(CustomSuitDataManager.currentIndex);
  128. // UpdateStepBtn();
  129. // AddMemoryDressup();
  130. Timers.inst.AddUpdate(CheckGuide);
  131. }
  132. protected override void OnHide()
  133. {
  134. base.OnHide();
  135. listTypeItem_FreedomDress = null;
  136. // MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  137. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);//在拍照界面断线返回登录,需要重新设置_sceneObject
  138. MyDressUpHelper.dressUpObj.TakeOffAll();
  139. if (_sceneObject != null)
  140. {
  141. GameObject.Destroy(_sceneObject);
  142. _sceneObject = null;
  143. }
  144. _ui.m_c2.selectedIndex = 0;
  145. Reset();
  146. Timers.inst.Remove(CheckGuide);
  147. }
  148. protected override void RemoveEventListener()
  149. {
  150. base.RemoveEventListener();
  151. EventAgent.RemoveEventListener(ConstMessage.CLOSE_PHOTOGRAPHVIEW, UpdateScene);
  152. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  153. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  154. }
  155. private void OnClickBtnBack()
  156. {
  157. Reset();
  158. // this.Hide();
  159. // ViewManager.Show(ViewName.MAINUI_VIEW);
  160. ViewManager.GoBackFrom(typeof(DressUpView).FullName);
  161. }
  162. private void OnClickBtnHome()
  163. {
  164. GameController.GoBackToMainView();
  165. Reset();
  166. }
  167. private void Reset()
  168. {
  169. DressUpMenuItemDataManager.Clear();
  170. _stepIndex = -1;
  171. _dressMemory.Clear();
  172. }
  173. private void OnClickBtnLastStep()
  174. {
  175. if (_stepIndex - 1 < 0) return;
  176. _stepIndex--;
  177. MyDressUpHelper.dressUpObj.PutOnDressUpData(_dressMemory[_stepIndex].dressUpData);
  178. _ui.m_comboBox.selectedIndex = _dressMemory[_stepIndex].pos;
  179. UpdateStepBtn();
  180. }
  181. private void OnClickBtnNextStep()
  182. {
  183. if (_stepIndex + 1 >= MAX_MEMORY_STEP) return;
  184. _stepIndex++;
  185. MyDressUpHelper.dressUpObj.PutOnDressUpData(_dressMemory[_stepIndex].dressUpData);
  186. _ui.m_comboBox.selectedIndex = _dressMemory[_stepIndex].pos;
  187. UpdateStepBtn();
  188. }
  189. private void OnComboBoxChanged()
  190. {
  191. MyDressUpHelper.PutOnSuitSavedByPos(_ui.m_comboBox.selectedIndex);
  192. }
  193. private void OnClickListType1Item(EventContext context)
  194. {
  195. GObject typeItem = (GObject)context.data as GObject;
  196. int order = (int)typeItem.data;
  197. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  198. if (item1.subMenusArr.Length > 0)
  199. {
  200. this.showListType2(item1.subMenusArr);
  201. }
  202. else
  203. {
  204. if (this.showListParts(item1.type) == false)
  205. {
  206. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  207. return;
  208. }
  209. }
  210. this.hideListType1();
  211. UpdateListPartsSelected();
  212. }
  213. private void OnClickListType2Item(EventContext context)
  214. {
  215. GObject typeItem = (GObject)context.data as GObject;
  216. int order = (int)typeItem.data;
  217. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  218. if (this.showListParts(item2.type) == false)
  219. {
  220. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  221. return;
  222. }
  223. this.hideListType2();
  224. }
  225. private void OnClickPartsListItem(EventContext context)
  226. {
  227. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  228. {
  229. return;
  230. }
  231. UI_PartsListItem listItem = UI_PartsListItem.Proxy(context.data as GObject);// (GObject)context.data as GObject;
  232. int id = (int)listItem.target.data;
  233. // bool isSuit = SuitCfgArray.Instance.GetTotalCountOfOneSuit(id) > 0;
  234. if (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG)
  235. {
  236. if (SuitCfgArray.Instance.CheckSuitHasAction(id))
  237. {
  238. listItem.m_comAxtionSelect.target.visible = true;
  239. UI_PartsListItem.ProxyEnd();
  240. }
  241. else
  242. {
  243. ShowSuitPartList(id, false);
  244. }
  245. }
  246. else if (_currentMenuType == ConstDressUpItemType.DONG_ZUO)
  247. {
  248. MyDressUpHelper.dressUpObj.PutOnOrTakeOffAction(id);
  249. }
  250. else
  251. {
  252. if (MyDressUpHelper.dressUpObj.IsAction)
  253. {
  254. if (SuitCfgArray.Instance.CheckItemReaplaceableByAction(id, MyDressUpHelper.dressUpObj.actionId))
  255. {
  256. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  257. }
  258. else
  259. {
  260. if (!SuitCfgArray.Instance.CheckActionContainsItem(id, MyDressUpHelper.dressUpObj.actionId))
  261. {
  262. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  263. }
  264. MyDressUpHelper.dressUpObj.CancelAction();
  265. }
  266. }
  267. else
  268. {
  269. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  270. }
  271. }
  272. UpdateListPartsSelected(id);
  273. UpdateListSuitPartsSelected();
  274. // AddMemoryDressup();
  275. }
  276. private void OnBtnNormalClick(EventContext context)
  277. {
  278. _isNormalSuitType = true;
  279. GObject gObject = context.sender as GObject;
  280. int suitId = (int)gObject.data;
  281. ShowSuitPartList(suitId, false);
  282. }
  283. private void OnBtnActionClick(EventContext context)
  284. {
  285. _isNormalSuitType = false;
  286. GObject gObject = context.sender as GObject;
  287. int suitId = (int)gObject.data;
  288. ShowSuitPartList(suitId, true);
  289. }
  290. private void ShowSuitPartList(int suitId, bool showAction)
  291. {
  292. this.showListParts2(suitId);
  293. this.hideListParts();
  294. if (showAction)
  295. {
  296. MyDressUpHelper.dressUpObj.PutOnSuitCfg(suitId, true);
  297. MyDressUpHelper.dressUpObj.PutOnAction(suitId);
  298. }
  299. else
  300. {
  301. MyDressUpHelper.dressUpObj.CancelAction();
  302. MyDressUpHelper.dressUpObj.PutOnSuitCfg(suitId, false);
  303. }
  304. }
  305. private void OnClickSuitPartsListItem(EventContext context)
  306. {
  307. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  308. {
  309. return;
  310. }
  311. GObject listItem = (GObject)context.data as GObject;
  312. int id = (int)listItem.data;
  313. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  314. if (itemCfg != null)
  315. {
  316. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  317. }
  318. else
  319. {
  320. MyDressUpHelper.dressUpObj.PutOnOrTakeOffAction(id);
  321. }
  322. UpdateListSuitPartsSelected();
  323. }
  324. private void AddMemoryDressup()
  325. {
  326. _stepIndex++;
  327. if (_stepIndex == MAX_MEMORY_STEP)
  328. {
  329. _stepIndex = MAX_MEMORY_STEP - 1;
  330. _dressMemory.RemoveAt(0);
  331. }
  332. if (_dressMemory.Count > _stepIndex)
  333. {
  334. _dressMemory.RemoveRange(_stepIndex, _dressMemory.Count - _stepIndex);
  335. }
  336. CustomSuitData suitSavedData = MyDressUpHelper.GetCurSuitDataClone(_ui.m_comboBox.selectedIndex);
  337. _dressMemory.Add(suitSavedData);
  338. UpdateStepBtn();
  339. }
  340. private void UpdateStepBtn()
  341. {
  342. _ui.m_btnLastStep.enabled = _stepIndex > 0;
  343. _ui.m_btnNextStep.enabled = _stepIndex < _dressMemory.Count - 1;
  344. }
  345. private void OnLongPress(EventContext context)
  346. {
  347. LongPressGesture gesture = (LongPressGesture)context.sender;
  348. int itemId = (int)gesture.host.data;
  349. GoodsItemTipsController.ShowItemTips(itemId);
  350. }
  351. private void OnTouchPad()
  352. {
  353. if (this.currentListType == DressUpListType.List4)
  354. {
  355. this.hideListParts2();
  356. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  357. }
  358. else if (this.currentListType == DressUpListType.List3)
  359. {
  360. if (_currentList2 != null)
  361. {
  362. this.showListType2(_currentList2);
  363. // _ui.m_comListType2.m_listType.numItems = _ui.m_comListType2.m_listType.numItems;
  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. // _ui.m_comListType1.m_listType.numItems = _ui.m_comListType1.m_listType.numItems;
  377. // this.ShowSubList();
  378. }
  379. private void OnClickBtnDelete()
  380. {
  381. MyDressUpHelper.dressUpObj.TakeOffAll();
  382. MyDressUpHelper.dressUpObj.AddOrRemove(ConstItemID.DEFULT_BG, false);
  383. UpdateBtnAction();
  384. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  385. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  386. }
  387. private void OnClickBtnSave()
  388. {
  389. CustomSuitDataManager.SaveCurrentSuit(_ui.m_comboBox.selectedIndex);
  390. }
  391. private void OnComboBoxRarityChanged()
  392. {
  393. _rarityIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  394. this.UpdatePartsListSort();
  395. }
  396. private void OnClickBtnAction()
  397. {
  398. MyDressUpHelper.dressUpObj.PutOnOrTakeOffAction(201003);
  399. }
  400. private void OnClickBtnSearch()
  401. {
  402. ViewManager.Show<DressFilterView>(true, new object[] { ViewName.DRESS_UP_VIEW });
  403. }
  404. private void InitLists()
  405. {
  406. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  407. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  408. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  409. listType1X = _ui.m_comListType1.target.x;
  410. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;// - DressUpView.RIGHT_BLANK;
  411. //一级菜单
  412. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  413. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length;
  414. //_ui.m_comListType1.m_listType1.ResizeToFit(_ui.m_comListType1.m_listType1.numItems);
  415. float maxHeight = _ui.target.height - _ui.m_comListType1.target.y - DressUpView.BOTTOM_BLANK;
  416. if (_ui.m_comListType1.m_listType.height > maxHeight)
  417. {
  418. _ui.m_comListType1.m_listType.height = maxHeight;
  419. }
  420. }
  421. private void showListType1()
  422. {
  423. _currentList2 = null;
  424. currentListType = DressUpListType.List1;
  425. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length;
  426. GTween.To(_ui.target.width, listType1X, 0.5f)
  427. .SetTarget(_ui.m_comListType1.target)
  428. .OnUpdate((GTweener t) =>
  429. {
  430. _ui.m_comListType1.target.x = t.value.x;
  431. });
  432. }
  433. private void hideListType1()
  434. {
  435. GTween.To(listType1X, _ui.target.width, 0.5f)
  436. .SetTarget(_ui.m_comListType1.target)
  437. .OnUpdate((GTweener t) =>
  438. {
  439. _ui.m_comListType1.target.x = t.value.x;
  440. });
  441. }
  442. private void showListType2(int[] menuStrArr = null)
  443. {
  444. currentListType = DressUpListType.List2;
  445. if (menuStrArr != null && menuStrArr.Length > 0)
  446. {
  447. int len = menuStrArr.Length;
  448. _currentList2 = menuStrArr.Clone() as int[];
  449. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  450. _ui.m_comListType2.m_listType.numItems = len;
  451. //_ui.m_comListType2.m_listType2.ResizeToFit(_ui.m_comListType2.m_listType2.numItems);
  452. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  453. if (_ui.m_comListType2.m_listType.height > maxHeight)
  454. {
  455. _ui.m_comListType2.m_listType.height = maxHeight;
  456. }
  457. }
  458. GTween.To(_ui.target.width, listType1X, 0.5f)
  459. .SetTarget(_ui.m_comListType2.target)
  460. .OnUpdate((GTweener t) =>
  461. {
  462. _ui.m_comListType2.target.x = t.value.x;
  463. });
  464. }
  465. private void hideListType2()
  466. {
  467. GTween.To(listType1X, _ui.target.width, 0.5f)
  468. .SetTarget(_ui.m_comListType2.target)
  469. .OnUpdate((GTweener t) =>
  470. {
  471. _ui.m_comListType2.target.x = t.value.x;
  472. });
  473. }
  474. private bool showListParts(int type, bool selectItem = false)
  475. {
  476. _currentMenuType = type;
  477. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  478. {
  479. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  480. if (_rarityIndex >= SORT_BY_GET_TIME)
  481. {
  482. _rarityIndex = SORT_BY_HIGH_RARITY;
  483. }
  484. }
  485. else
  486. {
  487. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  488. }
  489. this.UpdatePartsListSort();
  490. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  491. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  492. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;// - DressUpView.BOTTOM_BLANK;
  493. if (_ui.m_partsList.m_list.height > maxHeight)
  494. {
  495. _ui.m_partsList.m_list.height = maxHeight;
  496. }
  497. if (selectItem)
  498. {
  499. int itemId = 0;
  500. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  501. {
  502. itemId = _currentSuitId;
  503. }
  504. else
  505. {
  506. itemId = MyDressUpHelper.dressUpObj.GetItemIdBuyType(_currentMenuType);
  507. }
  508. if (itemId > 0)
  509. {
  510. int index = _currentList3.IndexOf(itemId);
  511. _ui.m_partsList.m_list.ScrollToView(index);
  512. }
  513. }
  514. currentListType = DressUpListType.List3;
  515. GTween.To(_ui.target.width, partsListX, 0.5f)
  516. .SetTarget(_ui.m_partsList)
  517. .OnUpdate((GTweener t) =>
  518. {
  519. _ui.m_partsList.target.x = t.value.x;
  520. });
  521. UpdateBtnAction();
  522. UpdateListPartsSelected();
  523. return true;
  524. }
  525. private void hideListParts()
  526. {
  527. // _currentMenuType = 0;
  528. UpdateBtnAction();
  529. GTween.To(partsListX, _ui.target.width, 0.5f)
  530. .SetTarget(_ui.m_partsList)
  531. .OnUpdate((GTweener t) =>
  532. {
  533. _ui.m_partsList.target.x = t.value.x;
  534. });
  535. }
  536. private void showListParts2(int suitId)
  537. {
  538. _currentSuitId = suitId;
  539. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  540. if (_rarityIndex >= SORT_BY_GET_TIME)
  541. {
  542. _rarityIndex = SORT_BY_HIGH_RARITY;
  543. }
  544. this.UpdateSuitPartsListSort();
  545. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  546. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  547. if (_ui.m_partsList2.m_list.height > maxHeight)
  548. {
  549. _ui.m_partsList2.m_list.height = maxHeight;
  550. }
  551. currentListType = DressUpListType.List4;
  552. GTween.To(_ui.target.width, partsListX, 0.5f)
  553. .SetTarget(_ui.m_partsList2)
  554. .OnUpdate((GTweener t) =>
  555. {
  556. _ui.m_partsList2.target.x = t.value.x;
  557. });
  558. UpdateBtnAction();
  559. }
  560. private void hideListParts2()
  561. {
  562. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  563. UpdateBtnAction();
  564. GTween.To(partsListX, _ui.target.width, 0.5f)
  565. .SetTarget(_ui.m_partsList2)
  566. .OnUpdate((GTweener t) =>
  567. {
  568. _ui.m_partsList2.target.x = t.value.x;
  569. });
  570. }
  571. /****************************************************************************************************************************/
  572. private void ListType1Item(int index, GObject item)
  573. {
  574. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  575. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  576. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  577. typeItem.m_txtname.text = item1.name;
  578. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  579. typeItem.target.data = item1.id;
  580. typeItem.m_imgNeed.visible = false;
  581. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  582. UI_TypeItem.ProxyEnd();
  583. }
  584. private void ListType2Item(int index, GObject item)
  585. {
  586. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  587. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  588. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  589. typeItem.m_txtname.text = item2.name;
  590. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  591. typeItem.target.data = item2.id;
  592. typeItem.m_imgNeed.visible = false;
  593. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  594. UI_TypeItem.ProxyEnd();
  595. }
  596. private void ListPartsItem(int index, GObject item)
  597. {
  598. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  599. int id = (int)_currentList3[index];
  600. string iconRes = "";
  601. string partName = "";
  602. string ext = "png";
  603. listItem.m_comAxtionSelect.target.visible = false;
  604. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  605. {
  606. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  607. iconRes = suitCfg.res;
  608. partName = suitCfg.name;
  609. listItem.m_iconSelected.visible = false;
  610. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  611. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  612. listItem.m_ScoreType.visible = false;
  613. listItem.m_imgNew.visible = false;
  614. listItem.m_comAxtionSelect.m_btnNormal.icon = ResPathUtil.GetIconPath(suitCfg.res, ext);
  615. listItem.m_comAxtionSelect.m_btnAction.icon = ResPathUtil.GetIconPath(suitCfg.res, ext);
  616. if (listItem.m_comAxtionSelect.m_btnNormal.data == null)
  617. {
  618. listItem.m_comAxtionSelect.m_btnNormal.onClick.Add(OnBtnNormalClick);
  619. }
  620. listItem.m_comAxtionSelect.m_btnNormal.data = id;
  621. if (listItem.m_comAxtionSelect.m_btnAction.data == null)
  622. {
  623. listItem.m_comAxtionSelect.m_btnAction.onClick.Add(OnBtnActionClick);
  624. }
  625. listItem.m_comAxtionSelect.m_btnAction.data = id;
  626. }
  627. else if (_currentMenuType == (int)ConstDressUpItemType.DONG_ZUO)
  628. {
  629. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  630. iconRes = suitCfg.res;
  631. partName = suitCfg.name;
  632. listItem.m_iconSelected.visible = false;
  633. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  634. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  635. listItem.m_ScoreType.visible = false;
  636. listItem.m_imgNew.visible = false;
  637. }
  638. else
  639. {
  640. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  641. iconRes = itemCfg.res;
  642. partName = itemCfg.name;
  643. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  644. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  645. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  646. // ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  647. listItem.m_ScoreType.visible = true;
  648. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
  649. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  650. listItem.m_imgNew.visible = isNew;
  651. if (isNew)
  652. {
  653. ItemProxy.ReqSetItemRead(id).Coroutine();
  654. }
  655. }
  656. if (listItem.target.data == null)
  657. {
  658. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  659. longPressGesture.once = true;
  660. longPressGesture.onAction.Add(OnLongPress);
  661. _listLongPress.Add(longPressGesture);
  662. }
  663. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  664. listItem.m_txtTitle.text = partName;
  665. listItem.target.data = id;
  666. listItem.m_txtScore.visible = false;
  667. //listItem.m_ScoreType.visible = true;
  668. listItem.m_imgNeed.visible = false;
  669. UI_PartsListItem.ProxyEnd();
  670. }
  671. private void ListParts2Item(int index, GObject item)
  672. {
  673. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  674. int id = (int)_currentList4[index];
  675. string iconRes = "";
  676. string partName = "";
  677. // string ext = "png";
  678. if (listItem.target.data == null)
  679. {
  680. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  681. longPressGesture.once = true;
  682. longPressGesture.onAction.Add(OnLongPress);
  683. _listLongPress.Add(longPressGesture);
  684. }
  685. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  686. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  687. iconRes = itemCfg != null ? itemCfg.res : suitCfg.res;
  688. partName = itemCfg != null ? itemCfg.name : suitCfg.name;
  689. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  690. bool isAction = MyDressUpHelper.dressUpObj.IsAction && SuitCfgArray.Instance.CheckActionContainsItem(id, MyDressUpHelper.dressUpObj.actionId);
  691. listItem.m_iconSelected.visible = isPutOn || isAction;
  692. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, itemCfg == null);
  693. listItem.m_ScoreType.visible = false;
  694. if (itemCfg != null)
  695. {
  696. listItem.m_ScoreType.visible = true;
  697. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
  698. }
  699. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, "png");
  700. listItem.m_txtTitle.text = partName;
  701. listItem.target.data = id;
  702. listItem.m_txtScore.visible = false;
  703. //listItem.m_ScoreType.visible = true;
  704. listItem.m_imgNeed.visible = false;
  705. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  706. listItem.m_imgNew.visible = isNew;
  707. if (isNew)
  708. {
  709. ItemProxy.ReqSetItemRead(id).Coroutine();
  710. }
  711. UI_PartsListItem.ProxyEnd();
  712. }
  713. private void UpdateListPartsSelected(int selectSuitId = 0)
  714. {
  715. int count = _ui.m_partsList.m_list.numChildren;
  716. int suitId = MyDressUpHelper.dressUpObj.suitId;
  717. for (int i = 0; i < count; i++)
  718. {
  719. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  720. int id = (int)listItem.target.data;
  721. if (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG)
  722. {
  723. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  724. listItem.m_comAxtionSelect.target.visible = id == selectSuitId && SuitCfgArray.Instance.CheckSuitHasAction(id);
  725. }
  726. else if (_currentMenuType == ConstDressUpItemType.DONG_ZUO)
  727. {
  728. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.IsAction && MyDressUpHelper.dressUpObj.actionId == id;
  729. }
  730. else
  731. {
  732. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  733. bool isAction = MyDressUpHelper.dressUpObj.IsAction && SuitCfgArray.Instance.CheckActionContainsItem(id, MyDressUpHelper.dressUpObj.actionId);
  734. listItem.m_iconSelected.visible = isPutOn || isAction;
  735. }
  736. UI_PartsListItem.ProxyEnd();
  737. }
  738. }
  739. private void UpdateListSuitPartsSelected()
  740. {
  741. int count = _ui.m_partsList2.m_list.numChildren;
  742. for (int i = 0; i < count; i++)
  743. {
  744. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  745. int id = (int)listItem.target.data;
  746. bool isSuitSelect = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//可换部件是否穿戴
  747. bool isActionSelect = MyDressUpHelper.dressUpObj.actionId == id;
  748. listItem.m_iconSelected.visible = isSuitSelect || isActionSelect;
  749. UI_PartsListItem.ProxyEnd();
  750. }
  751. }
  752. private void UpdatePartsListSort()
  753. {
  754. if (_currentMenuType == 0) return;
  755. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  756. {
  757. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  758. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  759. {
  760. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  761. }
  762. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  763. {
  764. _currentList3 = SuitUtil.SortSuitListByLowRarity(_currentList3);
  765. }
  766. else
  767. {
  768. _currentList3.Reverse();
  769. }
  770. }
  771. else if (_currentMenuType == (int)ConstDressUpItemType.DONG_ZUO)
  772. {
  773. _currentList3 = DressUpMenuSuitDataManager.GetActionIDList();
  774. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  775. {
  776. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  777. }
  778. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  779. {
  780. _currentList3 = SuitUtil.SortSuitListByLowRarity(_currentList3);
  781. }
  782. else
  783. {
  784. _currentList3.Reverse();
  785. }
  786. }
  787. else
  788. {
  789. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  790. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  791. {
  792. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighRarity(_currentList3);
  793. }
  794. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  795. {
  796. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowRarity(_currentList3);
  797. }
  798. else
  799. {
  800. _currentList3.Reverse();
  801. }
  802. }
  803. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  804. {
  805. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  806. }
  807. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  808. {
  809. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  810. }
  811. _ui.m_partsList.m_list.RemoveChildrenToPool();
  812. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  813. }
  814. private void UpdateSuitPartsListSort()
  815. {
  816. if (_currentMenuType == 0) return;
  817. if (_isNormalSuitType)
  818. {
  819. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId));
  820. }
  821. else
  822. {
  823. _currentList4 = SuitCfgArray.Instance.GetOneSuitAllNotActionParts(_currentSuitId);
  824. _currentList4.Add(_currentSuitId);
  825. }
  826. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  827. {
  828. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  829. }
  830. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  831. {
  832. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  833. }
  834. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  835. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  836. }
  837. private void UpdateBtnAction()
  838. {
  839. // _ui.m_btnAction.visible = (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG) || this.currentListType == DressUpListType.List4;
  840. // if (_ui.m_btnAction.visible)
  841. // {
  842. //_ui.m_btnAction.grayed = !EquipDataCache.cacher.HasSuitActionRes;
  843. // }
  844. }
  845. private void OnClickBtnShow()
  846. {
  847. Timers.inst.Remove(SetBtnShowVisable);
  848. _ui.m_c1.selectedIndex = 0;
  849. _ui.m_btnHide.visible = true;
  850. _ui.m_btnShow.visible = false;
  851. _ui.m_loaShow.visible = false;
  852. }
  853. private void OnClickBtnHide()
  854. {
  855. _ui.m_c1.selectedIndex = 1;
  856. _ui.m_btnHide.visible = false;
  857. _ui.m_btnShow.visible = true;
  858. _ui.m_loaShow.visible = true;
  859. Timers.inst.Add(2f, 1, SetBtnShowVisable);
  860. }
  861. private void OnClickLoaShow()
  862. {
  863. _ui.m_btnShow.alpha = 1;
  864. _ui.m_btnShow.enabled = true;
  865. Timers.inst.Add(2f, 1, SetBtnShowVisable);
  866. }
  867. private void OnClickBtnPhoto()
  868. {
  869. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.PAI_ZHAO, 1);
  870. if (!ViewManager.Show<PhotographView>())
  871. {
  872. return;
  873. }
  874. _ui.target.visible = false;
  875. this._sceneObject.gameObject.SetActive(false);
  876. }
  877. private void OnClickBtnNext()
  878. {
  879. // if (!EquipDataCache.cacher.CheckPutOnFinish())
  880. // {
  881. // AlertUI.Show("只有换好衣服才能出门哦!")
  882. // .SetRightButton(true, "好的");
  883. // return;
  884. // }
  885. if (!ViewManager.Show<PhotographView>(this.viewData))
  886. {
  887. return;
  888. }
  889. _ui.target.visible = false;
  890. this._sceneObject.gameObject.SetActive(false);
  891. }
  892. private void UpdateScene()
  893. {
  894. _ui.target.visible = true;
  895. this._sceneObject.gameObject.SetActive(true);
  896. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
  897. }
  898. private void SetBtnShowVisable(object param)
  899. {
  900. _ui.m_btnShow.enabled = false;
  901. GTween.To(1, 0, 0.3f).SetTarget(_ui.m_btnShow, TweenPropType.Alpha);
  902. }
  903. private bool CheckListCount(int type)
  904. {
  905. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  906. {
  907. return DressUpMenuSuitDataManager.GetSuitIDList().Count > 0;
  908. }
  909. else
  910. {
  911. return DressUpMenuItemDataManager.getItemDatasByType(type).Count > 0;
  912. }
  913. }
  914. private void CheckGuide(object param)
  915. {
  916. if (GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0
  917. || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER) <= 0)
  918. {
  919. UpdateToCheckGuide(null);
  920. }
  921. else
  922. {
  923. Timers.inst.Remove(CheckGuide);
  924. }
  925. }
  926. protected override void UpdateToCheckGuide(object param)
  927. {
  928. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  929. if (listTypeItem_FreedomDress == null && GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0)
  930. {
  931. int len = _ui.m_comListType1.m_listType.numChildren;
  932. for (int i = 0; i < len; i++)
  933. {
  934. UI_TypeItem item = UI_TypeItem.Proxy(_ui.m_comListType1.m_listType.GetChildAt(i));
  935. if (item != null)
  936. {
  937. int menuID = (int)item.target.data;
  938. DressUpMenuItemCfg1 dressUpMenuItemCfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuID);
  939. if (dressUpMenuItemCfg1.type == ConstDressUpItemType.TAO_ZHUANG)
  940. {
  941. listTypeItem_FreedomDress = item;
  942. _ui.m_comListType1.m_listType.ScrollToView(i);
  943. break;
  944. }
  945. }
  946. UI_TypeItem.ProxyEnd();
  947. }
  948. }
  949. if (listTypeItem_FreedomDress != null) GuideController.TryGuide(listTypeItem_FreedomDress.target, ConstGuideId.FREEDOM_DRESS, 3, "套装分类里,可以查看集齐成套的服饰,点击一键换上。");
  950. GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.FREEDOM_DRESS, 4, "", 0);
  951. GuideController.TryGuide(_ui.m_btnSave, ConstGuideId.FREEDOM_DRESS, 5, "搭配好的服饰,可以保存到主界面显示。");
  952. GuideController.TryGuide(_ui.m_btnPhoto, ConstGuideId.FREEDOM_DRESS, 6, "辛苦搭配完,去拍个照片留念呀~~");
  953. GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.ENTER_CHAPTER, 2, "");
  954. }
  955. }
  956. }