ArenaDressUpFightView.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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 ArenaDataManager _dataManager;
  17. public FightRoleData _roleData;
  18. // private int _fightID;
  19. // private int _levelID;
  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. if (_ui != null)
  48. {
  49. _ui.Dispose();
  50. _ui = null;
  51. }
  52. base.Dispose();
  53. }
  54. protected override void Init()
  55. {
  56. base.Init();
  57. packageName = UI_ArenaDressUpFightUI.PACKAGE_NAME;
  58. _ui = UI_ArenaDressUpFightUI.Create();
  59. viewCom = _ui.target;
  60. isfullScreen = true;
  61. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUpFight"));
  62. }
  63. protected override void OnInit()
  64. {
  65. base.OnInit();
  66. _ui.m_btnSearch.visible = true;
  67. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  68. InitLists();
  69. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  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_touchPad.onClick.Add(OnTouchPad);
  76. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  77. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  78. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  79. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  80. _ui.m_partsList2.m_imgTop.visible = true;
  81. _ui.m_partsList.m_imgTop.visible = false;
  82. }
  83. protected override void AddEventListener()
  84. {
  85. base.AddEventListener();
  86. // EventAgent.AddEventListener(ConstMessage.CARD_CHOOSE, StartCalculateScore);
  87. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  88. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  89. // EventAgent.AddEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateValueInfo);
  90. }
  91. protected override void OnShown()
  92. {
  93. base.OnShown();
  94. _dataManager = ArenaDataManager.Instance;
  95. _roleData = _dataManager.DressupList[_dataManager.SelectThemeIndex];
  96. InstanceZonesDataManager.currentScoreType = _dataManager.ThemeList[_dataManager.SelectThemeIndex];
  97. InstanceZonesDataManager.currentFightTags = _dataManager.DressupList[_dataManager.SelectThemeIndex].tags;
  98. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  99. //一级菜单
  100. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  101. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  102. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  103. if (_ui.m_comListType1.m_listType.height > maxHeight)
  104. {
  105. _ui.m_comListType1.m_listType.height = maxHeight;
  106. }
  107. _ui.m_comListType1.target.x = _ui.target.width;
  108. _ui.m_comListType2.target.x = _ui.target.width;
  109. _ui.m_partsList.target.x = _ui.target.width;
  110. _ui.m_partsList2.target.x = _ui.target.width;
  111. this.showListType1();
  112. if (_sceneObject == null)
  113. {
  114. _sceneObject = GameObject.Instantiate(_scenePrefab);
  115. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
  116. MyDressUpHelper.dressUpObj.PutOnDefaultDressUpData();
  117. }
  118. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  119. UpdateValueInfo();
  120. SendLog();
  121. Timers.inst.AddUpdate(CheckGuide);
  122. }
  123. protected override void OnHide()
  124. {
  125. base.OnHide();
  126. if (_sceneObject != null)
  127. {
  128. GameObject.Destroy(_sceneObject);
  129. _sceneObject = null;
  130. }
  131. DressUpMenuItemDataManager.Clear();
  132. Timers.inst.Remove(CheckGuide);
  133. }
  134. protected override void RemoveEventListener()
  135. {
  136. base.RemoveEventListener();
  137. // EventAgent.RemoveEventListener(ConstMessage.CARD_CHOOSE, StartCalculateScore);
  138. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
  139. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdatePartsListSort);
  140. // EventAgent.RemoveEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateValueInfo);
  141. }
  142. private void OnClickBtnBack()
  143. {
  144. if (!MyDressUpHelper.CheckPutOnFinish())
  145. {
  146. AlertUI.Show("当前主题尚未穿戴完整,是否确定退出?")
  147. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  148. {
  149. ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  150. });
  151. }
  152. }
  153. private void OnClickBtnHome()
  154. {
  155. AlertUI.Show("是否返回?")
  156. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  157. {
  158. GameController.GoBackToMainView();
  159. });
  160. }
  161. private void UpdateValueInfo()
  162. {
  163. UI_ComValueInfo comValueInfo = UI_ComValueInfo.Proxy(_ui.m_comValueInfo);
  164. comValueInfo.m_scoreType.url = "ui://CommonGame/kp_sx_" + InstanceZonesDataManager.currentScoreType;
  165. comValueInfo.m_txtScore.text = FightDataManager.Instance.GetScore(_roleData.itemScoreList).ToString();
  166. comValueInfo.m_txtFightScore.text = FightDataManager.Instance.GetArenaRoleFightScore(_roleData).ToString();
  167. comValueInfo.m_txtTagScore.text = FightDataManager.Instance.GetTagsScore(_roleData.itemList, _roleData.tags).ToString();
  168. int count = FightDataManager.Instance.GetTagsCount(_roleData.itemList, _roleData.tags);
  169. comValueInfo.m_c1.selectedIndex = Math.Min(count, ArenaTagCfgArray.Instance.dataArray.Length);
  170. if (_roleData.tags.Length > 0)
  171. {
  172. UI_ComTag item = UI_ComTag.Proxy(comValueInfo.m_comTag);
  173. int tagType = TagCfgArray.Instance.GetCfg(_roleData.tags[0]).type;
  174. item.m_txtTag.text = _roleData.tags[0];
  175. item.m_loaTag.url = ResPathUtil.GetCommonGameResPath("fzd_bqbq_" + tagType);
  176. UI_ComTag.ProxyEnd();
  177. }
  178. UI_ComValueInfo.ProxyEnd();
  179. // GuideController.TryGuideDressUpFightViewBtnNext(_ui.m_btnNext);
  180. }
  181. private void OnClickListType1Item(EventContext context)
  182. {
  183. // GuideController.HideGuide();
  184. GObject typeItem = context.data as GObject;
  185. int order = (int)typeItem.data;
  186. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  187. if (item1.subMenusArr.Length > 0)
  188. {
  189. this.showListType2(item1.subMenusArr);
  190. }
  191. else
  192. {
  193. if (this.showListParts(item1.type) == false)
  194. {
  195. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  196. return;
  197. }
  198. this.showListParts(item1.type);
  199. }
  200. this.hideListType1();
  201. UpdateListPartsSelected();
  202. }
  203. private void OnClickListType2Item(EventContext context)
  204. {
  205. GObject typeItem = context.data as GObject;
  206. int order = (int)typeItem.data;
  207. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  208. if (this.showListParts(item2.type) == false)
  209. {
  210. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  211. return;
  212. }
  213. this.hideListType2();
  214. }
  215. private void OnClickPartsListItem(EventContext context)
  216. {
  217. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  218. {
  219. return;
  220. }
  221. GObject listItem = context.data as GObject;
  222. int id = (int)listItem.data;
  223. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  224. {
  225. this.showListParts2(id);
  226. this.hideListParts();
  227. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  228. }
  229. else
  230. {
  231. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  232. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  233. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  234. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  235. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  236. {
  237. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  238. return;
  239. }
  240. MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(id);
  241. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  242. }
  243. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  244. UpdateListPartsSelected();
  245. UpdateListSuitPartsSelected();
  246. UpdateValueInfo();
  247. }
  248. private void OnClickSuitPartsListItem(EventContext context)
  249. {
  250. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  251. {
  252. return;
  253. }
  254. GObject listItem = (GObject)context.data as GObject;
  255. int id = (int)listItem.data;
  256. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  257. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  258. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  259. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  260. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  261. {
  262. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  263. return;
  264. }
  265. MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(id);
  266. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  267. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  268. UpdateListSuitPartsSelected();
  269. UpdateValueInfo();
  270. }
  271. private void OnLongPress(EventContext context)
  272. {
  273. LongPressGesture gesture = (LongPressGesture)context.sender;
  274. int itemId = (int)gesture.host.data;
  275. GoodsItemTipsController.ShowItemTips(itemId);
  276. }
  277. private void OnTouchPad()
  278. {
  279. if (this.currentListType == DressUpListType.List4)
  280. {
  281. this.hideListParts2();
  282. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  283. }
  284. else if (this.currentListType == DressUpListType.List3)
  285. {
  286. if (_currentList2 != null)
  287. {
  288. this.showListType2(_currentList2);
  289. }
  290. else
  291. {
  292. this.showListType1();
  293. }
  294. this.hideListParts();
  295. }
  296. else if (this.currentListType == DressUpListType.List2)
  297. {
  298. this.showListType1();
  299. this.hideListType2();
  300. }
  301. }
  302. private void OnClickBtnDelete()
  303. {
  304. MyDressUpHelper.dressUpObj.TakeOffAll();
  305. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  306. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  307. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  308. }
  309. private void OnClickBtnNext()
  310. {
  311. Timers.inst.StartCoroutine(ScreenShotTex());
  312. }
  313. private IEnumerator ScreenShotTex()
  314. {
  315. GameObject Role = _sceneObject.transform.Find("Role").gameObject;
  316. GameObject CopyRoleParent = _sceneObject.transform.Find("CopyRole").gameObject;
  317. Transform CopyRole = CopyRoleParent.transform.Find("Role");
  318. if (CopyRole != null)
  319. {
  320. GameObject.DestroyImmediate(CopyRole.gameObject);
  321. }
  322. Transform transform = GameObject.Instantiate(Role, CopyRoleParent.transform.position, Quaternion.identity).transform;//实例化物体
  323. transform.parent = CopyRoleParent.transform;
  324. transform.name = "Role";
  325. GameObject gameObject = _sceneObject.transform.Find("FightCamera").gameObject;
  326. Camera camera = gameObject.GetComponent<Camera>();
  327. ArenaViewManager.Instance.textureDic[_dataManager.SelectThemeIndex] = FightDataManager.Instance.GetPrintscreenNTexture(camera);
  328. yield return new WaitForEndOfFrame();
  329. DressUpFinish();
  330. }
  331. private void DressUpFinish()
  332. {
  333. if (CardDataManager.GetCardListByRarity(0).Count > 0)
  334. {
  335. ViewManager.Show<StoryCardChoose>(InstanceZonesDataManager.currentScoreType);
  336. }
  337. else
  338. {
  339. ArenaSproxy.ReqChangeArenaDressup(_dataManager.SelectThemeIndex, 0, MyDressUpHelper.dressUpObj.itemList).Coroutine();
  340. }
  341. }
  342. private void OnClickBtnRecommend()
  343. {
  344. if (this.currentListType == DressUpListType.List4)
  345. {
  346. this.hideListParts2();
  347. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  348. }
  349. MyDressUpHelper.dressUpObj.CheckCancelActionWhenPutOn(_currentSuitId);
  350. MyDressUpHelper.PutOnRecommendItems2();
  351. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  352. UpdateListPartsSelected();
  353. UpdateListSuitPartsSelected();
  354. }
  355. private void InitLists()
  356. {
  357. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  358. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  359. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  360. listType1X = _ui.m_comListType1.target.x;
  361. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  362. //一级菜单
  363. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  364. }
  365. private void showListType1()
  366. {
  367. _currentList2 = null;
  368. currentListType = DressUpListType.List1;
  369. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  370. GTween.To(_ui.target.width, listType1X, 0.5f)
  371. .SetTarget(_ui.m_comListType1.target)
  372. .OnUpdate((GTweener t) =>
  373. {
  374. _ui.m_comListType1.target.x = t.value.x;
  375. });
  376. }
  377. private void hideListType1()
  378. {
  379. GTween.To(listType1X, _ui.target.width, 0.5f)
  380. .SetTarget(_ui.m_comListType1.target)
  381. .OnUpdate((GTweener t) =>
  382. {
  383. _ui.m_comListType1.target.x = t.value.x;
  384. });
  385. }
  386. private void showListType2(int[] menuStrArr = null)
  387. {
  388. currentListType = DressUpListType.List2;
  389. if (menuStrArr != null && menuStrArr.Length > 0)
  390. {
  391. int len = menuStrArr.Length;
  392. _currentList2 = menuStrArr.Clone() as int[];
  393. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  394. _ui.m_comListType2.m_listType.numItems = len;
  395. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  396. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  397. if (_ui.m_comListType2.m_listType.height > maxHeight)
  398. {
  399. _ui.m_comListType2.m_listType.height = maxHeight;
  400. }
  401. }
  402. GTween.To(_ui.target.width, listType1X, 0.5f)
  403. .SetTarget(_ui.m_comListType2.target)
  404. .OnUpdate((GTweener t) =>
  405. {
  406. _ui.m_comListType2.target.x = t.value.x;
  407. });
  408. }
  409. private void hideListType2()
  410. {
  411. GTween.To(listType1X, _ui.target.width, 0.5f)
  412. .SetTarget(_ui.m_comListType2.target)
  413. .OnUpdate((GTweener t) =>
  414. {
  415. _ui.m_comListType2.target.x = t.value.x;
  416. });
  417. }
  418. private bool showListParts(int type, bool selectItem = false)
  419. {
  420. _currentMenuType = type;
  421. UpdatePartsListSort();
  422. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  423. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  424. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  425. if (_ui.m_partsList.m_list.height > maxHeight)
  426. {
  427. _ui.m_partsList.m_list.height = maxHeight;
  428. }
  429. if (selectItem)
  430. {
  431. int itemId = MyDressUpHelper.dressUpObj.GetItemIdBuyType(_currentMenuType);
  432. if (itemId > 0)
  433. {
  434. int index = _currentList3.IndexOf(itemId);
  435. _ui.m_partsList.m_list.ScrollToView(index);
  436. }
  437. }
  438. currentListType = DressUpListType.List3;
  439. GTween.To(_ui.target.width, partsListX, 0.5f)
  440. .SetTarget(_ui.m_partsList)
  441. .OnUpdate((GTweener t) =>
  442. {
  443. _ui.m_partsList.target.x = t.value.x;
  444. });
  445. UpdateListPartsSelected();
  446. return true;
  447. }
  448. private void OnComboBoxRarityChanged()
  449. {
  450. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  451. this.UpdatePartsListSort();
  452. }
  453. private void UpdatePartsListSort()
  454. {
  455. if (_currentMenuType == 0) return;
  456. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  457. {
  458. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  459. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  460. {
  461. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  462. }
  463. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  464. {
  465. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  466. }
  467. else
  468. {
  469. _currentList3.Reverse();
  470. }
  471. }
  472. else
  473. {
  474. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  475. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  476. {
  477. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3);
  478. }
  479. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  480. {
  481. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3);
  482. }
  483. else
  484. {
  485. _currentList3.Reverse();
  486. }
  487. }
  488. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  489. {
  490. _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  491. }
  492. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  493. {
  494. _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  495. }
  496. _ui.m_partsList.m_list.RemoveChildrenToPool();
  497. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  498. }
  499. private void UpdateSuitPartsListSort()
  500. {
  501. if (_currentMenuType == 0) return;
  502. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId, true));
  503. if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  504. {
  505. _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  506. }
  507. else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  508. {
  509. _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  510. }
  511. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  512. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  513. }
  514. private void hideListParts()
  515. {
  516. GTween.To(partsListX, _ui.target.width, 0.5f)
  517. .SetTarget(_ui.m_partsList)
  518. .OnUpdate((GTweener t) =>
  519. {
  520. _ui.m_partsList.target.x = t.value.x;
  521. });
  522. }
  523. private void showListParts2(int suitId)
  524. {
  525. _currentSuitId = suitId;
  526. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  527. this.UpdateSuitPartsListSort();
  528. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  529. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  530. if (_ui.m_partsList2.m_list.height > maxHeight)
  531. {
  532. _ui.m_partsList2.m_list.height = maxHeight;
  533. }
  534. currentListType = DressUpListType.List4;
  535. GTween.To(_ui.target.width, partsListX, 0.5f)
  536. .SetTarget(_ui.m_partsList2)
  537. .OnUpdate((GTweener t) =>
  538. {
  539. _ui.m_partsList2.target.x = t.value.x;
  540. });
  541. }
  542. private void hideListParts2()
  543. {
  544. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  545. GTween.To(partsListX, _ui.target.width, 0.5f)
  546. .SetTarget(_ui.m_partsList2)
  547. .OnUpdate((GTweener t) =>
  548. {
  549. _ui.m_partsList2.target.x = t.value.x;
  550. });
  551. }
  552. private void ListType1Item(int index, GObject item)
  553. {
  554. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  555. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  556. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  557. typeItem.m_txtname.text = item1.name;
  558. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  559. typeItem.target.data = item1.id;
  560. typeItem.m_imgNeed.visible = false;
  561. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  562. UI.DressUp.UI_TypeItem.ProxyEnd();
  563. }
  564. private void ListType2Item(int index, GObject item)
  565. {
  566. UI.DressUp.UI_TypeItem typeItem = UI.DressUp.UI_TypeItem.Proxy(item);
  567. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  568. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  569. typeItem.m_txtname.text = item2.name;
  570. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  571. typeItem.target.data = item2.id;
  572. // var subType = ItemUtilCS.GetItemSubType(_fightCfg.needItemId);
  573. // typeItem.m_imgNeed.visible = subType == item2.type;
  574. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  575. UI.DressUp.UI_TypeItem.ProxyEnd();
  576. }
  577. private void ListPartsItem(int index, GObject item)
  578. {
  579. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  580. int id = (int)_currentList3[index];
  581. string iconRes = "";
  582. string partName = "";
  583. string ext = "png";
  584. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  585. {
  586. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  587. iconRes = suitCfg.res;
  588. partName = suitCfg.name;
  589. listItem.m_iconSelected.visible = false;
  590. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  591. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  592. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  593. listItem.m_imgNew.visible = false;
  594. }
  595. else
  596. {
  597. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  598. iconRes = itemCfg.res;
  599. partName = itemCfg.name;
  600. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  601. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _roleData.tags);
  602. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  603. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  604. listItem.m_imgNew.visible = isNew;
  605. if (isNew)
  606. {
  607. ItemProxy.ReqSetItemRead(id).Coroutine();
  608. }
  609. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  610. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  611. }
  612. if (listItem.target.data == null)
  613. {
  614. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  615. longPressGesture.once = true;
  616. longPressGesture.onAction.Add(OnLongPress);
  617. _listLongPress.Add(longPressGesture);
  618. }
  619. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  620. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + InstanceZonesDataManager.currentScoreType;
  621. listItem.m_txtTitle.text = partName;
  622. listItem.target.data = id;
  623. listItem.m_imgNeed.visible = false;
  624. UI_PartsListItem.ProxyEnd();
  625. }
  626. private void ListParts2Item(int index, GObject item)
  627. {
  628. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  629. int id = (int)_currentList4[index];
  630. string iconRes = "";
  631. string partName = "";
  632. string ext = "png";
  633. if (listItem.target.data == null)
  634. {
  635. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  636. longPressGesture.once = true;
  637. longPressGesture.onAction.Add(OnLongPress);
  638. _listLongPress.Add(longPressGesture);
  639. }
  640. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  641. iconRes = itemCfg.res;
  642. partName = itemCfg.name;
  643. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  644. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  645. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  646. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  647. listItem.m_ScoreType.visible = true;
  648. // int mainScore;
  649. // int mainValuel;
  650. // ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  651. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + InstanceZonesDataManager.currentScoreType);
  652. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _dataManager.DressupList[_dataManager.SelectThemeIndex].tags);
  653. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  654. listItem.m_txtTitle.text = partName;
  655. listItem.target.data = id;
  656. // listItem.m_txtScore.visible = false;
  657. //listItem.m_ScoreType.visible = true;
  658. listItem.m_imgNeed.visible = false;
  659. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  660. listItem.m_imgNew.visible = isNew;
  661. if (isNew)
  662. {
  663. ItemProxy.ReqSetItemRead(id).Coroutine();
  664. }
  665. UI_PartsListItem.ProxyEnd();
  666. }
  667. private void UpdateListPartsSelected()
  668. {
  669. int count = _ui.m_partsList.m_list.numChildren;
  670. int suitId = MyDressUpHelper.dressUpObj.suitId;
  671. for (int i = 0; i < count; i++)
  672. {
  673. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(i));
  674. int id = (int)listItem.target.data;
  675. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  676. {
  677. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  678. }
  679. else
  680. {
  681. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  682. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  683. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  684. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  685. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  686. }
  687. UI_PartsListItem.ProxyEnd();
  688. }
  689. }
  690. private void UpdateListSuitPartsSelected()
  691. {
  692. int count = _ui.m_partsList2.m_list.numChildren;
  693. int suitId = MyDressUpHelper.dressUpObj.suitId;
  694. for (int i = 0; i < count; i++)
  695. {
  696. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  697. int id = (int)listItem.target.data;
  698. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  699. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  700. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  701. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  702. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  703. UI_PartsListItem.ProxyEnd();
  704. }
  705. }
  706. private void OnClickBtnSearch()
  707. {
  708. ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
  709. }
  710. private void SendLog()
  711. {
  712. }
  713. private void CheckGuide(object param)
  714. {
  715. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0
  716. || GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0
  717. || GuideDataManager.IsGuideFinish(ConstGuideId.AUTOPLAY_FIGHT) <= 0)
  718. {
  719. UpdateToCheckGuide(null);
  720. }
  721. else
  722. {
  723. Timers.inst.Remove(CheckGuide);
  724. }
  725. }
  726. protected override void UpdateToCheckGuide(object param)
  727. {
  728. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  729. }
  730. protected override void TryCompleteGuide()
  731. {
  732. base.TryCompleteGuide();
  733. }
  734. }
  735. }