DressUpFightView.cs 62 KB

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