ArenaDressUpFightView.cs 40 KB

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