DressUpView.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053
  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. _isNormalSuitType = !showAction;
  293. this.showListParts2(suitId);
  294. this.hideListParts();
  295. MyDressUpHelper.dressUpObj.TakeOffAll();
  296. if (showAction)
  297. {
  298. MyDressUpHelper.dressUpObj.PutOnSuitCfg(suitId, true);
  299. }
  300. else
  301. {
  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. if (index >= 0 && index < _ui.m_partsList.m_list.numItems)
  512. {
  513. _ui.m_partsList.m_list.ScrollToView(index);
  514. }
  515. }
  516. }
  517. currentListType = DressUpListType.List3;
  518. GTween.To(_ui.target.width, partsListX, 0.5f)
  519. .SetTarget(_ui.m_partsList)
  520. .OnUpdate((GTweener t) =>
  521. {
  522. _ui.m_partsList.target.x = t.value.x;
  523. });
  524. UpdateBtnAction();
  525. UpdateListPartsSelected();
  526. return true;
  527. }
  528. private void hideListParts()
  529. {
  530. // _currentMenuType = 0;
  531. UpdateBtnAction();
  532. GTween.To(partsListX, _ui.target.width, 0.5f)
  533. .SetTarget(_ui.m_partsList)
  534. .OnUpdate((GTweener t) =>
  535. {
  536. _ui.m_partsList.target.x = t.value.x;
  537. });
  538. }
  539. private void showListParts2(int suitId)
  540. {
  541. _currentSuitId = suitId;
  542. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  543. if (_rarityIndex >= SORT_BY_GET_TIME)
  544. {
  545. _rarityIndex = SORT_BY_HIGH_RARITY;
  546. }
  547. this.UpdateSuitPartsListSort();
  548. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  549. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  550. if (_ui.m_partsList2.m_list.height > maxHeight)
  551. {
  552. _ui.m_partsList2.m_list.height = maxHeight;
  553. }
  554. currentListType = DressUpListType.List4;
  555. GTween.To(_ui.target.width, partsListX, 0.5f)
  556. .SetTarget(_ui.m_partsList2)
  557. .OnUpdate((GTweener t) =>
  558. {
  559. _ui.m_partsList2.target.x = t.value.x;
  560. });
  561. UpdateBtnAction();
  562. }
  563. private void hideListParts2()
  564. {
  565. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  566. UpdateBtnAction();
  567. GTween.To(partsListX, _ui.target.width, 0.5f)
  568. .SetTarget(_ui.m_partsList2)
  569. .OnUpdate((GTweener t) =>
  570. {
  571. _ui.m_partsList2.target.x = t.value.x;
  572. });
  573. }
  574. /****************************************************************************************************************************/
  575. private void ListType1Item(int index, GObject item)
  576. {
  577. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  578. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  579. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  580. typeItem.m_txtname.text = item1.name;
  581. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  582. typeItem.target.data = item1.id;
  583. typeItem.m_imgNeed.visible = false;
  584. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  585. UI_TypeItem.ProxyEnd();
  586. }
  587. private void ListType2Item(int index, GObject item)
  588. {
  589. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  590. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  591. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  592. typeItem.m_txtname.text = item2.name;
  593. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  594. typeItem.target.data = item2.id;
  595. typeItem.m_imgNeed.visible = false;
  596. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  597. UI_TypeItem.ProxyEnd();
  598. }
  599. private void ListPartsItem(int index, GObject item)
  600. {
  601. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  602. int id = (int)_currentList3[index];
  603. string iconRes = "";
  604. string partName = "";
  605. string ext = "png";
  606. listItem.m_comAxtionSelect.target.visible = false;
  607. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  608. {
  609. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  610. iconRes = suitCfg.res;
  611. partName = suitCfg.name;
  612. listItem.m_iconSelected.visible = false;
  613. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  614. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  615. listItem.m_ScoreType.visible = false;
  616. listItem.m_imgNew.visible = false;
  617. listItem.m_comAxtionSelect.m_btnNormal.icon = ResPathUtil.GetIconPath(suitCfg.res, ext);
  618. listItem.m_comAxtionSelect.m_btnAction.icon = ResPathUtil.GetIconPath(suitCfg.res, ext);
  619. if (listItem.m_comAxtionSelect.m_btnNormal.data == null)
  620. {
  621. listItem.m_comAxtionSelect.m_btnNormal.onClick.Add(OnBtnNormalClick);
  622. }
  623. listItem.m_comAxtionSelect.m_btnNormal.data = id;
  624. if (listItem.m_comAxtionSelect.m_btnAction.data == null)
  625. {
  626. listItem.m_comAxtionSelect.m_btnAction.onClick.Add(OnBtnActionClick);
  627. }
  628. listItem.m_comAxtionSelect.m_btnAction.data = id;
  629. }
  630. else if (_currentMenuType == (int)ConstDressUpItemType.DONG_ZUO)
  631. {
  632. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  633. iconRes = suitCfg.res;
  634. partName = suitCfg.name;
  635. listItem.m_iconSelected.visible = false;
  636. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  637. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  638. listItem.m_ScoreType.visible = false;
  639. listItem.m_imgNew.visible = false;
  640. }
  641. else
  642. {
  643. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  644. iconRes = itemCfg.res;
  645. partName = itemCfg.name;
  646. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  647. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  648. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  649. // ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  650. listItem.m_ScoreType.visible = true;
  651. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
  652. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  653. listItem.m_imgNew.visible = isNew;
  654. if (isNew)
  655. {
  656. ItemProxy.ReqSetItemRead(id).Coroutine();
  657. }
  658. }
  659. if (listItem.target.data == null)
  660. {
  661. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  662. longPressGesture.once = true;
  663. longPressGesture.onAction.Add(OnLongPress);
  664. _listLongPress.Add(longPressGesture);
  665. }
  666. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  667. listItem.m_txtTitle.text = partName;
  668. listItem.target.data = id;
  669. listItem.m_txtScore.visible = false;
  670. //listItem.m_ScoreType.visible = true;
  671. listItem.m_imgNeed.visible = false;
  672. UI_PartsListItem.ProxyEnd();
  673. }
  674. private void ListParts2Item(int index, GObject item)
  675. {
  676. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  677. int id = (int)_currentList4[index];
  678. string iconRes = "";
  679. string partName = "";
  680. // string ext = "png";
  681. if (listItem.target.data == null)
  682. {
  683. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  684. longPressGesture.once = true;
  685. longPressGesture.onAction.Add(OnLongPress);
  686. _listLongPress.Add(longPressGesture);
  687. }
  688. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  689. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  690. iconRes = itemCfg != null ? itemCfg.res : suitCfg.res;
  691. partName = itemCfg != null ? itemCfg.name : suitCfg.name;
  692. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  693. bool isAction = MyDressUpHelper.dressUpObj.IsAction && SuitCfgArray.Instance.CheckActionContainsItem(id, MyDressUpHelper.dressUpObj.actionId);
  694. listItem.m_iconSelected.visible = isPutOn || isAction;
  695. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, itemCfg == null);
  696. listItem.m_ScoreType.visible = false;
  697. if (itemCfg != null)
  698. {
  699. listItem.m_ScoreType.visible = true;
  700. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
  701. }
  702. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, "png");
  703. listItem.m_txtTitle.text = partName;
  704. listItem.target.data = id;
  705. listItem.m_txtScore.visible = false;
  706. //listItem.m_ScoreType.visible = true;
  707. listItem.m_imgNeed.visible = false;
  708. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  709. listItem.m_imgNew.visible = isNew;
  710. if (isNew)
  711. {
  712. ItemProxy.ReqSetItemRead(id).Coroutine();
  713. }
  714. UI_PartsListItem.ProxyEnd();
  715. }
  716. private void UpdateListPartsSelected(int selectSuitId = 0)
  717. {
  718. int count = _ui.m_partsList.m_list.numChildren;
  719. int suitId = MyDressUpHelper.dressUpObj.suitId;
  720. for (int i = 0; i < count; i++)
  721. {
  722. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  723. int id = (int)listItem.target.data;
  724. if (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG)
  725. {
  726. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  727. listItem.m_comAxtionSelect.target.visible = id == selectSuitId && SuitCfgArray.Instance.CheckSuitHasAction(id);
  728. }
  729. else if (_currentMenuType == ConstDressUpItemType.DONG_ZUO)
  730. {
  731. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.IsAction && MyDressUpHelper.dressUpObj.actionId == id;
  732. }
  733. else
  734. {
  735. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  736. bool isAction = MyDressUpHelper.dressUpObj.IsAction && SuitCfgArray.Instance.CheckActionContainsItem(id, MyDressUpHelper.dressUpObj.actionId);
  737. listItem.m_iconSelected.visible = isPutOn || isAction;
  738. }
  739. UI_PartsListItem.ProxyEnd();
  740. }
  741. }
  742. private void UpdateListSuitPartsSelected()
  743. {
  744. int count = _ui.m_partsList2.m_list.numChildren;
  745. for (int i = 0; i < count; i++)
  746. {
  747. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  748. int id = (int)listItem.target.data;
  749. bool isSuitSelect = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//可换部件是否穿戴
  750. bool isActionSelect = MyDressUpHelper.dressUpObj.actionId == id;
  751. listItem.m_iconSelected.visible = isSuitSelect || isActionSelect;
  752. UI_PartsListItem.ProxyEnd();
  753. }
  754. }
  755. private void UpdatePartsListSort()
  756. {
  757. if (_currentMenuType == 0) return;
  758. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  759. {
  760. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  761. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  762. {
  763. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  764. }
  765. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  766. {
  767. _currentList3 = SuitUtil.SortSuitListByLowRarity(_currentList3);
  768. }
  769. else
  770. {
  771. _currentList3.Reverse();
  772. }
  773. }
  774. else if (_currentMenuType == (int)ConstDressUpItemType.DONG_ZUO)
  775. {
  776. _currentList3 = DressUpMenuSuitDataManager.GetActionIDList();
  777. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  778. {
  779. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  780. }
  781. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  782. {
  783. _currentList3 = SuitUtil.SortSuitListByLowRarity(_currentList3);
  784. }
  785. else
  786. {
  787. _currentList3.Reverse();
  788. }
  789. }
  790. else
  791. {
  792. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  793. if (_rarityIndex == SORT_BY_HIGH_RARITY)
  794. {
  795. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighRarity(_currentList3);
  796. }
  797. else if (_rarityIndex == SORT_BY_LOW_RARITY)
  798. {
  799. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowRarity(_currentList3);
  800. }
  801. else
  802. {
  803. _currentList3.Reverse();
  804. }
  805. }
  806. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  807. {
  808. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  809. }
  810. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  811. {
  812. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  813. }
  814. _ui.m_partsList.m_list.RemoveChildrenToPool();
  815. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  816. }
  817. private void UpdateSuitPartsListSort()
  818. {
  819. if (_currentMenuType == 0) return;
  820. if (_isNormalSuitType)
  821. {
  822. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId));
  823. }
  824. else
  825. {
  826. _currentList4 = SuitCfgArray.Instance.GetOneSuitAllNotActionParts(_currentSuitId);
  827. _currentList4.Add(_currentSuitId);
  828. }
  829. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  830. {
  831. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  832. }
  833. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  834. {
  835. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  836. }
  837. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  838. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  839. }
  840. private void UpdateBtnAction()
  841. {
  842. // _ui.m_btnAction.visible = (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG) || this.currentListType == DressUpListType.List4;
  843. // if (_ui.m_btnAction.visible)
  844. // {
  845. //_ui.m_btnAction.grayed = !EquipDataCache.cacher.HasSuitActionRes;
  846. // }
  847. }
  848. private void OnClickBtnShow()
  849. {
  850. Timers.inst.Remove(SetBtnShowVisable);
  851. _ui.m_c1.selectedIndex = 0;
  852. _ui.m_btnHide.visible = true;
  853. _ui.m_btnShow.visible = false;
  854. _ui.m_loaShow.visible = false;
  855. }
  856. private void OnClickBtnHide()
  857. {
  858. _ui.m_c1.selectedIndex = 1;
  859. _ui.m_btnHide.visible = false;
  860. _ui.m_btnShow.visible = true;
  861. _ui.m_loaShow.visible = true;
  862. Timers.inst.Add(2f, 1, SetBtnShowVisable);
  863. }
  864. private void OnClickLoaShow()
  865. {
  866. _ui.m_btnShow.alpha = 1;
  867. _ui.m_btnShow.enabled = true;
  868. Timers.inst.Add(2f, 1, SetBtnShowVisable);
  869. }
  870. private void OnClickBtnPhoto()
  871. {
  872. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.PAI_ZHAO, 1);
  873. if (!ViewManager.Show<PhotographView>())
  874. {
  875. return;
  876. }
  877. _ui.target.visible = false;
  878. this._sceneObject.gameObject.SetActive(false);
  879. }
  880. private void OnClickBtnNext()
  881. {
  882. // if (!EquipDataCache.cacher.CheckPutOnFinish())
  883. // {
  884. // AlertUI.Show("只有换好衣服才能出门哦!")
  885. // .SetRightButton(true, "好的");
  886. // return;
  887. // }
  888. if (!ViewManager.Show<PhotographView>(this.viewData))
  889. {
  890. return;
  891. }
  892. _ui.target.visible = false;
  893. this._sceneObject.gameObject.SetActive(false);
  894. }
  895. private void UpdateScene()
  896. {
  897. _ui.target.visible = true;
  898. this._sceneObject.gameObject.SetActive(true);
  899. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
  900. }
  901. private void SetBtnShowVisable(object param)
  902. {
  903. _ui.m_btnShow.enabled = false;
  904. GTween.To(1, 0, 0.3f).SetTarget(_ui.m_btnShow, TweenPropType.Alpha);
  905. }
  906. private bool CheckListCount(int type)
  907. {
  908. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  909. {
  910. return DressUpMenuSuitDataManager.GetSuitIDList().Count > 0;
  911. }
  912. else
  913. {
  914. return DressUpMenuItemDataManager.getItemDatasByType(type).Count > 0;
  915. }
  916. }
  917. private void CheckGuide(object param)
  918. {
  919. if (GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0
  920. || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER) <= 0)
  921. {
  922. UpdateToCheckGuide(null);
  923. }
  924. else
  925. {
  926. Timers.inst.Remove(CheckGuide);
  927. }
  928. }
  929. protected override void UpdateToCheckGuide(object param)
  930. {
  931. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  932. if (listTypeItem_FreedomDress == null && GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0)
  933. {
  934. int len = _ui.m_comListType1.m_listType.numChildren;
  935. for (int i = 0; i < len; i++)
  936. {
  937. UI_TypeItem item = UI_TypeItem.Proxy(_ui.m_comListType1.m_listType.GetChildAt(i));
  938. if (item != null)
  939. {
  940. int menuID = (int)item.target.data;
  941. DressUpMenuItemCfg1 dressUpMenuItemCfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuID);
  942. if (dressUpMenuItemCfg1.type == ConstDressUpItemType.TAO_ZHUANG)
  943. {
  944. listTypeItem_FreedomDress = item;
  945. _ui.m_comListType1.m_listType.ScrollToView(i);
  946. break;
  947. }
  948. }
  949. UI_TypeItem.ProxyEnd();
  950. }
  951. }
  952. if (listTypeItem_FreedomDress != null) GuideController.TryGuide(listTypeItem_FreedomDress.target, ConstGuideId.FREEDOM_DRESS, 3, "套装分类里,可以查看集齐成套的服饰,点击一键换上。");
  953. GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.FREEDOM_DRESS, 4, "", 0);
  954. GuideController.TryGuide(_ui.m_btnSave, ConstGuideId.FREEDOM_DRESS, 5, "搭配好的服饰,可以保存到主界面显示。");
  955. GuideController.TryGuide(_ui.m_btnPhoto, ConstGuideId.FREEDOM_DRESS, 6, "辛苦搭配完,去拍个照片留念呀~~");
  956. GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.ENTER_CHAPTER, 2, "");
  957. }
  958. }
  959. }