ArenaDressUpFightView.cs 41 KB

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