DressUpView.cs 42 KB

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