DressUpView.cs 41 KB

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