ArenaDressUpFightView.cs 41 KB

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