ArenaDressUpFightView.cs 41 KB

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