CardFosterView.cs 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  1. using FairyGUI;
  2. using UI.Card;
  3. using UI.CommonGame;
  4. using UI_ComConsume = UI.Card.UI_ComConsume;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using System.Timers;
  8. using System.Collections;
  9. using System.Linq;
  10. using VEngine;
  11. using ET;
  12. namespace GFGGame
  13. {
  14. public class CardFosterView : BaseView
  15. {
  16. private UI_CardFosterUI _ui;
  17. private UI_ComFosterBottom _comFosterBottom;
  18. private ValueBarController _valueBarController;
  19. private UI_ComCost _comLvConsumeGold;
  20. private UI_ComCostCurrencyWithHas _comStarCousumeGold;
  21. private CardData _cardData = new CardData();
  22. private List<CardStarCfg> _cardStarRewards = new List<CardStarCfg>();
  23. private int _selectTab = 0;
  24. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  25. private List<GGraph> _listEffectHolder = new List<GGraph>();
  26. private List<CardData> cardList = new List<CardData>();
  27. private int wordRow = 4; //字行数
  28. private int wordNumber = 5;//字每行个数
  29. private int nowIndex = 0;
  30. private bool refDodgeStar = true;
  31. private EffectUI _effectUI1;
  32. private EffectUI _effectUI3;
  33. private EffectUI _effectUI4;
  34. private EffectUI _effectUI5;
  35. private EffectUI _effectUI6;
  36. private EffectUI _effectUI7;
  37. private EffectUI _effectUI8;
  38. private EffectUI _effectUI9;
  39. private EffectUI _effectUI10;
  40. private GObject _consumeSelectItem;//选中的材料item
  41. private int _consumeSelectIndex = 0;//0为减,1为加
  42. private List<int> itemsCount;
  43. private int[] upgradeCardItemsArr = GlobalCfgArray.globalCfg.upgradeCardItemsArr;
  44. //private Timer _timer;
  45. private const float _delay = 300;
  46. private double _selectTimeCount = 0;//长按时间
  47. private int _showLv = 0;
  48. private int _showExp = 0;
  49. private float _cardScale = 0.8f;
  50. private bool showCard = false;
  51. private bool playAni = false;
  52. private const int _cardResInitWidth = 1440;
  53. private const int _cardResInitHight = 1920;
  54. private Vector2 comCardImgResInitSize;
  55. private Vector2 comCardImgResTargetSize;
  56. public override void Dispose()
  57. {
  58. EffectUIPool.Recycle(_effectUI3);
  59. _effectUI3 = null;
  60. EffectUIPool.Recycle(_effectUI4);
  61. _effectUI4 = null;
  62. for (int i = 0; i < _listLongPress.Count; i++)
  63. {
  64. _listLongPress[i].Dispose();
  65. }
  66. _listLongPress.Clear();
  67. if (_valueBarController != null)
  68. {
  69. _valueBarController.Dispose();
  70. _valueBarController = null;
  71. }
  72. if (_ui != null)
  73. {
  74. _ui.Dispose();
  75. _ui = null;
  76. }
  77. base.Dispose();
  78. }
  79. protected override void OnInit()
  80. {
  81. base.OnInit();
  82. packageName = UI_CardFosterUI.PACKAGE_NAME;
  83. _ui = UI_CardFosterUI.Create();
  84. viewCom = _ui.target;
  85. isfullScreen = true;
  86. //公共组件:返回,页签,属性列表
  87. _ui.m_ComFosterTop.m_btnback.onClick.Add(OnClickBtnBack);
  88. _ui.m_ComFosterTop.m_btnStarReward.onClick.Add(OnBtnStarRewardClick);
  89. _ui.m_ComFosterBottom.m_ctrlTab.onChanged.Add(OnChangeCtrlTab);
  90. _ui.m_ComFosterBottom.m_listProperty.itemRenderer = RenderListPropertyItem;
  91. //卡面和故事界面
  92. _ui.m_ComFosterTop.m_btnStory.onClick.Add(OnClickBtnStroy);
  93. //升级升星按钮
  94. _ui.m_ComFosterBottom.m_btnUpLv.onClick.Add(OnClickBtnUpLv);
  95. _ui.m_ComFosterBottom.m_btnAll.onClick.Add(OnClcikBtnAll);
  96. _ui.m_ComFosterBottom.m_btnClearAll.onClick.Add(OnClcikBtnClearAll);
  97. _ui.m_ComFosterBottom.m_btnUpStar.onClick.Add(OnClickBtnUpStar);
  98. _ui.m_ComFosterBottom.m_btnUpSkillLv.onClick.Add(OnBtnUpSkill);
  99. //升级升星消耗材料列表
  100. _ui.m_ComFosterBottom.m_listLvConsume.itemRenderer = RenderListLvConsumeItem;
  101. _ui.m_ComFosterBottom.m_listStarConsume.itemRenderer = RenderListStarConsumeItem;
  102. _ui.m_ComFosterBottom.m_listSkill.itemRenderer = RenderListSkillItem;
  103. //满星级后卡面列表
  104. _ui.m_ComFosterBottom.m_listShowCard.itemRenderer = RenderListShowCardItem;
  105. _ui.m_ComFosterBottom.m_listShowCard.onClickItem.Add(OnClickShowCardListItem);
  106. _ui.m_btnLeft.onClick.Add(OnClickBtnLeft);
  107. _ui.m_btnRight.onClick.Add(OnClickBtnRight);
  108. //_ui.m_loaCard.onClick.Add(OnClickLoaCard);
  109. //_ui.m_loaListener1.onClick.Add(OnClickLoaCard);
  110. //_ui.m_comImgCard.target.onClick.Add(OnClickLoaCard);
  111. //_ui.m_loaListener.onClick.Add(OnClickComCard);
  112. //_ui.m_comCard.target.onClick.Add(OnClickComCard);
  113. _ui.m_comImgCard.target.onTouchBegin.Add(onTouchCardBegin);
  114. _ui.m_comImgCard.target.onTouchEnd.Add(onTouchImgCardEnd);
  115. _ui.m_loaListener1.onTouchBegin.Add(onTouchCardBegin);
  116. _ui.m_loaListener1.onTouchEnd.Add(onTouchImgCardEnd);
  117. _ui.m_loaListener.onTouchBegin.Add(onTouchCardBegin);
  118. _ui.m_loaListener.onTouchEnd.Add(onTouchCardEnd);
  119. _ui.m_comCard.target.onTouchBegin.Add(onTouchCardBegin);
  120. _ui.m_comCard.target.onTouchEnd.Add(onTouchCardEnd);
  121. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_ComFosterBottom.m_holderflower, "ui_Activity", "SX_Top_TX");
  122. _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_ComFosterBottom.m_holderfBgEff, "ui_Activity", "SX_Down_TX");
  123. }
  124. private void RefLeftAndRight()
  125. {
  126. _ui.m_btnRight.grayed = false;
  127. _ui.m_btnRight.touchable = true;
  128. _ui.m_btnLeft.grayed = false;
  129. _ui.m_btnLeft.touchable = true;
  130. if (nowIndex <= 0)
  131. {
  132. _ui.m_btnLeft.grayed = true;
  133. _ui.m_btnLeft.touchable = false;
  134. }
  135. else if (nowIndex >= cardList.Count)
  136. {
  137. _ui.m_btnRight.grayed = true;
  138. _ui.m_btnRight.touchable = false;
  139. }
  140. }
  141. private void OnClickBtnLeft()
  142. {
  143. nowIndex -= 1;
  144. RefLeftAndRight();
  145. _cardData = cardList[nowIndex];
  146. RefCardFosterInfo();
  147. }
  148. private void OnClickBtnRight()
  149. {
  150. nowIndex += 1;
  151. RefLeftAndRight();
  152. _cardData = cardList[nowIndex];
  153. RefCardFosterInfo();
  154. }
  155. private void RefCardFosterInfo()
  156. {
  157. playAni = false;
  158. float imgInitHight = _ui.target.height - 570;//UI界面上小图时的高度
  159. float imgIniWidth = _cardResInitWidth * imgInitHight / _cardResInitHight;//UI界面上小图时的宽度
  160. _cardScale = imgIniWidth < _ui.target.width ? _ui.target.width / _cardResInitWidth : imgInitHight / _cardResInitHight;
  161. comCardImgResInitSize = Vector2.zero;
  162. comCardImgResTargetSize = Vector2.zero;
  163. showCard = false;
  164. Input.multiTouchEnabled = false;
  165. this.ClearItemsCountList();
  166. this.UpdateCommon();
  167. this.UpdateNormal();
  168. this.UpdateCardRes();
  169. this.UpdateUpLvView();
  170. this.UpdateUpStarView();
  171. this.UpdateUpSkillView();
  172. this.UpdateRedDot();
  173. _comFosterBottom.m_ctrlTab.selectedIndex = this._selectTab;
  174. _comFosterBottom.m_listSkill.selectedIndex = 0;
  175. _comFosterBottom.m_btnClearAll.visible = false;
  176. List<CardStarCfg> cardStarCfgs = CardStarCfgArray.Instance.GetCfgsBycardId(_cardData.id);
  177. for (int i = 0; i < cardStarCfgs.Count; i++)
  178. {
  179. if (cardStarCfgs[i].rewardsArr.Length > 0)
  180. {
  181. _cardStarRewards.Add(cardStarCfgs[i]);
  182. }
  183. }
  184. _ui.m_ComFosterTop.m_btnStarReward.visible = _cardStarRewards.Count > 0;
  185. Timers.inst.AddUpdate(CheckGuide);
  186. }
  187. protected override void OnShown()
  188. {
  189. base.OnShown();
  190. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
  191. List<object> dataList = viewData as List<object>;
  192. _cardData = CardDataManager.GetCardDataById((this.viewData as CardData).id);
  193. nowIndex = _cardData.index;
  194. _comFosterBottom = _ui.m_ComFosterBottom;
  195. RefCardFosterInfo();
  196. cardList = CardDataManager.GetCardListByRarity(0);
  197. if (CardDataManager.isFilter == true)
  198. {
  199. //筛选
  200. cardList = CardDataManager.FilterCardList(cardList);
  201. }
  202. cardList = CardDataManager.SortItemList(cardList);
  203. }
  204. protected override void AddEventListener()
  205. {
  206. base.AddEventListener();
  207. EventAgent.AddEventListener(ConstMessage.CARD_UP_SKILL, UpdateUpSkillView);
  208. EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateItemChange);
  209. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  210. }
  211. private void ClearItemsCountList()
  212. {
  213. if (itemsCount == null)
  214. {
  215. itemsCount = new List<int>();
  216. }
  217. itemsCount.Clear();
  218. for (int i = 0; i < upgradeCardItemsArr.Length; i++)
  219. {
  220. itemsCount.Add(0);
  221. }
  222. }
  223. private void UpdateNormal()
  224. {
  225. _ui.m_ComFosterTop.m_btnStory.visible = CardDataManager.GetStoryCfgsById(_cardData.id).Count > 0 ? true : false;
  226. _valueBarController = new ValueBarController(_ui.m_ComFosterTop.m_comValueBar, 5);
  227. _valueBarController.OnShown();
  228. RarityIconController.UpdateRarityIcon(_ui.m_ComFosterBottom.m_loaRarity, _cardData.id, false);
  229. string names = _cardData.itemCfg.name;
  230. _comFosterBottom.m_txtName0.text = "";
  231. _comFosterBottom.m_txtName1.text = "";
  232. _comFosterBottom.m_txtName2.text = "";
  233. _comFosterBottom.m_txtName3.text = "";
  234. _comFosterBottom.m_txtName4.text = "";
  235. switch (names.Length)
  236. {
  237. case 1:
  238. _comFosterBottom.m_txtName0.text = names.Substring(0, 1);
  239. break;
  240. case 2:
  241. _comFosterBottom.m_txtName0.text = names.Substring(0, 1);
  242. _comFosterBottom.m_txtName2.text = names.Substring(1, 1);
  243. break;
  244. case 3:
  245. _comFosterBottom.m_txtName0.text = names.Substring(0, 1);
  246. _comFosterBottom.m_txtName1.text = names.Substring(1, 1);
  247. _comFosterBottom.m_txtName2.text = names.Substring(2, 1);
  248. break;
  249. case 4:
  250. _comFosterBottom.m_txtName0.text = names.Substring(0, 1);
  251. _comFosterBottom.m_txtName1.text = names.Substring(1, 1);
  252. _comFosterBottom.m_txtName2.text = names.Substring(2, 1);
  253. _comFosterBottom.m_txtName3.text = names.Substring(3, 1);
  254. break;
  255. default:
  256. _comFosterBottom.m_txtName0.text = names.Substring(0, 1);
  257. _comFosterBottom.m_txtName1.text = names.Substring(1, 1);
  258. _comFosterBottom.m_txtName2.text = names.Substring(2, 1);
  259. _comFosterBottom.m_txtName3.text = names.Substring(3, 1);
  260. _comFosterBottom.m_txtName4.text = names.Substring(4);
  261. break;
  262. }
  263. }
  264. private void UpdateCommon()
  265. {
  266. _comFosterBottom.m_listProperty.numItems = _cardData.scores.Count;
  267. _comLvConsumeGold = UI_ComCost.Proxy(_comFosterBottom.m_ComLvConsumeGold);
  268. _comLvConsumeGold.m_txtNeed.text = "0";
  269. _comLvConsumeGold.m_c1.selectedIndex = 1;
  270. UI_ComCost.ProxyEnd();
  271. }
  272. private void UpdateCardRes()
  273. {
  274. if (_effectUI1 != null)
  275. {
  276. EffectUIPool.Recycle(_effectUI1);
  277. _effectUI1 = null;
  278. }
  279. string resName = _cardData.resources[_cardData.resIndex];
  280. string resPath = ResPathUtil.GetCardAnimationPath(_cardData.resources[_cardData.resIndex]);
  281. if (_cardData.itemCfg.animationCardStar > 0 && _cardData.star >= _cardData.itemCfg.animationCardStar && Versions.Contains(resPath))
  282. {
  283. _effectUI1 = new EffectUI();
  284. _effectUI1.Reset(_ui.m_comCard.m_comCardHolder.m_holder, resName, resName, 100, EffectUIType.Card);
  285. }
  286. if (_effectUI1 != null)
  287. {
  288. _ui.m_c1.selectedIndex = 1;
  289. _ui.m_comCard.target.scrollPane.SetPercX(0.5f, false);
  290. _ui.m_comCard.target.SetScale(_cardScale, _cardScale);
  291. }
  292. else
  293. {
  294. _ui.m_c1.selectedIndex = 0;
  295. if (comCardImgResInitSize == Vector2.zero)
  296. {
  297. GLoader loaCard = _ui.m_comImgCard.m_ComCardImgRes.m_loaCard;
  298. loaCard.url = ResPathUtil.GetCardPath(_cardData.resources[_cardData.resIndex]);
  299. comCardImgResTargetSize = new Vector2(_ui.target.height * _cardResInitWidth / _cardResInitHight, _ui.target.height);
  300. comCardImgResInitSize = new Vector2(_cardResInitWidth * _cardScale, _cardResInitHight * _cardScale);
  301. _ui.m_comImgCard.m_ComCardImgRes.target.size = comCardImgResInitSize;
  302. _ui.m_comImgCard.target.scrollPane.SetPercX(0.5f, false);
  303. }
  304. }
  305. }
  306. private void RenderListPropertyItem(int index, GObject obj)
  307. {
  308. UI_ListScoreItem listItem = UI_ListScoreItem.Proxy(obj);
  309. listItem.m_txtProperty.text = _cardData.scores[index + 1].ToString();
  310. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (index + 1));
  311. UI_ListScoreItem.ProxyEnd();
  312. }
  313. /***********************************************************升级***************************************************/
  314. private void UpdateUpLvView(bool isPreview = false, int lv = 0, int exp = 0, bool effLight = false)
  315. {
  316. _showLv = isPreview == true ? lv : _cardData.lv;
  317. _showExp = isPreview == true ? exp : _cardData.exp;
  318. CardLvlCfg cardLvCfg = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, _showLv);
  319. if (cardLvCfg == null)
  320. {
  321. ET.Log.Error("词牌" + _cardData.id + " 没有 " + _showLv + " 级等级配置");
  322. return;
  323. }
  324. _comFosterBottom.m_barLv.max = cardLvCfg.needExp;
  325. _comFosterBottom.m_barLv.value = _showExp;
  326. if (effLight) {
  327. EffectUIPool.Recycle(_effectUI6);
  328. _effectUI6 = EffectUIPool.CreateEffectUI(_comFosterBottom.m_holderbarLv, "ui_Activity", "SX_JinDuTiao");
  329. }
  330. int maxLv = CardRarityCfgArray.Instance.GetCfg(_cardData.itemCfg.rarity).maxCardLvl;
  331. _comFosterBottom.m_txtMaxLv.text = maxLv.ToString();
  332. _comFosterBottom.m_txtCurLv.text = _showLv.ToString();
  333. _comFosterBottom.m_txtMaxExp.text = cardLvCfg.needExp.ToString();
  334. _comFosterBottom.m_txtCurExp.text = _showExp.ToString();
  335. _comFosterBottom.m_ctrlFullLv.selectedIndex = CardDataManager.isFullLv(_cardData.id, _cardData.lv, false) ? 1 : 0;
  336. if (isPreview == true)
  337. {
  338. return;
  339. }
  340. _comFosterBottom.m_listLvConsume.numItems = upgradeCardItemsArr.Length;
  341. }
  342. private void RenderListLvConsumeItem(int index, GObject obj)
  343. {
  344. UI_ComConsume listItem = UI_ComConsume.Proxy(obj);
  345. CardLvlCfg cardLvCfg = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, _cardData.lv);
  346. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(upgradeCardItemsArr[index]);
  347. listItem.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  348. listItem.m_txtNum.text = ItemDataManager.GetItemNum(itemCfg.id).ToString();
  349. listItem.m_txtUseCount.text = "0";
  350. listItem.target.data = index;
  351. _listEffectHolder.Add(listItem.m_holderTouch);
  352. if (listItem.m_btnMinus.data == null)
  353. {
  354. listItem.m_btnMinus.onTouchBegin.Add(OnClickItemConsumsBegin);
  355. listItem.m_btnMinus.onTouchEnd.Add(OnClickItemLvConsumsEnd);
  356. }
  357. if (listItem.m_loaBg.data == null)
  358. {
  359. listItem.m_loaBg.onTouchBegin.Add(OnClickItemConsumsBegin);
  360. listItem.m_loaBg.onTouchEnd.Add(OnClickItemLvConsumsEnd);
  361. // LongPressGesture longPressGesture = new LongPressGesture(listItem.m_loaBg);
  362. // longPressGesture.once = true;
  363. // LongPressGesture.TRIGGER = 1f;
  364. // longPressGesture.onAction.Add(OnClickItemLvConsumsEnd);
  365. // // longPressGesture.onEnd.Add(OnLongEnd);
  366. // _listLongPress.Add(longPressGesture);
  367. }
  368. listItem.m_btnMinus.data = 0;
  369. listItem.m_loaBg.data = 1;
  370. UI_ComConsume.ProxyEnd();
  371. }
  372. private void OnClickItemConsumsBegin(EventContext context)
  373. {
  374. // GObject obj, int type
  375. GObject sender = context.sender as GObject;
  376. int type = (int)sender.data;
  377. GObject obj = sender.parent;
  378. // UI_ComConsume listItem = UI_ComConsume.Proxy(obj);
  379. int index = (int)obj.data;// (int)listItem.target.data;
  380. int itemId = upgradeCardItemsArr[index];
  381. _consumeSelectItem = obj;
  382. _consumeSelectIndex = type;
  383. if (type == 1)
  384. {
  385. if (IsUpLvLimit(itemId)) return;
  386. if (ItemDataManager.GetItemNum(itemId) == 0)
  387. {
  388. object[] sourceDatas = new object[] { itemId, new object[] { ViewName.CARD_FOSTER_VIEW, _cardData } };
  389. GoodsItemTipsController.ShowItemTips(itemId, sourceDatas);
  390. }
  391. }
  392. OnTimedEvent(null);
  393. Timers.inst.Add(0.3f, 0, OnTimedEvent);
  394. EffectUIPool.Recycle(_effectUI5);
  395. _effectUI5 = EffectUIPool.CreateEffectUI(_listEffectHolder[index], "ui_Activity", "SX_DianJi");
  396. }
  397. private void OnTimedEvent(object param)
  398. {
  399. _selectTimeCount += _delay;
  400. if (_selectTimeCount >= 900)//大于900毫秒才算长按
  401. {
  402. if (_consumeSelectIndex == 0)
  403. {
  404. UI_ComConsume listItem = UI_ComConsume.Proxy(_consumeSelectItem);
  405. bool pointIsOnComponent = CommonUtil.Instance.CheckPointIsOnComponent(listItem.m_btnMinus, CommonUtil.Instance.GetMouseV2Point());
  406. UI_ComConsume.ProxyEnd();
  407. if (!pointIsOnComponent)
  408. {
  409. Timers.inst.Remove(OnTimedEvent);
  410. return;
  411. }
  412. this.OnClickBtnMinus(_consumeSelectItem);
  413. }
  414. else
  415. {
  416. int index = (int)_consumeSelectItem.data;
  417. int itemId = upgradeCardItemsArr[index];
  418. if (!CommonUtil.Instance.CheckPointIsOnComponent(_consumeSelectItem, CommonUtil.Instance.GetMouseV2Point()) || IsUpLvLimit(itemId))
  419. {
  420. Timers.inst.Remove(OnTimedEvent);
  421. return;
  422. }
  423. this.OnClickBtnPlusLvConsume(_consumeSelectItem);
  424. }
  425. }
  426. }
  427. private void OnClickItemLvConsumsEnd()
  428. {
  429. Timers.inst.Remove(OnTimedEvent);
  430. _selectTimeCount = 0;
  431. if (_consumeSelectIndex == 0)
  432. {
  433. this.OnClickBtnMinus(_consumeSelectItem);
  434. }
  435. else
  436. {
  437. this.OnClickBtnPlusLvConsume(_consumeSelectItem);
  438. }
  439. }
  440. //返回值为此材料是否可继续消耗此材料继续升级
  441. private bool OnClickBtnPlusLvConsume(GObject obj, bool showTips = true)
  442. {
  443. UI_ComConsume listItem = UI_ComConsume.Proxy(obj);
  444. int index = (int)obj.data;
  445. int itemId = upgradeCardItemsArr[index];
  446. if (itemsCount[index] == ItemDataManager.GetItemNum(itemId))
  447. {
  448. Timers.inst.Remove(OnTimedEvent);
  449. return false;
  450. }
  451. int maxLv = CardRarityCfgArray.Instance.GetCfg(_cardData.itemCfg.rarity).maxCardLvl;
  452. int needExp = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, _showLv).needExp;
  453. if (_showLv == maxLv && _comFosterBottom.m_barLv.value >= needExp)
  454. {
  455. Timers.inst.Remove(OnTimedEvent);
  456. if (showTips == true)
  457. {
  458. PromptController.Instance.ShowFloatTextPrompt("已达到最大等级");
  459. }
  460. return false;
  461. }
  462. if (IsUpLvLimit(itemId, false)) return false;
  463. itemsCount[index] = itemsCount[index] + 1;
  464. listItem.m_txtUseCount.text = itemsCount[index].ToString();
  465. UI_ComConsume.ProxyEnd();
  466. this.UpdatePreView();
  467. return true;
  468. }
  469. private void OnClickBtnMinus(GObject obj)
  470. {
  471. UI_ComConsume listItem = UI_ComConsume.Proxy(obj);
  472. int index = (int)listItem.target.data;
  473. if (itemsCount[index] == 0)
  474. {
  475. Timers.inst.Remove(OnTimedEvent);
  476. return;
  477. }
  478. itemsCount[index] = itemsCount[index] - 1;
  479. listItem.m_txtUseCount.text = itemsCount[index].ToString();
  480. UI_ComConsume.ProxyEnd();
  481. this.UpdatePreView();
  482. }
  483. private void UpdatePreView()
  484. {
  485. int count = 0;//消耗金币数量
  486. int hasExp = 0;//消耗材料提升的总经验
  487. for (int i = 0; i < itemsCount.Count; i++)
  488. {
  489. if (itemsCount[i] == 0) continue;
  490. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(upgradeCardItemsArr[i]);
  491. count += itemCfg.cardUpLvGoldsArr[_cardData.itemCfg.rarity - 1][1] * itemsCount[i];
  492. hasExp += itemCfg.cardUpLvExp * itemsCount[i];
  493. }
  494. _comLvConsumeGold = UI_ComCost.Proxy(_comFosterBottom.m_ComLvConsumeGold);
  495. _comLvConsumeGold.m_txtNeed.text = count.ToString();
  496. UI_ComCost.ProxyEnd();
  497. _comFosterBottom.m_btnClearAll.visible = hasExp > 0;
  498. int previewLv = 0;
  499. int previewExp = 0;
  500. CardDataManager.GetPreViewLvAndExp(_cardData.id, _cardData.lv, _cardData.exp, hasExp, out previewLv, out previewExp);
  501. this.UpdateUpLvView(true, previewLv, previewExp);
  502. }
  503. private void OnClcikBtnAll()
  504. {
  505. int cardUpLvGoldsNeed = 0;
  506. for (int i = 0; i < itemsCount.Count; i++)
  507. {
  508. int[] cardUpLvGolds = ItemCfgArray.Instance.GetCfg(upgradeCardItemsArr[i]).cardUpLvGoldsArr[_cardData.itemCfg.rarity - 1];
  509. long itemNum = ItemDataManager.GetItemNum(upgradeCardItemsArr[i]);
  510. for (long j = 0; j < itemNum; j++)
  511. {
  512. if (ItemDataManager.GetItemNum(cardUpLvGolds[0]) < cardUpLvGoldsNeed + cardUpLvGolds[1] || this.OnClickBtnPlusLvConsume(_comFosterBottom.m_listLvConsume.GetChildAt(i), false) == false)
  513. {
  514. break;
  515. }
  516. cardUpLvGoldsNeed += cardUpLvGolds[1];
  517. }
  518. }
  519. }
  520. private void OnClcikBtnClearAll()
  521. {
  522. this.ClearItemsCountList();
  523. _comFosterBottom.m_listLvConsume.numItems = upgradeCardItemsArr.Length;
  524. this.UpdatePreView();
  525. }
  526. private void OnClickBtnUpLv()
  527. {
  528. if (_effectUI7 != null)
  529. {
  530. EffectUIPool.Recycle(_effectUI7);
  531. _effectUI7 = null;
  532. }
  533. //按钮点击特效
  534. _effectUI7 = EffectUIPool.CreateEffectUI(_ui.m_ComFosterBottom.m_holderTouchFlower, "ui_Activity", "SX_DJ");
  535. int itemMoneyId = ItemCfgArray.Instance.GetCfg(upgradeCardItemsArr[0]).cardUpLvGoldsArr[_cardData.itemCfg.rarity - 1][0];
  536. _comLvConsumeGold = UI_ComCost.Proxy(_comFosterBottom.m_ComLvConsumeGold);
  537. int itemMoneyNum = int.Parse(_comLvConsumeGold.m_txtNeed.text);
  538. UI_ComCost.ProxyEnd();
  539. if (itemMoneyNum == 0)
  540. {
  541. PromptController.Instance.ShowFloatTextPrompt("未选择升级材料");
  542. return;
  543. }
  544. if (!ItemUtil.CheckItemEnough(itemMoneyId, itemMoneyNum))
  545. {
  546. long has = ItemDataManager.GetItemNum(itemMoneyId);
  547. ItemUtil.BuyCurrency(itemMoneyId, itemMoneyNum - has);
  548. return;
  549. }
  550. this.UpLv();
  551. }
  552. private async void UpLv()
  553. {
  554. // itemsCount.Clear();
  555. int allConsume = 0;
  556. for (int i = 0; i < itemsCount.Count; i++)
  557. {
  558. allConsume += itemsCount[i];
  559. }
  560. if (allConsume == 0)
  561. {
  562. PromptController.Instance.ShowFloatTextPrompt("未选中任何材料");
  563. return;
  564. }
  565. if (CardDataManager.isFullLv(_cardData.id, _cardData.lv) == false)
  566. {
  567. int lv = _cardData.lv;
  568. bool result = await CardSProxy.UpgradeCardLvl(_cardData.id, itemsCount);
  569. if (result)
  570. {
  571. if (_showLv - lv >= 1)
  572. {
  573. // this._selectTab = _comFosterBottom.m_ctrlTab.selectedIndex;
  574. ViewManager.Show<CardUpView>(new object[] { _cardData.scores, "lv", lv, _showLv , _cardData.id }, new object[] { ViewName.CARD_FOSTER_VIEW, _cardData });
  575. }
  576. this.UpdateCommon();
  577. this.UpdateUpLvView(false, 0, 0, true);
  578. this.ClearItemsCountList();
  579. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.CI_PAI, 2);
  580. }
  581. }
  582. }
  583. private bool IsUpLvLimit(int itemId, bool showTips = true)
  584. {
  585. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  586. int lvLimit = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl).cardLeverLimit;
  587. int maxLv = CardRarityCfgArray.Instance.GetCfg(_cardData.itemCfg.rarity).maxCardLvl;
  588. lvLimit = Mathf.Min(lvLimit, maxLv);
  589. int needExp = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, lvLimit).needExp;
  590. if (_showLv >= lvLimit && _comFosterBottom.m_barLv.value + itemCfg.cardUpLvExp > needExp)
  591. {
  592. if (!showTips) return true;
  593. int roleLv = RoleDataManager.lvl;
  594. for (int i = roleLv + 1; i < RoleLevelCfgArray.Instance.dataArray.Length; i++)
  595. {
  596. int limit = RoleLevelCfgArray.Instance.GetCfg(i).cardLeverLimit;
  597. if (_showLv < limit)
  598. {
  599. roleLv = i;
  600. break;
  601. }
  602. }
  603. if(_showLv < maxLv)
  604. PromptController.Instance.ShowFloatTextPrompt(string.Format("角色等级达到{0}级可继续升级词牌", roleLv));
  605. return true;
  606. }
  607. return false;
  608. }
  609. /***********************************************************升星***************************************************/
  610. private void UpdateUpStarView()
  611. {
  612. CardStarCfg cardStarCfg = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(_cardData.id, _cardData.star);
  613. if (cardStarCfg == null)
  614. {
  615. ET.Log.Error("词牌:" + _cardData.id + " 无" + _cardData.star + "星升星配置");
  616. return;
  617. }
  618. //升星后星数正5才不进入
  619. if (refDodgeStar || _cardData.star % 5 != 0) {
  620. UpdateUpStarOfStarAndText();
  621. }
  622. refDodgeStar = true;
  623. if (CardDataManager.isFullStar(_cardData.id, _cardData.star, false))
  624. {
  625. _comFosterBottom.m_ctrlFullStar.selectedIndex = 1;
  626. _comFosterBottom.m_listShowCard.data = _cardData.resources;
  627. _comFosterBottom.m_listShowCard.numItems = _cardData.resources.Count;
  628. return;
  629. }
  630. else
  631. {
  632. _comFosterBottom.m_ctrlFullStar.selectedIndex = 0;
  633. // List<CardStarCfg> starCfgs = CardStarCfgArray.Instance.GetCfgsBycardId(_cardData.id);
  634. _comFosterBottom.m_btnUpStar.data = 0;//data 0:材料不足,1:可以升级
  635. ItemUtil.UpdateItemNeedNum(_comFosterBottom.m_comStarCousumeGold, cardStarCfg.costID, cardStarCfg.costNum);
  636. _comFosterBottom.m_listStarConsume.data = cardStarCfg;
  637. _comFosterBottom.m_listStarConsume.numItems = cardStarCfg.materiarsArr.Length;
  638. _comFosterBottom.m_txtTips.text = _cardData.lv < cardStarCfg.needLv ? string.Format("需等级达到{0}级", cardStarCfg.needLv) : "";
  639. _comFosterBottom.m_comStarCousumeGold.visible = _cardData.lv >= cardStarCfg.needLv;
  640. _comFosterBottom.m_btnUpStar.grayed = int.Parse(_comFosterBottom.m_btnUpStar.data.ToString()) == 0 ? true : false;
  641. // _comFosterBottom.m_btnUpStar.GetChild("ani").asMovieClip.visible = false;// !_comFosterBottom.m_btnUpStar.grayed;
  642. }
  643. }
  644. private void UpdateUpStarOfStarAndText()
  645. {
  646. UpdateUpStarOfStar();
  647. UpdateUpStarOfText();
  648. }
  649. private void UpdateUpStarOfStar()
  650. {
  651. int starLevelDodge = _cardData.star / wordNumber;
  652. for (int i = 0; i < wordRow; i++)
  653. {
  654. UI_ComDodgeStar dodgeStar = UI_ComDodgeStar.Proxy(_comFosterBottom.target.GetChild("dodgeStar" + i));
  655. dodgeStar.m_lightType.selectedIndex = (starLevelDodge > i) ? 1 : 0;
  656. UI_ComDodgeStar.ProxyEnd();
  657. }
  658. }
  659. private void UpdateUpStarOfText()
  660. {
  661. int starLevel = _cardData.star / wordNumber;
  662. if (starLevel >= wordRow)
  663. starLevel = wordRow - 1;
  664. int index = starLevel * wordNumber;
  665. UI_ComStarItem comStarItem = UI_ComStarItem.Proxy(_comFosterBottom.target.GetChild("comStarItem"));
  666. string starDesc = "";
  667. for (int j = 0; j < _cardData.itemCfg.starDescArr[starLevel].Length; j++)
  668. {
  669. index++;
  670. string str = _cardData.itemCfg.starDescArr[starLevel][j].ToString();
  671. if (j < _cardData.itemCfg.starDescArr[starLevel].Length - 1)
  672. str += " /";
  673. starDesc += index <= _cardData.star ? StringUtil.GetColorText(str, "#E5892F") : StringUtil.GetColorText(str, "#C8B693");
  674. }
  675. comStarItem.m_txtContent.text = starDesc;
  676. UI_ComStarItem.ProxyEnd();
  677. }
  678. private void RenderListStarConsumeItem(int index, GObject obj)
  679. {
  680. UI_ComItem listItem = UI_ComItem.Proxy(obj);
  681. CardStarCfg cardStarCfg = listItem.target.parent.data as CardStarCfg;
  682. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cardStarCfg.materiarsArr[index][0]);
  683. listItem.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  684. listItem.m_CountType.selectedIndex = 1;
  685. listItem.m_ButtonType.selectedIndex = 0;
  686. listItem.m_QualityType.selectedIndex = 4;
  687. int needCount = cardStarCfg.materiarsArr[index][1];
  688. long hasCount = ItemDataManager.GetItemNum(cardStarCfg.materiarsArr[index][0]);
  689. listItem.m_txtDecomCount.text = StringUtil.GetColorText(hasCount.ToString(), hasCount < needCount ? "#D27869" : "#FFFFFF");// StringUtil.GetColorText(needCount.ToString(), hasCount < needCount ? "#D27869" : "#FDF3D7"); ;
  690. listItem.m_txtDecomHasCount.text = "/" + needCount.ToString(); //; hasCount.ToString();
  691. if (listItem.target.data == null)
  692. {
  693. listItem.target.onClick.Add(() => OnClickBtnPlusStarConsum(index));
  694. }
  695. // listItem.m_btnPlus.data = cardStarCfg.materiarsArr[index][0];
  696. listItem.target.data = cardStarCfg.materiarsArr[index][0];
  697. _comFosterBottom.m_btnUpStar.data = hasCount >= needCount && ItemDataManager.GetItemNum(cardStarCfg.costID) >= cardStarCfg.costNum ? 1 : 0;
  698. if (hasCount < needCount)
  699. {
  700. //材料不足显示加号
  701. listItem.m_ButtonType.selectedIndex = 2;
  702. }
  703. }
  704. private void RenderListShowCardItem(int index, GObject obj)
  705. {
  706. GButton listItem = obj as GButton;
  707. GLoader loaStarCard = UI_ComStarCard.Proxy(listItem.GetChild("ComStarCard")).m_loaStarCard;
  708. // string res = (listItem.parent.data as List<string>)[index];
  709. if (index == _cardData.resIndex)
  710. {
  711. _comFosterBottom.m_listShowCard.selectedIndex = index;
  712. }
  713. loaStarCard.url = ResPathUtil.GetCardIconPath(_cardData.resources[index]);
  714. listItem.data = index;
  715. }
  716. private async void OnClickShowCardListItem(EventContext context)
  717. {
  718. int resIndex = (int)(context.data as GObject).data;
  719. if (resIndex != _cardData.resIndex)
  720. {
  721. bool result = await CardSProxy.ChangeCardRes(_cardData.id, resIndex);
  722. if (result)
  723. {
  724. this.UpdateCommon();
  725. this.UpdateCardRes();
  726. }
  727. }
  728. }
  729. private void OnClickBtnPlusStarConsum(int index)
  730. {
  731. int itemId = int.Parse(UI_ComStarConsume.Proxy(_comFosterBottom.m_listStarConsume.GetChildAt(index)).target.data.ToString());
  732. //ViewManager.Show<ApproachOfItemView>(new object[] { itemId, new object[] { ViewName.CARD_FOSTER_VIEW, _cardData } });
  733. object[] sourceDatas = new object[] { itemId, new object[] { ViewName.CARD_FOSTER_VIEW, _cardData } };
  734. GoodsItemTipsController.ShowItemTips(itemId, sourceDatas);
  735. }
  736. private void OnClickBtnUpStar()
  737. {
  738. if (_effectUI7 != null)
  739. {
  740. EffectUIPool.Recycle(_effectUI7);
  741. _effectUI7 = null;
  742. }
  743. //按钮点击特效
  744. _effectUI7 = EffectUIPool.CreateEffectUI(_ui.m_ComFosterBottom.m_holderTouchFlower, "ui_Activity", "SX_DJ");
  745. CardStarCfg cardStarCfg = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(_cardData.id, _cardData.star);
  746. if (_cardData.lv < cardStarCfg.needLv)
  747. {
  748. PromptController.Instance.ShowFloatTextPrompt("词牌等级不足");
  749. return;
  750. }
  751. if (CardDataManager.isFullStar(_cardData.id, _cardData.star) == true)
  752. {
  753. return;
  754. }
  755. if (!ItemUtil.CheckItemEnough(cardStarCfg.costID, cardStarCfg.costNum))
  756. {
  757. long has = ItemDataManager.GetItemNum(cardStarCfg.costID);
  758. ItemUtil.BuyCurrency(cardStarCfg.costID, cardStarCfg.costID - has);
  759. return;
  760. }
  761. for (int i = 0; i < cardStarCfg.materiarsArr.Length; i++)
  762. {
  763. if (!ItemUtil.CheckItemEnough(cardStarCfg.materiarsArr[i][0], cardStarCfg.materiarsArr[i][1], true)) return;
  764. }
  765. this.UpStar();
  766. }
  767. private async void UpStar()
  768. {
  769. bool result = await CardSProxy.UpgradeCardStar(_cardData.id);
  770. if (result)
  771. {
  772. UpdateCommon();
  773. refDodgeStar = false;
  774. UpdateUpStarView();
  775. UpdateCardRes();
  776. // this._selectTab = _comFosterBottom.m_ctrlTab.selectedIndex;
  777. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.CI_PAI, 2);
  778. UpdateRedDot();
  779. if (_cardData.star % 5 == 0) {
  780. int starLevelDodge = _cardData.star / wordNumber;
  781. int starLevel = _cardData.star / wordNumber - 1;
  782. UI_ComStarItem comStarItem = UI_ComStarItem.Proxy(_comFosterBottom.target.GetChild("comStarItem"));
  783. string starDesc = "";
  784. for (int j = 0; j < _cardData.itemCfg.starDescArr[starLevel].Length; j++)
  785. {
  786. string str = _cardData.itemCfg.starDescArr[starLevel][j].ToString();
  787. if (j < _cardData.itemCfg.starDescArr[starLevel].Length - 1)
  788. str += " /";
  789. starDesc += str;
  790. }
  791. comStarItem.m_txtContent.text = StringUtil.GetColorText(starDesc, "#E5892F");
  792. UI_ComStarItem.ProxyEnd();
  793. Timers.inst.Add(0.1f, 1, EffectTxetDisappear);
  794. }
  795. else
  796. OpenCardUp("starNormal");
  797. }
  798. }
  799. private void EffectTxetDisappear(object param)
  800. {
  801. if (_effectUI8 != null)
  802. {
  803. EffectUIPool.Recycle(_effectUI8);
  804. _effectUI8 = null;
  805. }
  806. //升星字体特效
  807. _effectUI8 = EffectUIPool.CreateEffectUI(_ui.m_ComFosterBottom.m_holderUpStar, "ui_Activity", "SX_Text_01");
  808. _ui.m_ComFosterBottom.m_starItemAlpha.Play();
  809. Timers.inst.Add(0.3f, 1, EffectTaril);
  810. }
  811. private void EffectTaril(object param)
  812. {
  813. if (_effectUI9 != null)
  814. {
  815. EffectUIPool.Recycle(_effectUI9);
  816. _effectUI9 = null;
  817. }
  818. int starLevelDodge = _cardData.star / wordNumber;
  819. UI_ComDodgeStar dodgeStar = UI_ComDodgeStar.Proxy(_comFosterBottom.target.GetChild("dodgeStar" + (starLevelDodge - 1)));
  820. //升星字体拖尾特效
  821. _effectUI9 = EffectUIPool.CreateEffectUI(dodgeStar.m_holderUpStarMove, "ui_Activity", "SX_Text_Taril_02");
  822. UI_ComDodgeStar.ProxyEnd();
  823. UpdateUpStarOfText();
  824. Timers.inst.Add(1.4f, 1, EffectStar);
  825. }
  826. private void EffectStar(object param)
  827. {
  828. if (_effectUI9 != null)
  829. {
  830. EffectUIPool.Recycle(_effectUI9);
  831. _effectUI9 = null;
  832. }
  833. if (_effectUI10 != null)
  834. {
  835. EffectUIPool.Recycle(_effectUI10);
  836. _effectUI10 = null;
  837. }
  838. int starLevelDodge = _cardData.star / wordNumber;
  839. UI_ComDodgeStar dodgeStar = UI_ComDodgeStar.Proxy(_comFosterBottom.target.GetChild("dodgeStar" + (starLevelDodge - 1)));
  840. //星星特效
  841. _effectUI10 = EffectUIPool.CreateEffectUI(dodgeStar.m_holderStarLight, "ui_Activity", "SX_Text_STAR_03");
  842. UI_ComDodgeStar.ProxyEnd();
  843. Timers.inst.Add(0.7f, 1, (obj) =>
  844. {
  845. if (_effectUI10 != null)
  846. {
  847. EffectUIPool.Recycle(_effectUI10);
  848. _effectUI10 = null;
  849. }
  850. UpdateUpStarOfStar();
  851. OpenCardUp("star");
  852. });
  853. }
  854. private void OpenCardUp(string strType)
  855. {
  856. ViewManager.Show<CardUpView>(new object[] { _cardData.scores, strType, _cardData.star - 1, _cardData.star, _cardData.id }, new object[] { ViewName.CARD_FOSTER_VIEW, _cardData });
  857. }
  858. /***********************************************************升技能***************************************************/
  859. private void UpdateUpSkillView()
  860. {
  861. // RedDotController.Instance.SetComRedDot(_ui.m_ComFosterBottom.m_btnSkill, RedDotDataManager.Instance.GetCardSkillsRed(_cardData.id));
  862. _comFosterBottom.m_listSkill.numItems = PassivitySkillCfgArray.Instance.GetCfgsBycardId(_cardData.id).Count;
  863. _comFosterBottom.m_ctrlSkillCount.selectedIndex = _comFosterBottom.m_listSkill.numItems;
  864. }
  865. private void RenderListSkillItem(int index, GObject obj)
  866. {
  867. UI_ListSkillItem item = UI_ListSkillItem.Proxy(obj);
  868. PassivitySkillCfg skillCfg = PassivitySkillCfgArray.Instance.GetCfgsBycardId(_cardData.id)[index];
  869. int skillLv = SkillDataManager.Instance.GetCardSkillLv(_cardData.id, skillCfg.skillId);
  870. CardData data = CardDataManager.GetCardDataById(InstanceZonesDataManager.currentCardId);
  871. item.m_loaSkill.url = ResPathUtil.GetCardSkillPath(skillCfg.res);
  872. item.m_txtName.text = skillCfg.name;
  873. item.m_txtLv.text = string.Format("{0}级", skillLv);
  874. PassivitySkillLvlCfg skillLvlCfg = PassivitySkillLvlCfgArray.Instance.GetCfgByskilllvlAndskillId(skillLv, skillCfg.skillId);
  875. // item.m_txtDesc.text = skillLvlCfg.describe;
  876. // item.m_btnUp.visible = PassivitySkillLvlCfgArray.Instance.GetCfgByskilllvlAndskillId(skillLv + 1, skillCfg.skillId) != null;
  877. RedDotController.Instance.SetComRedDot(item.target, RedDotDataManager.Instance.GetCardSkillRed(skillCfg.skillId), "", -10, 10);
  878. if (item.target.data == null)
  879. {
  880. item.target.onClick.Add(OnBtnUpSkill);
  881. }
  882. }
  883. private void OnBtnUpSkill()
  884. {
  885. List<PassivitySkillCfg> skillCfgs = PassivitySkillCfgArray.Instance.GetCfgsBycardId(_cardData.id);
  886. ViewManager.Show<CardSkillView>(new object[] { _cardData.id, skillCfgs[_comFosterBottom.m_listSkill.selectedIndex].skillId });
  887. }
  888. private float touchBeginX = 0;
  889. private void onTouchCardBegin(EventContext context)
  890. {
  891. InputEvent inputEvent = (InputEvent)context.data;
  892. touchBeginX = inputEvent.x;
  893. }
  894. private void onTouchCardEnd(EventContext context)
  895. {
  896. InputEvent inputEvent = (InputEvent)context.data;
  897. float diffValueX = touchBeginX - inputEvent.x;
  898. if (diffValueX > 20 && showCard == false)
  899. {
  900. if (nowIndex < cardList.Count)
  901. OnClickBtnRight();
  902. }
  903. else if (diffValueX < - 20 && showCard == false)
  904. {
  905. if (nowIndex > 0)
  906. OnClickBtnLeft();
  907. }
  908. else if (diffValueX <= 20 && diffValueX >= - 20)
  909. OnClickComCard();
  910. }
  911. private void onTouchImgCardEnd(EventContext context)
  912. {
  913. InputEvent inputEvent = (InputEvent)context.data;
  914. float diffValueX = touchBeginX - inputEvent.x;
  915. if (diffValueX > 20 && showCard == false)
  916. {
  917. if (nowIndex < cardList.Count)
  918. OnClickBtnRight();
  919. }
  920. else if (diffValueX < - 20 && showCard == false)
  921. {
  922. if (nowIndex > 0)
  923. OnClickBtnLeft();
  924. }
  925. else if(diffValueX <= 20 && diffValueX >= - 20)
  926. OnClickLoaCard();
  927. }
  928. private void OnClickLoaCard()
  929. {
  930. if (playAni) return;
  931. playAni = true;
  932. if (!showCard)
  933. {
  934. _ui.m_loaListener1.visible = false;
  935. GTween.To(comCardImgResInitSize, comCardImgResTargetSize, 0.5f).SetTarget(_ui.m_comImgCard.m_ComCardImgRes).OnUpdate((GTweener t) =>
  936. {
  937. _ui.m_comImgCard.m_ComCardImgRes.target.size = t.value.vec2;
  938. });
  939. GTween.To(_ui.m_comImgCard.target.scrollPane.posX, (comCardImgResTargetSize.x - _ui.target.width) / 2, 0.5f).SetTarget(_ui.m_comImgCard.target.scrollPane).OnUpdate((GTweener t) =>
  940. {
  941. _ui.m_comImgCard.target.scrollPane.posX = t.value.x;
  942. });
  943. _ui.m_t0.Play(() =>
  944. {
  945. playAni = false;
  946. });
  947. showCard = true;
  948. }
  949. else
  950. {
  951. _ui.m_loaListener1.visible = true;
  952. _ui.m_t1.SetHook("scale", () =>
  953. {
  954. GTween.To(comCardImgResTargetSize, comCardImgResInitSize, 0.5f).SetTarget(_ui.m_comImgCard.m_ComCardImgRes).OnUpdate((GTweener t) =>
  955. {
  956. _ui.m_comImgCard.m_ComCardImgRes.target.size = t.value.vec2;
  957. });
  958. GTween.To(_ui.m_comImgCard.target.scrollPane.posX, (comCardImgResInitSize.x - _ui.target.width) / 2, 0.5f).SetTarget(_ui.m_comImgCard.target.scrollPane).OnUpdate((GTweener t) =>
  959. {
  960. _ui.m_comImgCard.target.scrollPane.posX = t.value.x;
  961. });
  962. });
  963. _ui.m_t1.Play(() =>
  964. {
  965. playAni = false;
  966. });
  967. showCard = false;
  968. }
  969. }
  970. private void OnClickComCard()
  971. {
  972. if (playAni) return;
  973. playAni = true;
  974. if (showCard)
  975. {
  976. _ui.m_loaListener.visible = true;
  977. _ui.m_comCard.target.scrollPane.SetPercX(0.5f, true);
  978. float scale = _ui.m_comCard.target.scaleX;
  979. _ui.m_t1.SetValue("scale", scale, scale);
  980. _ui.m_t1.SetValue("normal", _cardScale, _cardScale);
  981. _ui.m_t1.Play(() =>
  982. {
  983. playAni = false;
  984. });
  985. showCard = false;
  986. }
  987. else
  988. {
  989. _ui.m_loaListener.visible = false;
  990. float scale = _ui.target.height / 1920;
  991. _ui.m_comCard.target.scrollPane.viewWidth = 1080 / scale;
  992. _ui.m_comCard.target.scrollPane.SetPercX(0.5f, true);
  993. _ui.m_t0.SetValue("scale", scale, scale);
  994. _ui.m_t0.SetValue("normal", _cardScale, _cardScale);
  995. _ui.m_t0.Play(() =>
  996. {
  997. playAni = false;
  998. });
  999. showCard = true;
  1000. }
  1001. }
  1002. private void OnClickBtnStroy()
  1003. {
  1004. ViewManager.Show<CardStoryView>(_cardData);
  1005. }
  1006. private void OnChangeCtrlTab()
  1007. {
  1008. // _comLvConsumeGold = UI_ComCostCurrency.Proxy(_comFosterBottom.m_ComLvConsumeGold);
  1009. this.UpdateCommon();
  1010. if (_comFosterBottom.m_ctrlTab.selectedIndex == 0)
  1011. {
  1012. this.ClearItemsCountList();
  1013. this.UpdateUpLvView();
  1014. }
  1015. else if (_comFosterBottom.m_ctrlTab.selectedIndex == 1)
  1016. {
  1017. GuideCfg guideCfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.UP_CARD_STAR);
  1018. if (!InstanceZonesDataManager.CheckLevelPass(guideCfg.storyLevelId - 1))//防止升星引导前将材料耗光
  1019. {
  1020. PromptController.Instance.ShowFloatTextPrompt("功能未开启");
  1021. _comFosterBottom.m_ctrlTab.selectedIndex = _comFosterBottom.m_ctrlTab.previsousIndex;
  1022. return;
  1023. }
  1024. this.UpdateUpStarView();
  1025. }
  1026. else
  1027. {
  1028. this.UpdateUpSkillView();
  1029. }
  1030. this._selectTab = _comFosterBottom.m_ctrlTab.selectedIndex;
  1031. }
  1032. private void UpdateItemChange()
  1033. {
  1034. _ui.m_ComFosterBottom.m_listLvConsume.numItems = _ui.m_ComFosterBottom.m_listLvConsume.numItems;
  1035. this.UpdateUpStarView();
  1036. this.UpdateUpSkillView();
  1037. }
  1038. private void OnBtnStarRewardClick()
  1039. {
  1040. ViewManager.Show<CardStarRewardView>(_cardStarRewards);
  1041. }
  1042. private void OnClickBtnBack()
  1043. {
  1044. ViewManager.GoBackFrom(ViewName.CARD_FOSTER_VIEW);
  1045. this._selectTab = 0;
  1046. }
  1047. private void UpdateRedDot()
  1048. {
  1049. RedDotController.Instance.SetComRedDot(_ui.m_ComFosterTop.m_btnStarReward, RedDotDataManager.Instance.GetCardStarReward(_cardData.id));
  1050. RedDotController.Instance.SetComRedDot(_ui.m_ComFosterBottom.m_btnUpLv, RedDotDataManager.Instance.GetCardUpLvRed(_cardData.id), "", -74, 60);
  1051. RedDotController.Instance.SetComRedDot(_ui.m_ComFosterBottom.m_btnUpStar, RedDotDataManager.Instance.GetCardUpStarRed(_cardData.id), "", -74, 60);
  1052. //RedDotController.Instance.SetComRedDot(_ui.m_ComFosterBottom.m_btnLv, RedDotDataManager.Instance.GetCardUpLvRed(_cardData.id), "", 0, 0);
  1053. //RedDotController.Instance.SetComRedDot(_ui.m_ComFosterBottom.m_btnStar, RedDotDataManager.Instance.GetCardUpStarRed(_cardData.id), "", 0, 0);
  1054. RedDotController.Instance.SetComRedDot(_ui.m_ComFosterBottom.m_btnSkill, RedDotDataManager.Instance.GetCardSkillsRed(_cardData.id), "", 0, 0);
  1055. }
  1056. protected override void OnHide()
  1057. {
  1058. base.OnHide();
  1059. EffectUIPool.Recycle(_effectUI1);
  1060. _effectUI1 = null;
  1061. EffectUIPool.Recycle(_effectUI5);
  1062. _effectUI5 = null;
  1063. EffectUIPool.Recycle(_effectUI6);
  1064. _effectUI6 = null;
  1065. EffectUIPool.Recycle(_effectUI7);
  1066. _effectUI7 = null;
  1067. EffectUIPool.Recycle(_effectUI8);
  1068. _effectUI8 = null;
  1069. EffectUIPool.Recycle(_effectUI9);
  1070. _effectUI9 = null;
  1071. EffectUIPool.Recycle(_effectUI10);
  1072. _effectUI10 = null;
  1073. Timers.inst.Remove(CheckGuide);
  1074. Timers.inst.Remove(OnTimedEvent);
  1075. UI_ComCostCurrency.ProxyEnd();
  1076. UI_ComCostCurrencyWithHas.ProxyEnd();
  1077. // _comFosterBottom.m_listLvConsume.numItems = 0;
  1078. _valueBarController.OnHide();
  1079. _cardStarRewards.Clear();
  1080. }
  1081. protected override void RemoveEventListener()
  1082. {
  1083. base.RemoveEventListener();
  1084. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateUpStarView);
  1085. // EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, OnItemChangeListener);
  1086. EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateItemChange);
  1087. EventAgent.RemoveEventListener(ConstMessage.CARD_UP_SKILL, UpdateUpSkillView);
  1088. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  1089. }
  1090. private void CheckGuide(object param)
  1091. {
  1092. if (GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0
  1093. || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_STAR) <= 0)
  1094. {
  1095. UpdateToCheckGuide(null);
  1096. }
  1097. else
  1098. {
  1099. Timers.inst.Remove(CheckGuide);
  1100. }
  1101. _ui.m_loaGuide.visible = false;
  1102. }
  1103. protected override void UpdateToCheckGuide(object param)
  1104. {
  1105. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  1106. GuideController.TryGuide(_ui.m_ComFosterBottom.m_btnAll, ConstGuideId.UP_CARD_LV, 4, "");
  1107. GuideController.TryGuide(_ui.m_ComFosterBottom.m_btnUpLv, ConstGuideId.UP_CARD_LV, 5, "");
  1108. GuideController.TryGuide(_ui.m_ComFosterTop.m_btnback, ConstGuideId.UP_CARD_LV, 7, "让我们继续新旅程吧~");
  1109. GuideController.TryGuide(_ui.m_ComFosterBottom.m_btnStar, ConstGuideId.UP_CARD_STAR, 4, "");
  1110. GuideController.TryGuide(_ui.m_ComFosterBottom.m_btnUpStar, ConstGuideId.UP_CARD_STAR, 5, "");
  1111. GuideController.TryGuide(_ui.m_ComFosterTop.m_btnback, ConstGuideId.UP_CARD_STAR, 7, "返回主界面");
  1112. }
  1113. protected override void TryCompleteGuide()
  1114. {
  1115. base.TryCompleteGuide();
  1116. GuideController.TryCompleteGuideIndex(ConstGuideId.UP_CARD_LV, 7);
  1117. GuideController.TryCompleteGuide(ConstGuideId.UP_CARD_LV, 7);
  1118. }
  1119. }
  1120. }