ArenaDressUpFightView.cs 41 KB

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