DressUpFightView.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  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. namespace GFGGame
  9. {
  10. public class DressUpFightView : BaseView
  11. {
  12. private UI_DressUpFightUI _ui;
  13. private int _fightID;
  14. private int _levelID;
  15. private float listType1X = 0;
  16. private float partsListX = 0;
  17. private float partsListScrollingPosY = 0;
  18. private DressUpListType currentListType;
  19. private int[] _currentList2;
  20. private GameObject _scenePrefab;
  21. private GameObject _sceneObject;
  22. private List<int> _currentList3 = new List<int>();
  23. private List<int> _currentList4 = new List<int>();
  24. private int _currentMenuType;
  25. private int _currentSuitId;
  26. private StoryLevelCfg _levelCfg;
  27. private StoryFightCfg _fightCfg;
  28. private const int SORT_BY_HIGH_SCORE = 0;
  29. private const int SORT_BY_LOW_SCORE = 1;
  30. private int _scoreIndex = SORT_BY_HIGH_SCORE;
  31. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  32. public override void Dispose()
  33. {
  34. if (_sceneObject != null)
  35. {
  36. GameObject.Destroy(_sceneObject);
  37. _sceneObject = null;
  38. }
  39. for (int i = 0; i < _listLongPress.Count; i++)
  40. {
  41. _listLongPress[i].Dispose();
  42. }
  43. if (_ui != null)
  44. {
  45. _ui.Dispose();
  46. _ui = null;
  47. }
  48. base.Dispose();
  49. }
  50. protected override void Init()
  51. {
  52. base.Init();
  53. packageName = UI_DressUpFightUI.PACKAGE_NAME;
  54. _ui = UI_DressUpFightUI.Create();
  55. viewCom = _ui.target;
  56. isfullScreen = true;
  57. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUpFight"));
  58. _ui.m_btnClose.width = GRoot.inst.width;
  59. _ui.m_btnClose.height = GRoot.inst.height;
  60. _ui.m_btnClose.AddRelation(GRoot.inst, RelationType.Size);
  61. }
  62. protected override void OnInit()
  63. {
  64. base.OnInit();
  65. _ui.m_btnLastStep.visible = true;
  66. _ui.m_btnNextStep.visible = true;
  67. _ui.m_btnClose.visible = false;
  68. _ui.m_grpTips.visible = false;
  69. _ui.m_btnRepeal.visible = false;
  70. _ui.m_btnRenewal.visible = false;
  71. _ui.m_btnSearch.visible = true;
  72. // _ui.m_comboBox.items = new string[] { "我的套装一", "我的套装二", "我的套装三", "我的套装四", "我的套装五", "我的套装六" };
  73. _ui.m_partsList.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  74. _ui.m_partsListSearch.m_comboBoxRarity.items = new string[] { "高分优先", "低分优先" };
  75. InitLists();
  76. _ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
  77. _ui.m_partsListSearch.m_comboBoxRarity.onChanged.Add(OnSearchComboBoxRarityChanged);
  78. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  79. _ui.m_btnHome.onClick.Add(OnClickBtnHome);
  80. // _ui.m_btnClothingShop.onClick.Add(OnClickBtnClothingShop);
  81. // _ui.m_comboBox.onChanged.Add(OnComboBoxChanged);
  82. _ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
  83. _ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
  84. _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
  85. _ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
  86. _ui.m_partsListSearch.m_list.onClickItem.Add(OnClickSearchPartsListItem);
  87. _ui.m_touchPad.onClick.Add(OnTouchPad);
  88. _ui.m_btnHint.onClick.Add(OnClickBtnHint);
  89. // _ui.m_btnGuide.onClick.Add(OnTouchPad);
  90. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  91. _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
  92. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  93. _ui.m_btnRecommend.onClick.Add(OnClickBtnRecommend);
  94. _ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
  95. _ui.m_btnAutoPlay.onClick.Add(OnClickBtnAutoPlay);
  96. _ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
  97. _ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
  98. _ui.m_compNeed.target.onClick.Add(OnClickComNeed);
  99. _ui.m_compNeed.m_listTag.itemRenderer = RenderListTagItem;
  100. // _ui.m_btnShow.onClick.Add(OnClickBtnShow);
  101. // _ui.m_btnHide.onClick.Add(OnClickBtnHide);
  102. // _ui.m_loaShow.onClick.Add(OnClickLoaShow);
  103. // _ui.m_btnHide.visible = false;
  104. // EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdatePartsListSort);
  105. _ui.m_partsList2.m_comboBoxRarity.visible = false;
  106. _ui.m_partsList2.m_imgTop.visible = true;
  107. _ui.m_partsList.m_imgTop.visible = false;
  108. }
  109. protected override void AddEventListener()
  110. {
  111. base.AddEventListener();
  112. EventAgent.AddEventListener(ConstMessage.CARD_CHOOSE, StartCalculateScore);
  113. EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  114. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  115. EventAgent.AddEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  116. // EventAgent.AddEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateScore);
  117. }
  118. protected override void OnShown()
  119. {
  120. base.OnShown();
  121. _ui.m_loaGuide.visible = true;
  122. InstanceZonesDataManager.usedRecommend = false;
  123. // _ui.m_comboBox.title = "我的套装";
  124. _ui.m_txtRecommendCount.SetVar("v1", "" + GameGlobal.myNumericComponent.GetAsInt(ET.NumericType.RecommendCount)).FlushVars();
  125. _ui.m_txtRecommendCount.SetVar("v2", GlobalCfgArray.globalCfg.recommendCount.ToString()).FlushVars();
  126. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  127. _ui.m_btnAutoPlay.selected = FightDataManager.Instance.autoPlay;
  128. _ui.m_btnAutoPlay.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(ConstFunctionId.FUNCTION_AUTOPLAY_FIGHT, false);
  129. _ui.m_btnRecommend.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(ConstFunctionId.FUNCTION_AUTOPLAY_FIGHT, false); ;
  130. _levelID = (int)viewData;
  131. InstanceZonesDataManager.currentLevelCfgId = _levelID;
  132. _levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  133. _fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  134. if (_levelCfg.type == ConstInstanceZonesType.Field)
  135. {
  136. _fightCfg.scoreType = FieldDataManager.Instance.fieldInfos.theme;
  137. _ui.m_btnAutoPlay.visible = false;
  138. }
  139. InstanceZonesDataManager.FightScene = _levelCfg.type;
  140. _ui.m_compNeed.target.visible = _fightCfg.needItemId > 0 || _fightCfg.needSuitId > 0 || _fightCfg.needTagsArr.Length > 0;
  141. if (_ui.m_compNeed.target.visible)
  142. {
  143. _ui.m_compNeed.m_c1.selectedIndex = 0;
  144. if (_fightCfg.needItemId > 0)
  145. {
  146. _ui.m_compNeed.m_txtNeedName.text = ItemUtil.GetItemName(_fightCfg.needItemId);
  147. _ui.m_compNeed.target.data = _fightCfg.needItemId;
  148. _ui.m_compNeed.m_imgGot.visible = ItemDataManager.GetItemNum(_fightCfg.needItemId) > 0;
  149. }
  150. else if (_fightCfg.needSuitId > 0)
  151. {
  152. _ui.m_compNeed.m_txtNeedName.text = ItemUtil.GetSuitName(_fightCfg.needSuitId);
  153. _ui.m_compNeed.target.data = _fightCfg.needSuitId;
  154. _ui.m_compNeed.m_imgGot.visible = DressUpMenuSuitDataManager.CheckHaveSuit(_fightCfg.needSuitId);
  155. }
  156. else
  157. {
  158. _ui.m_compNeed.m_c1.selectedIndex = 1;
  159. _ui.m_compNeed.m_listTag.numItems = _fightCfg.needTagsArr.Length;
  160. _ui.m_compNeed.m_imgGot.visible = false;
  161. }
  162. }
  163. InstanceZonesDataManager.currentScoreType = _fightCfg.scoreType;
  164. //一级菜单
  165. _ui.m_comListType1.m_listType.RemoveChildrenToPool();
  166. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  167. //_ui.m_comListType1.m_listType1.ResizeToFit(_ui.m_listType1.numItems);
  168. float maxHeight = _ui.target.height - _ui.m_comListType1.m_listType.y - DressUpView.BOTTOM_BLANK;
  169. if (_ui.m_comListType1.m_listType.height > maxHeight)
  170. {
  171. _ui.m_comListType1.m_listType.height = maxHeight;
  172. }
  173. _ui.m_comListType1.target.x = _ui.target.width;
  174. _ui.m_comListType2.target.x = _ui.target.width;
  175. _ui.m_partsList.target.x = _ui.target.width;
  176. _ui.m_partsList2.target.x = _ui.target.width;
  177. _ui.m_partsListSearch.target.x = _ui.target.width;
  178. _ui.m_scoreType.url = "ui://CommonGame/kp_sx_" + _fightCfg.scoreType;
  179. this.showListType1();
  180. if (_sceneObject == null)
  181. {
  182. _sceneObject = GameObject.Instantiate(_scenePrefab);
  183. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
  184. MyDressUpHelper.dressUpObj.PutOnDefaultDressUpData();
  185. }
  186. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  187. UpdateStepBtn(true);
  188. UpdateScore();
  189. SendLog();
  190. Timers.inst.AddUpdate(CheckGuide);
  191. }
  192. protected override void OnHide()
  193. {
  194. base.OnHide();
  195. _ui.m_btnClose.visible = false;
  196. _ui.m_grpTips.visible = false;
  197. if (_sceneObject != null)
  198. {
  199. GameObject.Destroy(_sceneObject);
  200. _sceneObject = null;
  201. }
  202. _fightCfg = null;
  203. _levelCfg = null;
  204. DressUpMenuItemDataManager.Clear();
  205. MyDressUpHelper.ResetMemory();
  206. Timers.inst.Remove(CheckGuide);
  207. }
  208. protected override void RemoveEventListener()
  209. {
  210. base.RemoveEventListener();
  211. EventAgent.RemoveEventListener(ConstMessage.CARD_CHOOSE, StartCalculateScore);
  212. EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdateSerch);
  213. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdateSerch);
  214. EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
  215. // EventAgent.RemoveEventListener(ConstMessage.DRESS_UP_SCORE_CHANGED, UpdateScore);
  216. }
  217. private void OnClickBtnLastStep()
  218. {
  219. if (!MyDressUpHelper.OnClickBtnLastStep()) return;
  220. UpdateStepBtn(false);
  221. }
  222. private void OnClickBtnNextStep()
  223. {
  224. if (!MyDressUpHelper.OnClickBtnNextStep()) return;
  225. UpdateStepBtn(false);
  226. }
  227. private void OnClickBtnBack()
  228. {
  229. AlertUI.Show("是否确定退出?")
  230. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  231. {
  232. if (_levelCfg.type == ConstInstanceZonesType.Studio && _levelCfg.subType != ConstInstanceZonesSubType.Hard3)
  233. {
  234. ViewManager.Show(StudioDataManager.Instance.VIEW_NAME, StudioDataManager.Instance.PROPERTY_SELECT_INDEX, ViewManager.GetGoBackDatas(StudioDataManager.Instance.VIEW_NAME));
  235. }
  236. else if (_levelCfg.type == ConstInstanceZonesType.Studio && _levelCfg.subType == ConstInstanceZonesSubType.Hard3)
  237. {
  238. ViewManager.Show<StudioFilingView>(null, ViewManager.GetGoBackDatas(typeof(StudioFilingView).FullName));
  239. }
  240. else if (_levelCfg.type == ConstInstanceZonesType.Field)
  241. {
  242. ViewManager.GoBackFrom(ViewName.DRESS_UP_FIGHT_VIEW);
  243. }
  244. else
  245. {
  246. // ViewManager.GoBackFrom(ViewName.STORY_CHAPTER_VIEW);
  247. ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, _levelCfg.chapterId);//, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW }
  248. }
  249. //MyDressUpHelper.dressUpObj.TakeOffAll();
  250. this.Hide();
  251. });
  252. // ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter);
  253. }
  254. private void OnClickBtnHome()
  255. {
  256. AlertUI.Show("是否返回?")
  257. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  258. {
  259. //MyDressUpHelper.dressUpObj.TakeOffAll();
  260. GameController.GoBackToMainView();
  261. });
  262. }
  263. private void OnClickBtnClothingShop()
  264. {
  265. ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { null, _fightCfg.scoreType }, null, false, true);
  266. }
  267. private void OnClickListType1Item(EventContext context)
  268. {
  269. // GuideController.HideGuide();
  270. GObject typeItem = context.data as GObject;
  271. int order = (int)typeItem.data;
  272. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
  273. if (item1.subMenusArr.Length > 0)
  274. {
  275. this.showListType2(item1.subMenusArr);
  276. }
  277. else
  278. {
  279. if (this.showListParts(item1.type) == false)
  280. {
  281. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  282. return;
  283. }
  284. this.showListParts(item1.type);
  285. }
  286. this.hideListType1();
  287. UpdateListPartsSelected();
  288. }
  289. private void OnClickListType2Item(EventContext context)
  290. {
  291. GObject typeItem = context.data as GObject;
  292. int order = (int)typeItem.data;
  293. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
  294. if (this.showListParts(item2.type) == false)
  295. {
  296. PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
  297. return;
  298. }
  299. this.hideListType2();
  300. }
  301. private void OnClickSearchPartsListItem(EventContext context)
  302. {
  303. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  304. {
  305. return;
  306. }
  307. GObject listItem = context.data as GObject;
  308. int id = (int)listItem.data;
  309. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  310. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  311. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  312. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  313. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  314. {
  315. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  316. return;
  317. }
  318. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  319. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  320. UpdateStepBtn(true);
  321. // UpdateSearchListPartsSelected();
  322. UpdateScore();
  323. }
  324. private void OnClickPartsListItem(EventContext context)
  325. {
  326. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  327. {
  328. return;
  329. }
  330. GObject listItem = context.data as GObject;
  331. int id = (int)listItem.data;
  332. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  333. {
  334. partsListScrollingPosY = _ui.m_partsList.m_list.scrollPane.scrollingPosY;
  335. this.showListParts2(id);
  336. this.hideListParts();
  337. MyDressUpHelper.dressUpObj.PutOnItemList(MyDressUpHelper.GetSuitFightItems(id));
  338. UpdateStepBtn(true);
  339. // MyDressUpHelper.dressUpObj.PutOnSuitCfg(id, false);
  340. }
  341. else
  342. {
  343. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  344. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  345. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  346. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  347. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  348. {
  349. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  350. return;
  351. }
  352. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  353. UpdateStepBtn(true);
  354. }
  355. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  356. // UpdateListPartsSelected();
  357. // UpdateListSuitPartsSelected();
  358. UpdateScore();
  359. }
  360. private void OnClickSuitPartsListItem(EventContext context)
  361. {
  362. if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
  363. {
  364. return;
  365. }
  366. GObject listItem = (GObject)context.data as GObject;
  367. int id = (int)listItem.data;
  368. bool isOrnament = DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsType(id);
  369. bool isDress = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  370. bool isHasSame = MyDressUpHelper.dressUpObj.CheckSameTypeIsOn(id);
  371. bool isMaxCount = MyDressUpHelper.GetCurrentOrnamentCount() >= GlobalCfgArray.globalCfg.dressLimitCount;
  372. if (isOrnament && !isDress && !isHasSame && isMaxCount)
  373. {
  374. PromptController.Instance.ShowFloatTextPrompt("饰品穿戴数量已达上限");
  375. return;
  376. }
  377. if (!DressUpMenuItemDataManager.CheckHasItem(id))
  378. {
  379. PromptController.Instance.ShowFloatTextPrompt("还未获得这件装扮");
  380. return;
  381. }
  382. MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
  383. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  384. UpdateStepBtn(true);
  385. // UpdateListSuitPartsSelected();
  386. UpdateScore();
  387. }
  388. private void UpdateStepBtn(bool isAdd, int suitId = 0)
  389. {
  390. if (isAdd)
  391. {
  392. MyDressUpHelper.AddMemoryDressup();
  393. }
  394. _ui.m_btnLastStep.enabled = MyDressUpHelper.stepIndex > 0;
  395. _ui.m_btnNextStep.enabled = MyDressUpHelper.stepIndex < MyDressUpHelper.dressMemory.Count - 1;
  396. UpdateListPartsSelected();
  397. UpdateListSuitPartsSelected();
  398. }
  399. private void OnLongPress(EventContext context)
  400. {
  401. LongPressGesture gesture = (LongPressGesture)context.sender;
  402. int itemId = (int)gesture.host.data;
  403. GoodsItemTipsController.ShowItemTips(itemId);
  404. }
  405. private void OnTouchPad()
  406. {
  407. if (this.currentListType == DressUpListType.List4)
  408. {
  409. this.hideListParts2();
  410. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  411. }
  412. else if (this.currentListType == DressUpListType.List3)
  413. {
  414. if (_currentList2 != null)
  415. {
  416. this.showListType2(_currentList2);
  417. }
  418. else
  419. {
  420. this.showListType1();
  421. }
  422. this.hideListParts();
  423. }
  424. else if (this.currentListType == DressUpListType.List2)
  425. {
  426. this.showListType1();
  427. this.hideListType2();
  428. }
  429. else if (this.currentListType == DressUpListType.List5)
  430. {
  431. this.showListType1();
  432. this.hideSearchListType();
  433. }
  434. }
  435. private void OnClickBtnHint()
  436. {
  437. this.ShowTaskHint();
  438. }
  439. private void OnClickBtnDelete()
  440. {
  441. MyDressUpHelper.dressUpObj.TakeOffAll();
  442. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  443. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  444. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  445. UpdateStepBtn(true);
  446. // UpdateListPartsSelected();
  447. // UpdateListSuitPartsSelected();
  448. }
  449. private void OnClickBtnClose()
  450. {
  451. _ui.m_btnClose.visible = false;
  452. _ui.m_grpTips.visible = false;
  453. }
  454. private void OnClickBtnNext()
  455. {
  456. // if (!MyDressUpHelper.CheckPutOnFinish())
  457. // {
  458. // AlertUI.Show("只有换好衣服才能出门哦!")
  459. // .SetRightButton(true, "好的");
  460. // return;
  461. // }
  462. if (!CheckHasNeed())
  463. {
  464. AlertUI.Show("未穿戴必需品。").SetRightButton(true, "好的");
  465. return;
  466. }
  467. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  468. if (RoleDataManager.power < levelCfg.power)
  469. {
  470. ItemUtil.AddPower(OnClickBtnPhotograph);
  471. return;
  472. }
  473. OnClickBtnPhotograph();
  474. }
  475. private bool CheckHasNeed()
  476. {
  477. int _suitId = MyDressUpHelper.dressUpObj.suitId;
  478. bool isNoSuit = _fightCfg.needSuitId > 0 && _suitId != _fightCfg.needSuitId;//需要套装但未穿套装
  479. bool isDressUpItem = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(_fightCfg.needItemId);
  480. bool isIncludeItem = _suitId > 0 && Array.IndexOf(SuitCfgArray.Instance.GetCfg(_suitId).partsArr, _fightCfg.needItemId) >= 0;
  481. bool isNoItem = _fightCfg.needItemId > 0 && !isDressUpItem && !isIncludeItem;
  482. if (isNoSuit || isNoItem)
  483. {
  484. return false;
  485. }
  486. return true;
  487. }
  488. private void OnClickBtnPhotograph()
  489. {
  490. Timers.inst.StartCoroutine(ScreenShotTex());
  491. }
  492. private IEnumerator ScreenShotTex()
  493. {
  494. GameObject Role = _sceneObject.transform.Find("Role").gameObject;
  495. GameObject CopyRoleParent = _sceneObject.transform.Find("CopyRole").gameObject;
  496. Transform CopyRole = CopyRoleParent.transform.Find("Role");
  497. if (CopyRole != null)
  498. {
  499. GameObject.DestroyImmediate(CopyRole.gameObject);
  500. }
  501. Transform transform = GameObject.Instantiate(Role, CopyRoleParent.transform.position, Quaternion.identity).transform;//实例化物体
  502. transform.parent = CopyRoleParent.transform;
  503. transform.name = "Role";
  504. GameObject gameObject = _sceneObject.transform.Find("FightCamera").gameObject;
  505. Camera camera = gameObject.GetComponent<Camera>();
  506. FightDataManager.Instance.RoleTextuex = FightDataManager.Instance.GetPrintscreenNTexture(camera);
  507. yield return new WaitForEndOfFrame();
  508. if (CardDataManager.GetCardListByRarity(0).Count > 0)
  509. {
  510. ViewManager.Show<StoryCardChoose>(_fightCfg.scoreType);
  511. }
  512. else
  513. {
  514. StartCalculateScore();
  515. }
  516. }
  517. private void StartCalculateScore()
  518. {
  519. //不可移动代码位置
  520. bool hasFightTarget = _fightCfg.targetName != null && _fightCfg.targetName.Length > 0;
  521. if (_levelCfg.type == ConstInstanceZonesType.Field)
  522. {
  523. FieldFightDataManager.Instance.CurrentCardId = InstanceZonesDataManager.currentCardId;
  524. FieldFightDataManager.Instance.CurrentScoreType = InstanceZonesDataManager.currentScoreType;
  525. FieldFightDataManager.Instance.currentLevelCfgId = InstanceZonesDataManager.currentLevelCfgId;
  526. }
  527. if (hasFightTarget)
  528. {
  529. ViewManager.Show(ViewName.STORY_FIGHT_TARGET_VIEW);
  530. }
  531. else
  532. {
  533. ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_VIEW);
  534. }
  535. this.Hide();
  536. }
  537. private void OnClickBtnRecommend()
  538. {
  539. if (this.currentListType == DressUpListType.List4)
  540. {
  541. this.hideListParts2();
  542. this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
  543. }
  544. InstanceZonesDataManager.usedRecommend = true;
  545. // MyDressUpHelper.PutOnRecommendItems();
  546. MyDressUpHelper.PutOnRecommendItems2();
  547. _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
  548. UpdateStepBtn(true);
  549. // UpdateListPartsSelected();
  550. // UpdateListSuitPartsSelected();
  551. UpdateScore();
  552. if (!CheckHasNeed())
  553. {
  554. PromptController.Instance.ShowFloatTextPrompt("未拥有必需品");
  555. }
  556. }
  557. private void InitLists()
  558. {
  559. _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
  560. _ui.m_partsList.m_list.itemRenderer = ListPartsItem;
  561. _ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
  562. _ui.m_partsListSearch.m_list.itemRenderer = ListPartsItem;
  563. listType1X = _ui.m_comListType1.target.x;
  564. partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;
  565. //一级菜单
  566. _ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
  567. }
  568. private void showListType1()
  569. {
  570. _currentList2 = null;
  571. currentListType = DressUpListType.List1;
  572. _ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length - 3;
  573. GTween.To(_ui.target.width, listType1X, 0.5f)
  574. .SetTarget(_ui.m_comListType1.target)
  575. .OnUpdate((GTweener t) =>
  576. {
  577. _ui.m_comListType1.target.x = t.value.x;
  578. });
  579. }
  580. private void hideListType1()
  581. {
  582. GTween.To(listType1X, _ui.target.width, 0.5f)
  583. .SetTarget(_ui.m_comListType1.target)
  584. .OnUpdate((GTweener t) =>
  585. {
  586. _ui.m_comListType1.target.x = t.value.x;
  587. });
  588. }
  589. private void showListType2(int[] menuStrArr = null)
  590. {
  591. currentListType = DressUpListType.List2;
  592. if (menuStrArr != null && menuStrArr.Length > 0)
  593. {
  594. int len = menuStrArr.Length;
  595. _currentList2 = menuStrArr.Clone() as int[];
  596. _ui.m_comListType2.m_listType.RemoveChildrenToPool();
  597. _ui.m_comListType2.m_listType.numItems = len;
  598. //_ui.m_listType2.ResizeToFit(_ui.m_listType2.numItems);
  599. float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
  600. if (_ui.m_comListType2.m_listType.height > maxHeight)
  601. {
  602. _ui.m_comListType2.m_listType.height = maxHeight;
  603. }
  604. }
  605. GTween.To(_ui.target.width, listType1X, 0.5f)
  606. .SetTarget(_ui.m_comListType2.target)
  607. .OnUpdate((GTweener t) =>
  608. {
  609. _ui.m_comListType2.target.x = t.value.x;
  610. });
  611. }
  612. private void hideListType2()
  613. {
  614. GTween.To(listType1X, _ui.target.width, 0.5f)
  615. .SetTarget(_ui.m_comListType2.target)
  616. .OnUpdate((GTweener t) =>
  617. {
  618. _ui.m_comListType2.target.x = t.value.x;
  619. });
  620. }
  621. private bool showListParts(int type, bool selectItem = false)
  622. {
  623. _currentMenuType = type;
  624. UpdatePartsListSort();
  625. if (_ui.m_partsList.m_list.numItems <= 0) return false;
  626. _ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
  627. float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;
  628. if (_ui.m_partsList.m_list.height > maxHeight)
  629. {
  630. _ui.m_partsList.m_list.height = maxHeight;
  631. }
  632. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  633. {
  634. _ui.m_partsList.m_list.scrollPane.SetPosY(partsListScrollingPosY, false);
  635. partsListScrollingPosY = 0;
  636. }
  637. currentListType = DressUpListType.List3;
  638. GTween.To(_ui.target.width, partsListX, 0.5f)
  639. .SetTarget(_ui.m_partsList)
  640. .OnUpdate((GTweener t) =>
  641. {
  642. _ui.m_partsList.target.x = t.value.x;
  643. });
  644. UpdateListPartsSelected();
  645. return true;
  646. }
  647. private void OnComboBoxRarityChanged()
  648. {
  649. _scoreIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
  650. this.UpdatePartsListSort();
  651. }
  652. private void OnSearchComboBoxRarityChanged()
  653. {
  654. _scoreIndex = _ui.m_partsListSearch.m_comboBoxRarity.selectedIndex;
  655. this.UpdateSearchList();
  656. }
  657. private void UpdatePartsListSort()
  658. {
  659. if (_currentMenuType == 0) return;
  660. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  661. {
  662. _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  663. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  664. {
  665. _currentList3 = SuitUtil.SortSuitListByHighScore(_currentList3);
  666. }
  667. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  668. {
  669. _currentList3 = SuitUtil.SortSuitListByLowScore(_currentList3);
  670. }
  671. else
  672. {
  673. _currentList3.Reverse();
  674. }
  675. }
  676. else
  677. {
  678. _currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
  679. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  680. {
  681. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3, true);
  682. }
  683. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  684. {
  685. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3, true);
  686. }
  687. else
  688. {
  689. _currentList3.Reverse();
  690. }
  691. }
  692. // if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  693. // {
  694. // _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
  695. // }
  696. // else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  697. // {
  698. // _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
  699. // }
  700. //必穿品放在列表最前面
  701. if (_fightCfg.needItemId > 0)
  702. {
  703. int index = _currentList3.IndexOf(_fightCfg.needItemId);
  704. if (index >= 0)
  705. {
  706. int item = _currentList3[index];
  707. _currentList3.Remove(_currentList3[index]);
  708. _currentList3.Insert(0, item);
  709. }
  710. }
  711. else if (_fightCfg.needSuitId > 0)
  712. {
  713. int index = _currentList3.IndexOf(_fightCfg.needSuitId);
  714. if (index >= 0)
  715. {
  716. int item = _currentList3[index];
  717. _currentList3.Remove(_currentList3[index]);
  718. _currentList3.Insert(0, item);
  719. }
  720. }
  721. _ui.m_partsList.m_list.RemoveChildrenToPool();
  722. _ui.m_partsList.m_list.numItems = _currentList3.Count;
  723. }
  724. private void UpdateSuitPartsListSort()
  725. {
  726. if (_currentMenuType == 0) return;
  727. _currentList4 = new List<int>(SuitCfgArray.Instance.GetSuitItems(_currentSuitId, true));
  728. // if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
  729. // {
  730. // _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
  731. // }
  732. // else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
  733. // {
  734. // _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
  735. // }
  736. _ui.m_partsList2.m_list.RemoveChildrenToPool();
  737. _ui.m_partsList2.m_list.numItems = _currentList4.Count;
  738. }
  739. private void hideListParts()
  740. {
  741. GTween.To(partsListX, _ui.target.width, 0.5f)
  742. .SetTarget(_ui.m_partsList)
  743. .OnUpdate((GTweener t) =>
  744. {
  745. _ui.m_partsList.target.x = t.value.x;
  746. });
  747. }
  748. private void showListParts2(int suitId)
  749. {
  750. _currentSuitId = suitId;
  751. _ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
  752. this.UpdateSuitPartsListSort();
  753. _ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
  754. float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
  755. if (_ui.m_partsList2.m_list.height > maxHeight)
  756. {
  757. _ui.m_partsList2.m_list.height = maxHeight;
  758. }
  759. currentListType = DressUpListType.List4;
  760. GTween.To(_ui.target.width, partsListX, 0.5f)
  761. .SetTarget(_ui.m_partsList2)
  762. .OnUpdate((GTweener t) =>
  763. {
  764. _ui.m_partsList2.target.x = t.value.x;
  765. });
  766. }
  767. private void hideListParts2()
  768. {
  769. _currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
  770. GTween.To(partsListX, _ui.target.width, 0.5f)
  771. .SetTarget(_ui.m_partsList2)
  772. .OnUpdate((GTweener t) =>
  773. {
  774. _ui.m_partsList2.target.x = t.value.x;
  775. });
  776. }
  777. private void showSearchListType()
  778. {
  779. // _currentList2 = null;
  780. currentListType = DressUpListType.List5;
  781. GTween.To(_ui.target.width, partsListX, 0.5f)
  782. .SetTarget(_ui.m_partsListSearch.target)
  783. .OnUpdate((GTweener t) =>
  784. {
  785. _ui.m_partsListSearch.target.x = t.value.x;
  786. });
  787. }
  788. private void hideSearchListType()
  789. {
  790. GTween.To(partsListX, _ui.target.width, 0.5f)
  791. .SetTarget(_ui.m_partsListSearch.target)
  792. .OnUpdate((GTweener t) =>
  793. {
  794. _ui.m_partsListSearch.target.x = t.value.x;
  795. });
  796. }
  797. /*****************************************************************************************************/
  798. private void DressResetSerch()
  799. {
  800. if (currentListType == DressUpListType.List5)
  801. {
  802. OnTouchPad();
  803. }
  804. }
  805. private void UpdateSerch(EventContext context)
  806. {
  807. if (context.data.ToString() == ConstMessage.DRESS_SEARCH)
  808. {
  809. _currentList3 = DressUpMenuItemDataManager.DressSearch(false);
  810. }
  811. else if (context.data.ToString() == ConstMessage.DRESS_FILTER)
  812. {
  813. _currentList3 = DressUpMenuItemDataManager.DressFilter(false);
  814. }
  815. ViewManager.Hide<ModalStatusView>();
  816. UpdateSearchList();
  817. if (currentListType != DressUpListType.List5)
  818. {
  819. hideListParts();
  820. hideListParts2();
  821. hideListType1();
  822. hideListType2();
  823. showSearchListType();
  824. }
  825. _currentMenuType = 0;
  826. }
  827. private void UpdateSearchList()
  828. {
  829. if (_scoreIndex == SORT_BY_HIGH_SCORE)
  830. {
  831. _currentList3 = DressUpMenuItemDataManager.SortItemListByHighScore(_currentList3, true);
  832. }
  833. else if (_scoreIndex == SORT_BY_LOW_SCORE)
  834. {
  835. _currentList3 = DressUpMenuItemDataManager.SortItemListByLowScore(_currentList3, true);
  836. }
  837. _currentMenuType = 0;
  838. _ui.m_partsListSearch.m_list.numItems = _currentList3.Count; ;
  839. }
  840. private void ListType1Item(int index, GObject item)
  841. {
  842. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  843. DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
  844. typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
  845. typeItem.m_txtname.text = item1.name;
  846. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
  847. typeItem.target.data = item1.id;
  848. typeItem.m_imgNeed.visible = ItemUtil.CheckMenuType1(_fightCfg.needItemId, _fightCfg.needSuitId, item1.id);
  849. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
  850. UI_TypeItem.ProxyEnd();
  851. }
  852. private void ListType2Item(int index, GObject item)
  853. {
  854. UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
  855. DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
  856. typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
  857. typeItem.m_txtname.text = item2.name;
  858. //typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
  859. typeItem.target.data = item2.id;
  860. var subType = ItemUtilCS.GetItemSubType(_fightCfg.needItemId);
  861. typeItem.m_imgNeed.visible = subType == item2.type;
  862. typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
  863. UI_TypeItem.ProxyEnd();
  864. }
  865. private void ListPartsItem(int index, GObject item)
  866. {
  867. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  868. int id = (int)_currentList3[index];
  869. string iconRes = "";
  870. string partName = "";
  871. string ext = "png";
  872. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  873. {
  874. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  875. iconRes = suitCfg.res;
  876. partName = suitCfg.name;
  877. listItem.m_iconSelected.visible = false;
  878. listItem.m_txtScore.text = "" + SuitUtil.GetSuitScore(id);
  879. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
  880. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
  881. listItem.m_imgNew.visible = false;
  882. }
  883. else
  884. {
  885. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  886. iconRes = itemCfg.res;
  887. partName = itemCfg.name;
  888. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  889. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, InstanceZonesDataManager.currentScoreType, _fightCfg.needTagsArr);
  890. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  891. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  892. listItem.m_imgNew.visible = isNew;
  893. if (isNew)
  894. {
  895. ItemProxy.ReqSetItemRead(id).Coroutine();
  896. }
  897. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  898. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  899. }
  900. if (listItem.target.data == null)
  901. {
  902. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  903. longPressGesture.once = true;
  904. longPressGesture.onAction.Add(OnLongPress);
  905. _listLongPress.Add(longPressGesture);
  906. }
  907. listItem.m_btnAni.visible = false;
  908. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  909. listItem.m_ScoreType.url = "ui://CommonGame/kp_sx_" + _fightCfg.scoreType;
  910. listItem.m_txtTitle.text = partName;
  911. listItem.target.data = id;
  912. listItem.m_imgNeed.visible = _fightCfg.needItemId == id || _fightCfg.needSuitId == id;
  913. UI_PartsListItem.ProxyEnd();
  914. }
  915. private void ListParts2Item(int index, GObject item)
  916. {
  917. UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
  918. int id = (int)_currentList4[index];
  919. string iconRes = "";
  920. string partName = "";
  921. string ext = "png";
  922. if (listItem.target.data == null)
  923. {
  924. LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
  925. longPressGesture.once = true;
  926. longPressGesture.onAction.Add(OnLongPress);
  927. _listLongPress.Add(longPressGesture);
  928. }
  929. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
  930. iconRes = itemCfg.res;
  931. partName = itemCfg.name;
  932. listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
  933. listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
  934. RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
  935. ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
  936. listItem.m_ScoreType.visible = true;
  937. // int mainScore;
  938. // int mainValuel;
  939. // ItemDataManager.GetMainScore(id, out mainScore, out mainValuel);
  940. listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + _fightCfg.scoreType);
  941. listItem.m_txtScore.text = "" + ItemDataManager.GetItemAdditionScore(id, _fightCfg.scoreType, _fightCfg.needTagsArr);
  942. listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
  943. listItem.m_txtTitle.text = partName;
  944. listItem.target.data = id;
  945. // listItem.m_txtScore.visible = false;
  946. //listItem.m_ScoreType.visible = true;
  947. listItem.m_imgNeed.visible = false;
  948. listItem.m_btnAni.visible = false;
  949. bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
  950. listItem.m_imgNew.visible = isNew;
  951. if (isNew)
  952. {
  953. ItemProxy.ReqSetItemRead(id).Coroutine();
  954. }
  955. UI_PartsListItem.ProxyEnd();
  956. }
  957. private void UpdateListPartsSelected()
  958. {
  959. GList list;
  960. if (_ui.m_partsList.target.x == partsListX)
  961. {
  962. list = _ui.m_partsList.m_list;
  963. }
  964. else if (_ui.m_partsListSearch.target.x == partsListX)
  965. {
  966. list = _ui.m_partsListSearch.m_list;
  967. }
  968. else
  969. {
  970. return;
  971. }
  972. int count = list.numChildren;
  973. int suitId = MyDressUpHelper.dressUpObj.suitId;
  974. for (int i = 0; i < count; i++)
  975. {
  976. UI_PartsListItem listItem = UI_PartsListItem.Proxy(list.GetChildAt(i));
  977. int id = (int)listItem.target.data;
  978. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  979. {
  980. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  981. }
  982. else
  983. {
  984. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  985. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  986. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  987. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  988. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  989. }
  990. UI_PartsListItem.ProxyEnd();
  991. }
  992. }
  993. private void UpdateSearchListPartsSelected()
  994. {
  995. int count = _ui.m_partsListSearch.m_list.numChildren;
  996. int suitId = MyDressUpHelper.dressUpObj.suitId;
  997. for (int i = 0; i < count; i++)
  998. {
  999. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsListSearch.m_list.GetChildAt(i));
  1000. int id = (int)listItem.target.data;
  1001. if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
  1002. {
  1003. listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
  1004. }
  1005. else
  1006. {
  1007. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  1008. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  1009. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  1010. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  1011. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  1012. }
  1013. UI_PartsListItem.ProxyEnd();
  1014. }
  1015. }
  1016. private void UpdateListSuitPartsSelected()
  1017. {
  1018. int count = _ui.m_partsList2.m_list.numChildren;
  1019. int suitId = MyDressUpHelper.dressUpObj.suitId;
  1020. for (int i = 0; i < count; i++)
  1021. {
  1022. UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
  1023. int id = (int)listItem.target.data;
  1024. bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//非套装金判断是否穿戴
  1025. var isSceneType = DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(id);
  1026. bool isSuit = !isSceneType && suitId > 0 && SuitCfgArray.Instance.GetSuitIdOfItem(id) == suitId;//非场景类, 若当前穿戴套装要判断item是否属于套装(更换场景类不会改变套装穿戴状态)
  1027. bool isSceneSuit = isSceneType && suitId > 0 && isPutOn;//场景类, 若当前穿戴套装要判断item是否属已穿戴
  1028. listItem.m_iconSelected.visible = isPutOn || isSuit || isSceneSuit;
  1029. UI_PartsListItem.ProxyEnd();
  1030. }
  1031. }
  1032. private void ShowTaskHint()
  1033. {
  1034. _ui.m_btnClose.visible = true;
  1035. _ui.m_grpTips.visible = true;
  1036. _ui.m_txtHint.text = _levelCfg.hint;
  1037. if (this._ui.m_txtHint.textHeight > this._ui.m_txtHint.textFormat.size * 2)
  1038. {
  1039. this._ui.m_txtHint.align = AlignType.Left;
  1040. }
  1041. else
  1042. {
  1043. this._ui.m_txtHint.align = AlignType.Center;
  1044. }
  1045. }
  1046. private void UpdateScore()
  1047. {
  1048. _ui.m_txtScore.text = "" + FightDataManager.Instance.GetScore(InstanceZonesDataManager.roleData).ToString();
  1049. // GuideController.TryGuideDressUpFightViewBtnNext(_ui.m_btnNext);
  1050. }
  1051. private void OnClickBtnSearch()
  1052. {
  1053. ViewManager.Show<DressFilterView>(false, new object[] { ViewName.DRESS_UP_VIEW });
  1054. }
  1055. private void OnClickBtnAutoPlay()
  1056. {
  1057. FightDataManager.Instance.autoPlay = _ui.m_btnAutoPlay.selected;
  1058. }
  1059. private void OnClickComNeed()
  1060. {
  1061. if (_fightCfg.needItemId <= 0 && _fightCfg.needSuitId <= 0)
  1062. {
  1063. return;
  1064. }
  1065. if (_fightCfg.needSuitId > 0)
  1066. {
  1067. ViewManager.Show<SuitPartsDetailView>(_fightCfg.needSuitId, new object[] { typeof(DressUpFightView).FullName, this.viewData });
  1068. }
  1069. else
  1070. {
  1071. int itemId = (int)_ui.m_compNeed.target.data;
  1072. object[] sourceDatas = new object[] { itemId, new object[] { ViewName.DRESS_UP_FIGHT_VIEW, this.viewData }, 1 };
  1073. GoodsItemTipsController.ShowItemTips(itemId, sourceDatas);
  1074. }
  1075. }
  1076. private void RenderListTagItem(int index, GObject obj)
  1077. {
  1078. UI.CommonGame.UI_ComTag item = UI.CommonGame.UI_ComTag.Proxy(obj);
  1079. string tag = _fightCfg.needTagsArr[index];
  1080. int tagType = TagCfgArray.Instance.GetCfg(tag).type;
  1081. item.m_txtTag.text = tag;
  1082. item.m_loaTag.url = ResPathUtil.GetCommonGameResPath("fzd_bqbq_" + tagType);
  1083. UI.CommonGame.UI_ComTag.ProxyEnd();
  1084. }
  1085. private bool CheckListCount(int type)
  1086. {
  1087. if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
  1088. {
  1089. return DressUpMenuSuitDataManager.GetSuitIDList().Count > 0;
  1090. }
  1091. else
  1092. {
  1093. return DressUpMenuItemDataManager.getItemDatasByType(type).Count > 0;
  1094. }
  1095. }
  1096. private void SendLog()
  1097. {
  1098. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  1099. switch (levelCfg.type)
  1100. {
  1101. case ConstInstanceZonesType.Story:
  1102. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.CHUN_ZHONG_LOU, 2);
  1103. break;
  1104. case ConstInstanceZonesType.Studio:
  1105. StudioCfg studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  1106. if (studioCfg.funId == typeof(StudioMetalView).Name)
  1107. {
  1108. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.JIN_SHU_XIU_FU, 2);
  1109. }
  1110. else if (studioCfg.funId == typeof(StudioFabricView).Name)
  1111. {
  1112. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZHI_WU_XIU_FU, 2);
  1113. }
  1114. else if (studioCfg.funId == typeof(StudioPropertyView).Name)
  1115. {
  1116. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHU_HUA_XIU_FU, 2);
  1117. }
  1118. break;
  1119. }
  1120. }
  1121. private void CheckGuide(object param)
  1122. {
  1123. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0
  1124. || GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0
  1125. || GuideDataManager.IsGuideFinish(ConstGuideId.AUTOPLAY_FIGHT) <= 0)
  1126. {
  1127. UpdateToCheckGuide(null);
  1128. }
  1129. else
  1130. {
  1131. Timers.inst.Remove(CheckGuide);
  1132. }
  1133. _ui.m_loaGuide.visible = false;
  1134. }
  1135. protected override void UpdateToCheckGuide(object param)
  1136. {
  1137. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  1138. int buyClothingIndex = 0;
  1139. int buyClothingSubIndex = 0;
  1140. int taozhuangIndex = 0;
  1141. int len = _ui.m_comListType1.m_listType.numChildren;
  1142. for (int i = 0; i < len; i++)
  1143. {
  1144. UI_TypeItem item = UI_TypeItem.Proxy(_ui.m_comListType1.m_listType.GetChildAt(i));
  1145. if (item != null)
  1146. {
  1147. int menuID = (int)item.target.data;
  1148. DressUpMenuItemCfg1 dressUpMenuItemCfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuID);
  1149. if (GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0 && dressUpMenuItemCfg1.type == ConstDressUpItemType.TAO_ZHUANG)
  1150. {
  1151. taozhuangIndex = i;
  1152. break;
  1153. }
  1154. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0 && _fightCfg.needItemId > 0 && ItemUtil.CheckMenuType1(_fightCfg.needItemId, _fightCfg.needSuitId, dressUpMenuItemCfg1.id))
  1155. {
  1156. buyClothingIndex = i;
  1157. break;
  1158. }
  1159. }
  1160. UI_TypeItem.ProxyEnd();
  1161. }
  1162. buyClothingSubIndex = _currentList3.IndexOf(_fightCfg.needItemId);
  1163. GuideController.TryGuide(_ui.m_comListType1.m_listType, ConstGuideId.START_FIGHT, 3, "点击相应的分类,可以快速找到服饰。", taozhuangIndex);
  1164. GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.START_FIGHT, 4, "", 0);
  1165. GuideController.TryGuide(_ui.m_btnNext, ConstGuideId.START_FIGHT, 5, "穿着完毕,来验证一下,换上的服饰是否符合需求。");
  1166. // GuideController.TryCompleteGuide(ConstGuideId.START_FIGHT, 5);
  1167. GuideController.TryGuide(_ui.m_compNeed.target, ConstGuideId.BUY_CLOTHING, 3, "当提示有“必需品”时,需要穿上对应物品才能通关。");
  1168. GuideController.TryGuide(_ui.m_comListType1.m_listType, ConstGuideId.BUY_CLOTHING, 7, "按照指示就可以找到必需品啦,点击换上吧。", buyClothingIndex);
  1169. GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.BUY_CLOTHING, 8, "", buyClothingSubIndex);
  1170. GuideController.TryCompleteGuide(ConstGuideId.BUY_CLOTHING, 8);
  1171. GuideController.TryGuide(_ui.m_btnHint, ConstGuideId.FIGHT_TIPS, 1, "这次换装需要获得别人的认可呢。");
  1172. GuideController.TryCompleteGuide(ConstGuideId.FIGHT_TIPS, 1);
  1173. GuideController.TryGuide(_ui.m_btnRecommend, ConstGuideId.AUTOPLAY_FIGHT, 1, "衣服太多难以选择,可以点击这里。");
  1174. GuideController.TryGuide(_ui.m_btnAutoPlay, ConstGuideId.AUTOPLAY_FIGHT, 2, "勾选后,自动进行比拼哦~~");
  1175. GuideController.TryCompleteGuide(ConstGuideId.AUTOPLAY_FIGHT, 2);
  1176. }
  1177. protected override void TryCompleteGuide()
  1178. {
  1179. base.TryCompleteGuide();
  1180. // GuideController.TryCompleteGuide(ConstGuideId.START_FIGHT, 5);
  1181. }
  1182. }
  1183. }