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 DressUpListType currentListType;
  23. private int[] _currentList2;
  24. private GameObject _scenePrefab;
  25. private GameObject _sceneObject;
  26. private List<int> _currentList3 = new List<int>();
  27. private List<int> _currentList4 = new List<int>();
  28. private int _currentMenuType;
  29. private int _currentSuitId;
  30. // private StoryLevelCfg _levelCfg;
  31. // private StoryFightCfg _fightCfg;
  32. private const int SORT_BY_HIGH_SCORE = 0;
  33. private const int SORT_BY_LOW_SCORE = 1;
  34. private int _scoreIndex = SORT_BY_HIGH_SCORE;
  35. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  36. public override void Dispose()
  37. {
  38. if (_sceneObject != null)
  39. {
  40. GameObject.Destroy(_sceneObject);
  41. _sceneObject = null;
  42. }
  43. for (int i = 0; i < _listLongPress.Count; i++)
  44. {
  45. _listLongPress[i].Dispose();
  46. }
  47. // _dressUpData.Dispose();
  48. if (_ui != null)
  49. {
  50. _ui.Dispose();
  51. _ui = null;
  52. }
  53. base.Dispose();
  54. }
  55. protected override void Init()
  56. {
  57. base.Init();
  58. packageName = UI_ArenaDressUpFightUI.PACKAGE_NAME;
  59. _ui = UI_ArenaDressUpFightUI.Create();
  60. viewCom = _ui.target;
  61. isfullScreen = true;
  62. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArenaDressUpFight"));
  63. }
  64. protected override void OnInit()
  65. {
  66. base.OnInit();
  67. _ui.m_btnLastStep.visible = true;
  68. _ui.m_btnNextStep.visible = true;
  69. _ui.m_btnSearch.visible = true;
  70. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  71. _ui.m_partsListSearch.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  72. InitLists();
  73. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  74. _ui.m_partsListSearch.m_comboBoxRarity.onChanged.Add(OnSearchComboBoxRarityChanged);
  75. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  76. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  77. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  78. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  79. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  80. _ui.m_partsListSearch.m_list.onClickItem.Add(OnClickSearchPartsListItem);
  81. _ui.m_touchPad.onClick.Add(OnTouchPad);
  82. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  83. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  84. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  85. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  86. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  87. // _ui.m_comValueInfo.m_btnFightScoreRule.onClick.Add(OnBtnFightScoreRule);
  88. _ui.m_comValueInfo.GetChild("btnFightScoreRule").onClick.Add(OnBtnFightScoreRule);
  89. _ui.m_grhCloseComFightScore.onClick.Add(OnCloseComFightScore);
  90. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  91. _ui.m_partsList2.m_imgTop.visible = true;
  92. _ui.m_partsList.m_imgTop.visible = false;
  93. }
  94. protected override void AddEventListener()
  95. {
  96. base.AddEventListener();
  97. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  98. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  99. EventAgent.AddEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  100. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  101. }
  102. protected override void OnShown()
  103. {
  104. base.OnShown();
  105. _dataManager = ArenaDataManager.Instance;
  106. _roleData = _dataManager.DressupList[_dataManager.SelectThemeIndex];
  107. _itemList = new List<int>(_roleData.itemList);
  108. InstanceZonesDataManager.currentScoreType = _dataManager.ThemeList[_dataManager.SelectThemeIndex];
  109. InstanceZonesDataManager.currentFightTags = _dataManager.DressupList[_dataManager.SelectThemeIndex].tags;
  110. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  111. _ui.m_grhCloseComFightScore.visible = false;
  112. //一级菜单
  113. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  114. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  115. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  116. if (_ui.m_comListType1.m_listType.height > maxHeight)
  117. {
  118. _ui.m_comListType1.m_listType.height = maxHeight;
  119. }
  120. _ui.m_comListType1.target.x = _ui.target.width;
  121. _ui.m_comListType2.target.x = _ui.target.width;
  122. _ui.m_partsList.target.x = _ui.target.width;
  123. _ui.m_partsList2.target.x = _ui.target.width;
  124. this.showListType1();
  125. if (_sceneObject == null)
  126. {
  127. _sceneObject = GameObject.Instantiate(_scenePrefab);
  128. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
  129. // GameObject copyObj = _sceneObject.transform.Find("CopyRole").gameObject;
  130. // _dressUpData.setSceneObj(copyObj);
  131. }
  132. MyDressUpHelper.dressUpObj.PutOnItemList(_roleData.itemList);
  133. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  134. UpdateStepBtn(true);
  135. UpdateValueInfo();
  136. SendLog();
  137. Timers.inst.AddUpdate(CheckGuide);
  138. }
  139. protected override void OnHide()
  140. {
  141. base.OnHide();
  142. if (_sceneObject != null)
  143. {
  144. GameObject.Destroy(_sceneObject);
  145. _sceneObject = null;
  146. }
  147. // _dressUpData.TakeOffAll();
  148. // _dressUpData = null;
  149. DressUpMenuItemDataManager.Clear();
  150. MyDressUpHelper.ResetMemory();
  151. Timers.inst.Remove(CheckGuide);
  152. _ui.m_grhCloseComFightScore.visible = false;
  153. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  154. }
  155. protected override void RemoveEventListener()
  156. {
  157. base.RemoveEventListener();
  158. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  159. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  160. EventAgent.RemoveEventListener(ConstMessage.CARD_SELECTED, UpdateValueInfo);
  161. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  162. }
  163. private void OnClickBtnBack()
  164. {
  165. bool isSave = _itemList.Count == MyDressUpHelper.dressUpObj.itemList.Count;
  166. if (isSave)
  167. {
  168. for (int i = 0; i < _itemList.Count; i++)
  169. {
  170. int itemId = MyDressUpHelper.dressUpObj.itemList[i];
  171. if (_itemList.IndexOf(itemId) < 0)
  172. {
  173. isSave = false;
  174. break;
  175. }
  176. }
  177. }
  178. if (!isSave)
  179. {
  180. AlertUI.Show("当前穿搭尚未保存,是否确定退出?")
  181. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  182. {
  183. GoBackToView();
  184. });
  185. }
  186. else
  187. {
  188. GoBackToView();
  189. }
  190. }
  191. private void GoBackToView()
  192. {
  193. _roleData.itemList = _itemList;
  194. FightDataManager.Instance.SetItemScoreList(_roleData);
  195. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  196. ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  197. }
  198. private void OnBtnFightScoreRule()
  199. {
  200. _ui.m_grhCloseComFightScore.visible = true;
  201. }
  202. private void OnCloseComFightScore()
  203. {
  204. _ui.m_comValueInfo.GetController("c2").selectedIndex = 0;
  205. _ui.m_grhCloseComFightScore.visible = false;
  206. }
  207. private void OnClickBtnHome()
  208. {
  209. AlertUI.Show("是否返回?")
  210. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  211. {
  212. GameController.GoBackToMainView();
  213. });
  214. }
  215. private void UpdateValueInfo()
  216. {
  217. _roleData.itemList = MyDressUpHelper.dressUpObj.itemList;
  218. FightDataManager.Instance.SetItemScoreList(_roleData);
  219. ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData);
  220. ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo, _dataManager.SelectThemeIndex, _dataManager.DressupList);
  221. }
  222. private void OnClickListType1Item(EventContext context)
  223. {
  224. // GuideController.HideGuide();
  225. GObject typeItem = context.data as GObject;
  226. int order = (int)typeItem.data;
  227. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  228. if (item1.subMenusArr.Length > 0)
  229. {
  230. this.showListType2(item1.subMenusArr);
  231. }
  232. else
  233. {
  234. if (this.showListParts(item1.type) == false)
  235. {
  236. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  237. return;
  238. }
  239. this.showListParts(item1.type);
  240. }
  241. this.hideListType1();
  242. UpdateListPartsSelected();
  243. }
  244. private void OnClickListType2Item(EventContext context)
  245. {
  246. GObject typeItem = context.data as GObject;
  247. int order = (int)typeItem.data;
  248. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  249. if (this.showListParts(item2.type) == false)
  250. {
  251. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  252. return;
  253. }
  254. this.hideListType2();
  255. }
  256. private void OnClickSearchPartsListItem(EventContext context)
  257. {
  258. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  259. {
  260. return;
  261. }
  262. GObject listItem = context.data as GObject;
  263. int id = (int)listItem.data;
  264. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  265. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  266. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  267. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  268. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  269. {
  270. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  271. return;
  272. }
  273. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  274. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  275. UpdateStepBtn(true);
  276. // UpdateSearchListPartsSelected();
  277. UpdateValueInfo();
  278. }
  279. private void OnClickPartsListItem(EventContext context)
  280. {
  281. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  282. {
  283. return;
  284. }
  285. GObject listItem = context.data as GObject;
  286. int id = (int)listItem.data;
  287. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  288. {
  289. this.showListParts2(id);
  290. this.hideListParts();
  291. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  292. }
  293. else
  294. {
  295. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  296. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  297. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  298. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  299. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  300. {
  301. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  302. return;
  303. }
  304. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  305. }
  306. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  307. UpdateStepBtn(true);
  308. // UpdateListPartsSelected();
  309. // UpdateListSuitPartsSelected();
  310. UpdateValueInfo();
  311. }
  312. private void OnClickSuitPartsListItem(EventContext context)
  313. {
  314. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  315. {
  316. return;
  317. }
  318. GObject listItem = (GObject)context.data as GObject;
  319. int id = (int)listItem.data;
  320. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  321. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  322. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  323. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  324. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  325. {
  326. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  327. return;
  328. }
  329. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  330. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  331. UpdateStepBtn(true);
  332. // UpdateListSuitPartsSelected();
  333. UpdateValueInfo();
  334. }
  335. private void UpdateStepBtn(bool isAdd, int suitId = 0)
  336. {
  337. if (isAdd)
  338. {
  339. MyDressUpHelper.AddMemoryDressup();
  340. }
  341. _ui.m_btnLastStep.enabled = MyDressUpHelper.stepIndex > 0;
  342. _ui.m_btnNextStep.enabled = MyDressUpHelper.stepIndex < MyDressUpHelper.dressMemory.Count - 1;
  343. UpdateListPartsSelected();
  344. UpdateListSuitPartsSelected();
  345. UpdateSearchListPartsSelected();
  346. }
  347. private void OnLongPress(EventContext context)
  348. {
  349. LongPressGesture gesture = (LongPressGesture)context.sender;
  350. int itemId = (int)gesture.host.data;
  351. GoodsItemTipsController.ShowItemTips(itemId);
  352. }
  353. private void OnTouchPad()
  354. {
  355. if (this.currentListType == DressUpListType.List4)
  356. {
  357. this.hideListParts2();
  358. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  359. }
  360. else if (this.currentListType == DressUpListType.List3)
  361. {
  362. if (_currentList2 != null)
  363. {
  364. this.showListType2(_currentList2);
  365. }
  366. else
  367. {
  368. this.showListType1();
  369. }
  370. this.hideListParts();
  371. }
  372. else if (this.currentListType == DressUpListType.List2)
  373. {
  374. this.showListType1();
  375. this.hideListType2();
  376. }
  377. else if (this.currentListType == DressUpListType.List5)
  378. {
  379. this.showListType1();
  380. this.hideSearchListType();
  381. }
  382. }
  383. private void OnClickBtnDelete()
  384. {
  385. MyDressUpHelper.dressUpObj.TakeOffAll();
  386. _roleData.cardId = 0;
  387. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  388. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  389. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  390. UpdateStepBtn(true);
  391. // UpdateListPartsSelected();
  392. // UpdateListSuitPartsSelected();
  393. UpdateValueInfo();
  394. }
  395. private void OnClickBtnNext()
  396. {
  397. if (!MyDressUpHelper.CheckPutOnFinish())
  398. {
  399. AlertUI.Show("换好衣服才能进行下一步哦~").SetRightButton(true, "好的");
  400. }
  401. else
  402. {
  403. DressUpFinish();
  404. }
  405. }
  406. private async void DressUpFinish()
  407. {
  408. if (CardDataManager.GetCardListByRarity(0).Count > 0)
  409. {
  410. ViewManager.Show<StoryCardChoose>(InstanceZonesDataManager.currentScoreType);
  411. }
  412. else
  413. {
  414. bool result = await ArenaSproxy.ReqChangeArenaDressup(_dataManager.SelectThemeIndex, 0, MyDressUpHelper.dressUpObj.itemList);
  415. if (result)
  416. {
  417. _itemList = new List<int>(MyDressUpHelper.dressUpObj.itemList);
  418. PromptController.Instance.ShowFloatTextPrompt("保存成功");
  419. OnClickBtnBack();
  420. }
  421. }
  422. }
  423. // private void OnClickBtnRecommend()
  424. // {
  425. // if (this.currentListType == DressUpListType.List4)
  426. // {
  427. // this.hideListParts2();
  428. // this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  429. // }
  430. // MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(_currentSuitId);
  431. // MyDressUpHelper.PutOnRecommendItems2();
  432. // _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  433. // UpdateListPartsSelected();
  434. // UpdateListSuitPartsSelected();
  435. // }
  436. private void InitLists()
  437. {
  438. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  439. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  440. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  441. _ui.m_partsListSearch.m_list.itemRenderer = ListPartsItem;
  442. listType1X = _ui.m_comListType1.target.x;
  443. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  444. //一级菜单
  445. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  446. }
  447. private void showListType1()
  448. {
  449. _currentList2 = null;
  450. currentListType = DressUpListType.List1;
  451. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  452. GTween.To(_ui.target.width, listType1X, 0.5f)
  453. .SetTarget(_ui.m_comListType1.target)
  454. .OnUpdate((GTweener t) =>
  455. {
  456. _ui.m_comListType1.target.x = t.value.x;
  457. });
  458. }
  459. private void hideListType1()
  460. {
  461. GTween.To(listType1X, _ui.target.width, 0.5f)
  462. .SetTarget(_ui.m_comListType1.target)
  463. .OnUpdate((GTweener t) =>
  464. {
  465. _ui.m_comListType1.target.x = t.value.x;
  466. });
  467. }
  468. private void showListType2(int[] menuStrArr = null)
  469. {
  470. currentListType = DressUpListType.List2;
  471. if (menuStrArr != null && menuStrArr.Length > 0)
  472. {
  473. int len = menuStrArr.Length;
  474. _currentList2 = menuStrArr.Clone() as int[];
  475. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  476. _ui.m_comListType2.m_listType.numItems = len;
  477. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  478. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  479. if (_ui.m_comListType2.m_listType.height > maxHeight)
  480. {
  481. _ui.m_comListType2.m_listType.height = maxHeight;
  482. }
  483. }
  484. GTween.To(_ui.target.width, listType1X, 0.5f)
  485. .SetTarget(_ui.m_comListType2.target)
  486. .OnUpdate((GTweener t) =>
  487. {
  488. _ui.m_comListType2.target.x = t.value.x;
  489. });
  490. }
  491. private void hideListType2()
  492. {
  493. GTween.To(listType1X, _ui.target.width, 0.5f)
  494. .SetTarget(_ui.m_comListType2.target)
  495. .OnUpdate((GTweener t) =>
  496. {
  497. _ui.m_comListType2.target.x = t.value.x;
  498. });
  499. }
  500. private bool showListParts(int type, bool selectItem = false)
  501. {
  502. _currentMenuType = type;
  503. UpdatePartsListSort();
  504. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  505. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  506. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  507. if (_ui.m_partsList.m_list.height > maxHeight)
  508. {
  509. _ui.m_partsList.m_list.height = maxHeight;
  510. }
  511. if (selectItem)
  512. {
  513. int itemId = MyDressUpHelper.dressUpObj.GetItemIdBuyType(_currentMenuType);
  514. if (itemId > 0)
  515. {
  516. int index = _currentList3.IndexOf(itemId);
  517. if (index >= 0 && index < _ui.m_partsList.m_list.numItems)
  518. {
  519. _ui.m_partsList.m_list.ScrollToView(index);
  520. }
  521. }
  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. }