ClothingSelectView.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.CommonGame;
  6. using UI.ClothingUpgrade;
  7. using UnityEngine;
  8. using System.Text.RegularExpressions;
  9. namespace GFGGame
  10. {
  11. public class ClothingSelectView : BaseWindow
  12. {
  13. private UI_ClothingSelectUI _ui;
  14. private int partIndex1;
  15. private int partIndex2;
  16. private EffectUI _effectUI1;
  17. private EffectUI _effectUI2;
  18. public override void Dispose()
  19. {
  20. EffectUIPool.Recycle(_effectUI1);
  21. _effectUI1 = null;
  22. EffectUIPool.Recycle(_effectUI2);
  23. _effectUI2 = null;
  24. if (_ui != null)
  25. {
  26. _ui.Dispose();
  27. _ui = null;
  28. }
  29. base.Dispose();
  30. }
  31. protected override void OnInit()
  32. {
  33. base.OnInit();
  34. packageName = UI_ClothingSelectUI.PACKAGE_NAME;
  35. _ui = UI_ClothingSelectUI.Create();
  36. this.viewCom = _ui.target;
  37. isReturnView = true;
  38. isfullScreen = true;
  39. modal = true;
  40. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  41. _ui.m_selectList.itemRenderer = RenderListItem;
  42. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_bgEffect, "ui_gyp", "GYP_ALL");
  43. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_birdEffect, "ui_gyp", "GYP_Bird");
  44. }
  45. protected override void OnShown()
  46. {
  47. base.OnShown();
  48. _ui.m_bg.url = ResPathUtil.GetBgImgPath("gyp_bg");
  49. UpdateList();
  50. }
  51. protected override void OnHide()
  52. {
  53. base.OnHide();
  54. }
  55. private void UpdateList()
  56. {
  57. _ui.m_selectList.numItems = CollectPartDataManager.Count;
  58. }
  59. private void RenderListItem(int index, GObject obj)
  60. {
  61. UI_clothingSelectItem listItem = UI_clothingSelectItem.Proxy(obj);
  62. int level;
  63. int levelNum;
  64. int addNum;
  65. if(index < CollectPartDataManager.Count - 1)
  66. {
  67. //0表示所有部位,1~7表示各个部位
  68. partIndex1 = 0;
  69. partIndex2 = index + 1;
  70. }
  71. else
  72. {
  73. partIndex1 = 99;
  74. partIndex2 = 99;
  75. }
  76. level = CollectPartDataManager.Instance.CollectPartDataDic[partIndex2][0];
  77. levelNum = CollectPartDataManager.Instance.CollectPartDataDic[partIndex2][1];
  78. if (IsOpenRank(partIndex2))
  79. {
  80. listItem.target.visible = true;
  81. if (levelNum > 0)
  82. {
  83. addNum = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(partIndex1, level, levelNum).value;
  84. float addNumPercentage = (float)addNum / CollectPartDataManager.Instance.AddtitionRatio;
  85. listItem.m_c1.selectedIndex = 0;
  86. listItem.m_partIcon.url = string.Format("ui://ClothingUpgrade/{0}", CollectPartDataManager.Instance.partImage[partIndex2]);
  87. CollegeRankCfg rankItemList = CollegeRankCfgArray.Instance.GetCfgByRankPartsIdAndSecondLevelRank(partIndex1, level);
  88. listItem.m_levelText.text = rankItemList.gradeName;
  89. listItem.m_levelNumText.text = string.Format("{0}级", levelNum.ToString());
  90. listItem.m_nameText.text = CollectPartDataManager.Instance.partNameDic[partIndex2];
  91. listItem.m_levelDescText.text = string.Format("{0}%", addNumPercentage);
  92. }
  93. else
  94. {
  95. listItem.m_c1.selectedIndex = 0;
  96. listItem.m_partIcon.url = string.Format("ui://ClothingUpgrade/{0}", CollectPartDataManager.Instance.partImage[partIndex2]);
  97. CollegeRankCfg rankItemList = CollegeRankCfgArray.Instance.GetCfgByRankPartsIdAndSecondLevelRank(partIndex1, level);
  98. listItem.m_levelText.text = rankItemList.gradeName;
  99. listItem.m_levelNumText.text = string.Format("{0}级", "0");
  100. listItem.m_nameText.text = CollectPartDataManager.Instance.partNameDic[partIndex2];
  101. listItem.m_levelDescText.text = string.Format("{0}%", "0");
  102. }
  103. if (listItem.target.data == null)
  104. {
  105. listItem.target.onClick.Add(OnBtnItem);
  106. }
  107. listItem.target.data = partIndex2;
  108. }
  109. else
  110. {
  111. listItem.m_c1.selectedIndex = 1;
  112. listItem.target.visible = false;
  113. }
  114. UI_clothingSelectItem.ProxyEnd();
  115. }
  116. private bool IsOpenRank(int partIndex,int levelNum = 9)
  117. {
  118. List<int> openList;
  119. bool isRank = false;
  120. bool isLevel = false;
  121. bool isPassStory = false ;
  122. CollegeRankOpenCfg openitem = CollegeRankOpenCfgArray.Instance.GetCfg(partIndex);
  123. openList = GetOpenList(partIndex);
  124. //判断段位
  125. if (openitem.OpenPreconditionArr == null || openitem.OpenPreconditionArr.Length == 0)
  126. {
  127. isRank = true;
  128. }
  129. else
  130. {
  131. if (CollectPartDataManager.Instance.CollectPartDataDic[openList[0]][0] >= openList[1])
  132. {
  133. if (CollectPartDataManager.Instance.CollectPartDataDic[openList[0]][1] >= openList[2])
  134. {
  135. isRank = true;
  136. }
  137. }
  138. }
  139. //判断等级
  140. if(RoleDataManager.lvl >= openitem.needRoleLv)
  141. {
  142. isLevel = true;
  143. }
  144. //判断关卡
  145. if(openitem.needStoryLevelId == 0 || InstanceZonesDataManager.CheckLevelPass(openitem.needStoryLevelId))
  146. {
  147. isPassStory = true;
  148. }
  149. else
  150. {
  151. isPassStory = false;
  152. }
  153. return isRank&&isLevel&&isPassStory;
  154. }
  155. private List<int> GetOpenList(int partIndex)
  156. {
  157. List<int> openList = new List<int>();
  158. string pattern = @"\d+";
  159. CollegeRankOpenCfg openitem = CollegeRankOpenCfgArray.Instance.GetCfg(partIndex);
  160. for (int i = 0; i < openitem.OpenPreconditionArr.Length; i++)
  161. {
  162. MatchCollection matches = Regex.Matches(openitem.OpenPreconditionArr[i], pattern);
  163. foreach (Match match in matches)
  164. {
  165. openList.Add(int.Parse(match.Value));
  166. }
  167. }
  168. return openList;
  169. }
  170. private void OnBtnItem(EventContext context)
  171. {
  172. GObject Item = context.sender as GObject;
  173. int partIndex = (int)Item.data;
  174. if(IsOpenRank(partIndex))
  175. {
  176. ViewManager.Show<ClothingUpgradeView>(new object[] { partIndex });
  177. }
  178. else
  179. {
  180. //string openString = "";
  181. //string partName = CollectPartDataManager.Instance.partNameDic[partIndex];
  182. //List<int> openList = GetOpenList(partIndex);
  183. //openString = CollegeRankCfgArray.Instance.GetCfgByRankPartsIdAndSecondLevelRank(partIndex2, openList[1]).gradeName;
  184. //string descString = string.Format("该部位需要达到{0}{1}{2}开启", partName, openString, openList[2]);
  185. PromptController.Instance.ShowFloatTextPrompt("需要达到特定条件开启");
  186. }
  187. }
  188. private void OnClickBtnBack()
  189. {
  190. ViewManager.GoBackFrom(typeof(ClothingSelectView).FullName);
  191. }
  192. }
  193. }