ArenaDressUpFightView.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996
  1. using UI.DressUp;
  2. using FairyGUI;
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. namespace GFGGame
  6. {
  7. public class ArenaDressUpFightView : BaseView
  8. {
  9. private UI_ArenaDressUpFightUI _ui;
  10. // private DressUpObj _dressUpData = new DressUpObj();
  11. private ArenaDataManager _dataManager;
  12. private FightData _roleData;
  13. public List<int> _itemList;//记录打开界面时的穿戴数据(保存后会更新)
  14. private float listType1X = 0;
  15. private float partsListX = 0;
  16. private float partsListScrollingPosY = 0;
  17. private DressUpListType currentListType;
  18. private int[] _currentList2;
  19. private GameObject _scenePrefab;
  20. private GameObject _sceneObject;
  21. private List<int> _currentList3 = new List<int>();
  22. private List<int> _currentList4 = new List<int>();
  23. private int _currentMenuType;
  24. private int _currentSuitId;
  25. // private StoryLevelCfg _levelCfg;
  26. // private StoryFightCfg _fightCfg;
  27. private const int SORT_BY_HIGH_SCORE = 0;
  28. private const int SORT_BY_LOW_SCORE = 1;
  29. private int _scoreIndex = SORT_BY_HIGH_SCORE;
  30. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  31. public override void Dispose()
  32. {
  33. if (_sceneObject != null)
  34. {
  35. GameObject.Destroy(_sceneObject);
  36. _sceneObject = null;
  37. }
  38. for (int i = 0; i < _listLongPress.Count; i++)
  39. {
  40. _listLongPress[i].Dispose();
  41. }
  42. // _dressUpData.Dispose();
  43. if (_ui != null)
  44. {
  45. _ui.Dispose();
  46. _ui = null;
  47. }
  48. base.Dispose();
  49. }
  50. protected override void Init()
  51. {
  52. base.Init();
  53. packageName = UI_ArenaDressUpFightUI.PACKAGE_NAME;
  54. _ui = UI_ArenaDressUpFightUI.Create();
  55. viewCom = _ui.target;
  56. isfullScreen = true;
  57. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArenaDressUpFight"));
  58. }
  59. protected override void OnInit()
  60. {
  61. base.OnInit();
  62. _ui.m_btnLastStep.visible = true;
  63. _ui.m_btnNextStep.visible = true;
  64. _ui.m_btnSearch.visible = true;
  65. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  66. _ui.m_partsListSearch.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  67. InitLists();
  68. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  69. _ui.m_partsListSearch.m_comboBoxRarity.onChanged.Add(OnSearchComboBoxRarityChanged);
  70. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  71. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  72. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  73. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  74. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  75. _ui.m_partsListSearch.m_list.onClickItem.Add(OnClickSearchPartsListItem);
  76. _ui.m_touchPad.onClick.Add(OnTouchPad);
  77. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  78. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  79. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  80. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  81. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  82. // _ui.m_comValueInfo.m_btnFightScoreRule.onClick.Add(OnBtnFightScoreRule);
  83. _ui.m_comValueInfo.GetChild("btnFightScoreRule").onClick.Add(OnBtnFightScoreRule);
  84. _ui.m_grhCloseComFightScore.onClick.Add(OnCloseComFightScore);
  85. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  86. _ui.m_partsList2.m_imgTop.visible = true;
  87. _ui.m_partsList.m_imgTop.visible = false;
  88. }
  89. protected override void AddEventListener()
  90. {
  91. base.AddEventListener();
  92. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  93. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  94. EventAgent.AddEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  95. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  96. }
  97. protected override void RemoveEventListener()
  98. {
  99. base.RemoveEventListener();
  100. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  101. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  102. EventAgent.RemoveEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  103. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  104. }
  105. protected override void OnShown()
  106. {
  107. base.OnShown();
  108. _dataManager = ArenaDataManager.Instance;
  109. _roleData = _dataManager.DressupList[_dataManager.SelectThemeIndex];
  110. _itemList = new List<int>(_roleData.itemList);
  111. InstanceZonesDataManager.currentScoreType = _dataManager.ThemeList[_dataManager.SelectThemeIndex];
  112. InstanceZonesDataManager.currentFightTags = _dataManager.DressupList[_dataManager.SelectThemeIndex].tags;
  113. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  114. _ui.m_grhCloseComFightScore.visible = false;
  115. //一级菜单
  116. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  117. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  118. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  119. if (_ui.m_comListType1.m_listType.height > maxHeight)
  120. {
  121. _ui.m_comListType1.m_listType.height = maxHeight;
  122. }
  123. _ui.m_comListType1.target.x = _ui.target.width;
  124. _ui.m_comListType2.target.x = _ui.target.width;
  125. _ui.m_partsList.target.x = _ui.target.width;
  126. _ui.m_partsList2.target.x = _ui.target.width;
  127. _ui.m_partsListSearch.target.x = _ui.target.width;
  128. this.showListType1();
  129. if (_sceneObject == null)
  130. {
  131. _sceneObject = GameObject.Instantiate(_scenePrefab);
  132. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
  133. // GameObject copyObj = _sceneObject.transform.Find("CopyRole").gameObject;
  134. // _dressUpData.setSceneObj(copyObj);
  135. }
  136. MyDressUpHelper.dressUpObj.PutOnItemList(_roleData.itemList);
  137. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  138. UpdateStepBtn(true);
  139. UpdateValueInfo();
  140. SendLog();
  141. }
  142. protected override void OnHide()
  143. {
  144. base.OnHide();
  145. if (_sceneObject != null)
  146. {
  147. GameObject.Destroy(_sceneObject);
  148. _sceneObject = null;
  149. }
  150. DressUpMenuItemDataManager.Clear();
  151. MyDressUpHelper.ResetMemory();
  152. _ui.m_grhCloseComFightScore.visible = false;
  153. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  154. }
  155. private void OnClickBtnBack()
  156. {
  157. bool isSave = _itemList.Count == MyDressUpHelper.dressUpObj.itemList.Count;
  158. if (isSave)
  159. {
  160. for (int i = 0; i < _itemList.Count; i++)
  161. {
  162. int itemId = MyDressUpHelper.dressUpObj.itemList[i];
  163. if (_itemList.IndexOf(itemId) < 0)
  164. {
  165. isSave = false;
  166. break;
  167. }
  168. }
  169. }
  170. if (!isSave)
  171. {
  172. AlertUI.Show("当前穿搭尚未保存,是否确定退出?")
  173. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  174. {
  175. GoBackToView();
  176. });
  177. }
  178. else
  179. {
  180. GoBackToView();
  181. }
  182. }
  183. private void GoBackToView()
  184. {
  185. _roleData.itemList = _itemList;
  186. FightDataManager.Instance.SetItemScoreList(_roleData);
  187. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  188. ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  189. }
  190. private void OnBtnFightScoreRule()
  191. {
  192. _ui.m_grhCloseComFightScore.visible = true;
  193. }
  194. private void OnCloseComFightScore()
  195. {
  196. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  197. _ui.m_grhCloseComFightScore.visible = false;
  198. }
  199. private void OnClickBtnHome()
  200. {
  201. AlertUI.Show("是否返回?")
  202. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  203. {
  204. GameController.GoBackToMainView();
  205. });
  206. }
  207. private void UpdateValueInfo()
  208. {
  209. _roleData.itemList = MyDressUpHelper.dressUpObj.itemList;
  210. FightDataManager.Instance.SetItemScoreList(_roleData);
  211. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  212. ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo, _dataManager.SelectThemeIndex, _dataManager.DressupList);
  213. }
  214. private void OnClickListType1Item(EventContext context)
  215. {
  216. // GuideController.HideGuide();
  217. GObject typeItem = context.data as GObject;
  218. int order = (int)typeItem.data;
  219. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  220. if (item1.subMenusArr.Length > 0)
  221. {
  222. this.showListType2(item1.subMenusArr);
  223. }
  224. else
  225. {
  226. if (this.showListParts(item1.type) == false)
  227. {
  228. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  229. return;
  230. }
  231. this.showListParts(item1.type);
  232. }
  233. this.hideListType1();
  234. UpdateListPartsSelected();
  235. }
  236. private void OnClickListType2Item(EventContext context)
  237. {
  238. GObject typeItem = context.data as GObject;
  239. int order = (int)typeItem.data;
  240. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  241. if (this.showListParts(item2.type) == false)
  242. {
  243. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  244. return;
  245. }
  246. this.hideListType2();
  247. }
  248. private void OnClickSearchPartsListItem(EventContext context)
  249. {
  250. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  251. {
  252. return;
  253. }
  254. GObject listItem = context.data as GObject;
  255. int id = (int)listItem.data;
  256. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  257. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  258. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  259. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  260. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  261. {
  262. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  263. return;
  264. }
  265. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  266. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  267. UpdateStepBtn(true);
  268. // UpdateSearchListPartsSelected();
  269. UpdateValueInfo();
  270. }
  271. private void OnClickPartsListItem(EventContext context)
  272. {
  273. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  274. {
  275. return;
  276. }
  277. GObject listItem = context.data as GObject;
  278. int id = (int)listItem.data;
  279. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  280. {
  281. partsListScrollingPosY = _ui.m_partsList.m_list.scrollPane.scrollingPosY;
  282. this.showListParts2(id);
  283. this.hideListParts();
  284. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  285. }
  286. else
  287. {
  288. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  289. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  290. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  291. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  292. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  293. {
  294. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  295. return;
  296. }
  297. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  298. }
  299. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  300. UpdateStepBtn(true);
  301. // UpdateListPartsSelected();
  302. // UpdateListSuitPartsSelected();
  303. UpdateValueInfo();
  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. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  314. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  315. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  316. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  317. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  318. {
  319. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  320. return;
  321. }
  322. if (!DressUpMenuItemDataManager.CheckHasItem(id))
  323. {
  324. PromptController.Instance.ShowFloatTextPrompt("还未获得这件装扮");
  325. return;
  326. }
  327. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  328. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  329. UpdateStepBtn(true);
  330. // UpdateListSuitPartsSelected();
  331. UpdateValueInfo();
  332. }
  333. private void UpdateStepBtn(bool isAdd, int suitId = 0)
  334. {
  335. if (isAdd)
  336. {
  337. MyDressUpHelper.AddMemoryDressup();
  338. }
  339. _ui.m_btnLastStep.enabled = MyDressUpHelper.stepIndex > 0;
  340. _ui.m_btnNextStep.enabled = MyDressUpHelper.stepIndex < MyDressUpHelper.dressMemory.Count - 1;
  341. UpdateListPartsSelected();
  342. UpdateListSuitPartsSelected();
  343. UpdateSearchListPartsSelected();
  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. }
  364. else
  365. {
  366. this.showListType1();
  367. }
  368. this.hideListParts();
  369. }
  370. else if (this.currentListType == DressUpListType.List2)
  371. {
  372. this.showListType1();
  373. this.hideListType2();
  374. }
  375. else if (this.currentListType == DressUpListType.List5)
  376. {
  377. this.showListType1();
  378. this.hideSearchListType();
  379. }
  380. }
  381. private void OnClickBtnDelete()
  382. {
  383. MyDressUpHelper.dressUpObj.TakeOffAll();
  384. _roleData.cardId = 0;
  385. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  386. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  387. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  388. UpdateStepBtn(true);
  389. // UpdateListPartsSelected();
  390. // UpdateListSuitPartsSelected();
  391. UpdateValueInfo();
  392. }
  393. private void OnClickBtnNext()
  394. {
  395. // if (!MyDressUpHelper.CheckPutOnFinish())
  396. // {
  397. // AlertUI.Show("换好衣服才能进行下一步哦~").SetRightButton(true, "好的");
  398. // }
  399. // else
  400. // {
  401. DressUpFinish();
  402. // }
  403. }
  404. private async void DressUpFinish()
  405. {
  406. if (CardDataManager.GetCardListByRarity(0).Count > 0)
  407. {
  408. ViewManager.Show<StoryCardChoose>(InstanceZonesDataManager.currentScoreType);
  409. }
  410. else
  411. {
  412. bool result = await ArenaSproxy.ReqChangeArenaDressup(_dataManager.SelectThemeIndex, 0, MyDressUpHelper.dressUpObj.itemList);
  413. if (result)
  414. {
  415. _itemList = new List<int>(MyDressUpHelper.dressUpObj.itemList);
  416. PromptController.Instance.ShowFloatTextPrompt("保存成功");
  417. OnClickBtnBack();
  418. }
  419. }
  420. }
  421. // private void OnClickBtnRecommend()
  422. // {
  423. // if (this.currentListType == DressUpListType.List4)
  424. // {
  425. // this.hideListParts2();
  426. // this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  427. // }
  428. // MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(_currentSuitId);
  429. // MyDressUpHelper.PutOnRecommendItems2();
  430. // _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  431. // UpdateListPartsSelected();
  432. // UpdateListSuitPartsSelected();
  433. // }
  434. private void InitLists()
  435. {
  436. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  437. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  438. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  439. _ui.m_partsListSearch.m_list.itemRenderer = ListPartsItem;
  440. listType1X = _ui.m_comListType1.target.x;
  441. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  442. //一级菜单
  443. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  444. }
  445. private void showListType1()
  446. {
  447. _currentList2 = null;
  448. currentListType = DressUpListType.List1;
  449. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  450. GTween.To(_ui.target.width, listType1X, 0.5f)
  451. .SetTarget(_ui.m_comListType1.target)
  452. .OnUpdate((GTweener t) =>
  453. {
  454. _ui.m_comListType1.target.x = t.value.x;
  455. });
  456. }
  457. private void hideListType1()
  458. {
  459. GTween.To(listType1X, _ui.target.width, 0.5f)
  460. .SetTarget(_ui.m_comListType1.target)
  461. .OnUpdate((GTweener t) =>
  462. {
  463. _ui.m_comListType1.target.x = t.value.x;
  464. });
  465. }
  466. private void showListType2(int[] menuStrArr = null)
  467. {
  468. currentListType = DressUpListType.List2;
  469. if (menuStrArr != null && menuStrArr.Length > 0)
  470. {
  471. int len = menuStrArr.Length;
  472. _currentList2 = menuStrArr.Clone() as int[];
  473. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  474. _ui.m_comListType2.m_listType.numItems = len;
  475. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  476. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  477. if (_ui.m_comListType2.m_listType.height > maxHeight)
  478. {
  479. _ui.m_comListType2.m_listType.height = maxHeight;
  480. }
  481. }
  482. GTween.To(_ui.target.width, listType1X, 0.5f)
  483. .SetTarget(_ui.m_comListType2.target)
  484. .OnUpdate((GTweener t) =>
  485. {
  486. _ui.m_comListType2.target.x = t.value.x;
  487. });
  488. }
  489. private void hideListType2()
  490. {
  491. GTween.To(listType1X, _ui.target.width, 0.5f)
  492. .SetTarget(_ui.m_comListType2.target)
  493. .OnUpdate((GTweener t) =>
  494. {
  495. _ui.m_comListType2.target.x = t.value.x;
  496. });
  497. }
  498. private bool showListParts(int type, bool selectItem = false)
  499. {
  500. _currentMenuType = type;
  501. UpdatePartsListSort();
  502. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  503. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  504. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  505. if (_ui.m_partsList.m_list.height > maxHeight)
  506. {
  507. _ui.m_partsList.m_list.height = maxHeight;
  508. }
  509. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  510. {
  511. _ui.m_partsList.m_list.scrollPane.SetPosY(partsListScrollingPosY, false);
  512. partsListScrollingPosY = 0;
  513. }
  514. currentListType = DressUpListType.List3;
  515. GTween.To(_ui.target.width, partsListX, 0.5f)
  516. .SetTarget(_ui.m_partsList)
  517. .OnUpdate((GTweener t) =>
  518. {
  519. _ui.m_partsList.target.x = t.value.x;
  520. });
  521. UpdateListPartsSelected();
  522. return true;
  523. }
  524. private void OnComboBoxRarityChanged()
  525. {
  526. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  527. this.UpdatePartsListSort();
  528. }
  529. private void OnSearchComboBoxRarityChanged()
  530. {
  531. _scoreIndex = _ui.m_partsListSearch.m_comboBoxRarity.selectedIndex;
  532. this.UpdateSearchList();
  533. }
  534. private void UpdatePartsListSort()
  535. {
  536. if (_currentMenuType == 0) return;
  537. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  538. {
  539. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  540. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  541. {
  542. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  543. }
  544. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  545. {
  546. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  547. }
  548. else
  549. {
  550. _currentList3.Reverse();
  551. }
  552. }
  553. else
  554. {
  555. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  556. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  557. {
  558. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3);
  559. }
  560. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  561. {
  562. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3);
  563. }
  564. else
  565. {
  566. _currentList3.Reverse();
  567. }
  568. }
  569. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  570. {
  571. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  572. }
  573. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  574. {
  575. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  576. }
  577. _ui.m_partsList.m_list.RemoveChildrenToPool();
  578. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  579. }
  580. private void UpdateSuitPartsListSort()
  581. {
  582. if (_currentMenuType == 0) return;
  583. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId, true));
  584. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  585. {
  586. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  587. }
  588. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  589. {
  590. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  591. }
  592. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  593. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  594. }
  595. private void hideListParts()
  596. {
  597. GTween.To(partsListX, _ui.target.width, 0.5f)
  598. .SetTarget(_ui.m_partsList)
  599. .OnUpdate((GTweener t) =>
  600. {
  601. _ui.m_partsList.target.x = t.value.x;
  602. });
  603. }
  604. private void showListParts2(int suitId)
  605. {
  606. _currentSuitId = suitId;
  607. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  608. this.UpdateSuitPartsListSort();
  609. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  610. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  611. if (_ui.m_partsList2.m_list.height > maxHeight)
  612. {
  613. _ui.m_partsList2.m_list.height = maxHeight;
  614. }
  615. currentListType = DressUpListType.List4;
  616. GTween.To(_ui.target.width, partsListX, 0.5f)
  617. .SetTarget(_ui.m_partsList2)
  618. .OnUpdate((GTweener t) =>
  619. {
  620. _ui.m_partsList2.target.x = t.value.x;
  621. });
  622. }
  623. private void hideListParts2()
  624. {
  625. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  626. GTween.To(partsListX, _ui.target.width, 0.5f)
  627. .SetTarget(_ui.m_partsList2)
  628. .OnUpdate((GTweener t) =>
  629. {
  630. _ui.m_partsList2.target.x = t.value.x;
  631. });
  632. }
  633. private void showSearchListType()
  634. {
  635. // _currentList2 = null;
  636. currentListType = DressUpListType.List5;
  637. GTween.To(_ui.target.width, partsListX, 0.5f)
  638. .SetTarget(_ui.m_partsListSearch.target)
  639. .OnUpdate((GTweener t) =>
  640. {
  641. _ui.m_partsListSearch.target.x = t.value.x;
  642. });
  643. }
  644. private void hideSearchListType()
  645. {
  646. GTween.To(partsListX, _ui.target.width, 0.5f)
  647. .SetTarget(_ui.m_partsListSearch.target)
  648. .OnUpdate((GTweener t) =>
  649. {
  650. _ui.m_partsListSearch.target.x = t.value.x;
  651. });
  652. }
  653. /*****************************************************************************************************/
  654. private void DressResetSerch()
  655. {
  656. if (currentListType == DressUpListType.List5)
  657. {
  658. OnTouchPad();
  659. }
  660. }
  661. private void UpdateSerch(EventContext context)
  662. {
  663. if (context.data.ToString() == ConstMessage.DRESS_SEARCH)
  664. {
  665. _currentList3 = DressUpMenuItemDataManager.DressSearch(false);
  666. }
  667. else if (context.data.ToString() == ConstMessage.DRESS_FILTER)
  668. {
  669. _currentList3 = DressUpMenuItemDataManager.DressFilter(false);
  670. }
  671. ViewManager.Hide<ModalStatusView>();
  672. UpdateSearchList();
  673. if (currentListType != DressUpListType.List5)
  674. {
  675. hideListParts();
  676. hideListParts2();
  677. hideListType1();
  678. hideListType2();
  679. showSearchListType();
  680. }
  681. _currentMenuType = 0;
  682. }
  683. private void UpdateSearchList()
  684. {
  685. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  686. {
  687. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3, true);
  688. }
  689. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  690. {
  691. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3, true);
  692. }
  693. _currentMenuType = 0;
  694. _ui.m_partsListSearch.m_list.numItems = _currentList3.Count; ;
  695. }
  696. private void ListType1Item(int index, GObject item)
  697. {
  698. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  699. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  700. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  701. typeItem.m_txtname.text = item1.name;
  702. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  703. typeItem.target.data = item1.id;
  704. typeItem.m_imgNeed.visible = false;
  705. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  706. UI.DressUp.UI_TypeItem.ProxyEnd();
  707. }
  708. private void ListType2Item(int index, GObject item)
  709. {
  710. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  711. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  712. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  713. typeItem.m_txtname.text = item2.name;
  714. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  715. typeItem.target.data = item2.id;
  716. // var subType = ItemUtilCS.GetItemSubType(_fightCfg.needItemId);
  717. typeItem.m_imgNeed.visible = false;
  718. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  719. UI.DressUp.UI_TypeItem.ProxyEnd();
  720. }
  721. private void ListPartsItem(int index, GObject item)
  722. {
  723. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  724. int id = (int)_currentList3[index];
  725. string iconRes = "";
  726. string partName = "";
  727. string ext = "png";
  728. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  729. {
  730. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  731. iconRes = suitCfg.res;
  732. partName = suitCfg.name;
  733. listItem.m_iconSelected.visible = false;
  734. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  735. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  736. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  737. listItem.m_imgNew.visible = false;
  738. }
  739. else
  740. {
  741. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  742. iconRes = itemCfg.res;
  743. partName = itemCfg.name;
  744. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  745. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _roleData.tags);
  746. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  747. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  748. listItem.m_imgNew.visible = isNew;
  749. if (isNew)
  750. {
  751. ItemProxy.ReqSetItemRead(id).Coroutine();
  752. }
  753. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  754. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  755. }
  756. if (listItem.target.data == null)
  757. {
  758. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  759. longPressGesture.once = true;
  760. longPressGesture.onAction.Add(OnLongPress);
  761. _listLongPress.Add(longPressGesture);
  762. }
  763. listItem.m_btnAni.visible = false;
  764. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  765. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + InstanceZonesDataManager.currentScoreType;
  766. listItem.m_txtTitle.text = partName;
  767. listItem.target.data = id;
  768. listItem.m_imgNeed.visible = false;
  769. UI_PartsListItem.ProxyEnd();
  770. }
  771. private void ListParts2Item(int index, GObject item)
  772. {
  773. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  774. int id = (int)_currentList4[index];
  775. string iconRes = "";
  776. string partName = "";
  777. string ext = "png";
  778. if (listItem.target.data == null)
  779. {
  780. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  781. longPressGesture.once = true;
  782. longPressGesture.onAction.Add(OnLongPress);
  783. _listLongPress.Add(longPressGesture);
  784. }
  785. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  786. iconRes = itemCfg.res;
  787. partName = itemCfg.name;
  788. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  789. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  790. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  791. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  792. listItem.m_ScoreType.visible = true;
  793. // int mainScore;
  794. // int mainValuel;
  795. // ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  796. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + InstanceZonesDataManager.currentScoreType);
  797. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _dataManager.DressupList[_dataManager.SelectThemeIndex].tags);
  798. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  799. listItem.m_txtTitle.text = partName;
  800. listItem.target.data = id;
  801. // listItem.m_txtScore.visible = false;
  802. //listItem.m_ScoreType.visible = true;
  803. listItem.m_imgNeed.visible = false;
  804. listItem.m_btnAni.visible = false;
  805. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  806. listItem.m_imgNew.visible = isNew;
  807. if (isNew)
  808. {
  809. ItemProxy.ReqSetItemRead(id).Coroutine();
  810. }
  811. UI_PartsListItem.ProxyEnd();
  812. }
  813. private void UpdateSearchListPartsSelected()
  814. {
  815. int count = _ui.m_partsListSearch.m_list.numChildren;
  816. int suitId = MyDressUpHelper.dressUpObj.suitId;
  817. for (int i = 0; i < count; i++)
  818. {
  819. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsListSearch.m_list.GetChildAt(i));
  820. int id = (int)listItem.target.data;
  821. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  822. {
  823. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  824. }
  825. else
  826. {
  827. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  828. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  829. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  830. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  831. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  832. }
  833. UI_PartsListItem.ProxyEnd();
  834. }
  835. }
  836. private void UpdateListPartsSelected()
  837. {
  838. GList list;
  839. if (_ui.m_partsList.target.x == partsListX)
  840. {
  841. list = _ui.m_partsList.m_list;
  842. }
  843. else if (_ui.m_partsListSearch.target.x == partsListX)
  844. {
  845. list = _ui.m_partsListSearch.m_list;
  846. }
  847. else
  848. {
  849. return;
  850. }
  851. int count = list.numChildren;
  852. int suitId = MyDressUpHelper.dressUpObj.suitId;
  853. for (int i = 0; i < count; i++)
  854. {
  855. UI_PartsListItem listItem = UI_PartsListItem.Proxy(list.GetChildAt(i));
  856. int id = (int)listItem.target.data;
  857. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  858. {
  859. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  860. }
  861. else
  862. {
  863. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  864. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  865. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  866. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  867. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  868. }
  869. UI_PartsListItem.ProxyEnd();
  870. }
  871. }
  872. private void UpdateListSuitPartsSelected()
  873. {
  874. int count = _ui.m_partsList2.m_list.numChildren;
  875. int suitId = MyDressUpHelper.dressUpObj.suitId;
  876. for (int i = 0; i < count; i++)
  877. {
  878. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  879. int id = (int)listItem.target.data;
  880. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  881. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  882. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  883. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  884. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  885. UI_PartsListItem.ProxyEnd();
  886. }
  887. }
  888. private void OnClickBtnSearch()
  889. {
  890. ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
  891. }
  892. private void OnClickBtnLastStep()
  893. {
  894. if (!MyDressUpHelper.OnClickBtnLastStep()) return;
  895. UpdateStepBtn(false);
  896. }
  897. private void OnClickBtnNextStep()
  898. {
  899. if (!MyDressUpHelper.OnClickBtnNextStep()) return;
  900. UpdateStepBtn(false);
  901. }
  902. private void SendLog()
  903. {
  904. }
  905. }
  906. }