ArenaDressUpFightView.cs 35 KB

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