DressUpView.cs 37 KB

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