ClothingSyntheticView.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. using UnityEngine;
  2. using UI.ClothingSynthetic;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using System;
  6. using ET;
  7. using System.Collections;
  8. using System.Threading.Tasks;
  9. using YooAsset;
  10. namespace GFGGame
  11. {
  12. public class ClothingSyntheticView : BaseWindow
  13. {
  14. private const int HEAD_Y = 942;
  15. private const int FA_XING_Y = 609;
  16. private const int UPPER_BODY_Y = 383;
  17. private const int LOWER_BODY_Y = 112;
  18. private const int SHOES_Y = -287;
  19. private const int BODY_Y = 289;
  20. private const float HEAD_SCALE = 3f;
  21. private const float FA_XING_SCALE = 2f;
  22. private const float UPPER_BODY_SCALE = 1.5f;
  23. private const float LOWER_BODY_SCALE = 1.4f;
  24. private const float SHOES_SCALE = 2.5f;
  25. private const float BODY_SCALE = 1f;
  26. private const float DURATION = 0.6f;
  27. private readonly int[] HEAD_Y_ARR = new int[] { ConstDressUpItemType.TOU_SHI, ConstDressUpItemType.ER_SHI, ConstDressUpItemType.JING_SHI, ConstDressUpItemType.ZHUANG_RONG };
  28. private readonly int[] FA_XING_Y_ARR = new int[] { ConstDressUpItemType.FA_XING };
  29. private readonly int[] UPPER_BODY_Y_ARR = new int[] { ConstDressUpItemType.NEI_DA, ConstDressUpItemType.SHANG_YI };
  30. private readonly int[] LOWER_BODY_Y_ARR = new int[] { ConstDressUpItemType.XIA_ZHUANG, ConstDressUpItemType.SHOU_SHI };
  31. private readonly int[] SHOES_Y_ARR = new int[] { ConstDressUpItemType.WA_ZI, ConstDressUpItemType.XIE_ZI };
  32. private UI_ClothingSyntheticUI _ui;
  33. private DressUpObjUI _dressUpObjUI;
  34. private ValueBarController _valueBarController;
  35. private GImage _imgSelected;
  36. private int _suitId;
  37. private int _chapterID;
  38. private int _itemId;
  39. private int[] _items;
  40. private int _selectedItemId;
  41. private GComponent _selectedListItem;
  42. private List<ItemData> _materiarsOfSelectedItem;
  43. private UI_MateriasListItem listTypeItem_CloSynthetic;
  44. private UI_Component2 _compMover;
  45. private int _cardID;
  46. public override void Dispose()
  47. {
  48. RemoveSoftMask();
  49. if (_valueBarController != null)
  50. {
  51. _valueBarController.Dispose();
  52. _valueBarController = null;
  53. }
  54. if (_imgSelected != null)
  55. {
  56. _imgSelected.RemoveFromParent();
  57. _imgSelected.Dispose();
  58. }
  59. if (_dressUpObjUI != null)
  60. {
  61. _dressUpObjUI.Dispose();
  62. _dressUpObjUI = null;
  63. }
  64. if (_ui != null)
  65. {
  66. _ui.Dispose();
  67. _ui = null;
  68. }
  69. base.Dispose();
  70. }
  71. protected override void OnInit()
  72. {
  73. base.OnInit();
  74. packageName = UI_ClothingSyntheticListUI.PACKAGE_NAME;
  75. _ui = UI_ClothingSyntheticUI.Create();
  76. this.viewCom = _ui.target;
  77. isfullScreen = true;
  78. //layer = ConstViewLayer.TOP;
  79. isReturnView = true;
  80. //this.clickBlankToClose = false;
  81. _compMover = _ui.m_compHolder.m_compHolder.m_compMover;
  82. _valueBarController = new ValueBarController(_ui.m_valueBar);
  83. _dressUpObjUI = new DressUpObjUI("SceneDressUpSynthetic");
  84. _imgSelected = new GImage();
  85. _imgSelected = UIPackage.CreateObject(UI_ClothingSyntheticUI.PACKAGE_NAME, "hc_kuang_4").asImage;
  86. _ui.m_listClothing.itemRenderer = ListClothingItemRender;
  87. _ui.m_listClothing.onClickItem.Add(OnClickListClothingItem);
  88. _ui.m_listMaterias.itemRenderer = RenderListMateriasItem;
  89. _ui.m_listMaterias.onClickItem.Add(OnClickMateriasItemPlus);
  90. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  91. _ui.m_btnProduction.onClick.Add(OnClickBtnProcuction);
  92. _ui.m_btnHome.onClick.Add(OnClickBtnHome);
  93. _ui.m_cardSyntheticBtn.onClick.Add(OnClickBtnCardSyntheticView);
  94. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
  95. UpdateMaskHeight();
  96. }
  97. protected override void AddEventListener()
  98. {
  99. base.AddEventListener();
  100. EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnItemNumChanged);
  101. }
  102. protected override void OnShown()
  103. {
  104. base.OnShown();
  105. _suitId = 0;
  106. _selectedItemId = 0;
  107. _chapterID = 0;
  108. if (this.viewData != null)
  109. {
  110. _suitId = (int)(this.viewData as object[])[0];
  111. _selectedItemId = (this.viewData as object[]).Length > 1 ? (int)(this.viewData as object[])[1] : 0;
  112. if((this.viewData as object[]).Length > 2)
  113. _chapterID = (int)(this.viewData as object[])[2];
  114. }
  115. UpdateCardSyntheticBtn();
  116. if (DressUpMenuSuitDataManager.chooseClothing > 0)
  117. _selectedItemId = DressUpMenuSuitDataManager.chooseClothing;
  118. _valueBarController.OnShown();
  119. _ui.m_loaBg2.url = ResPathUtil.GetBgImgPath("hc_bj_1");
  120. UpdateClothingList(false);
  121. Timers.inst.AddUpdate(CheckGuide);
  122. }
  123. protected override void OnHide()
  124. {
  125. base.OnHide();
  126. _valueBarController.OnHide();
  127. _ui.m_listMaterias.selectedIndex = 0;
  128. Timers.inst.Remove(CheckGuide);
  129. _dressUpObjUI.dressUpObj.TakeOffAll();
  130. if(_chapterID > 0)
  131. MainStoryDataManager.currentChapterCfgId = _chapterID;
  132. }
  133. protected override void RemoveEventListener()
  134. {
  135. base.RemoveEventListener();
  136. EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, OnItemNumChanged);
  137. }
  138. private void OnClickBtnBack()
  139. {
  140. DressUpMenuSuitDataManager.chooseClothing = 0;
  141. ViewManager.GoBackFrom(typeof(ClothingSyntheticView).FullName);
  142. }
  143. private void OnClickListClothingItem(EventContext context)
  144. {
  145. UpdateSelectedItemInfo(context.data as GComponent, true);
  146. }
  147. private async void OnClickBtnProcuction()
  148. {
  149. if (ItemDataManager.GetItemNum(_selectedItemId) > 0)
  150. {
  151. PromptController.Instance.ShowFloatTextPrompt("不能制作已经拥有的物品");
  152. return;
  153. }
  154. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_selectedItemId);
  155. if (itemCfg == null)
  156. {
  157. ET.Log.Error("OnClickBtnProcuction itemCfg is null");
  158. return;
  159. }
  160. if (!ItemUtil.CheckItemEnough(itemCfg.syntheticCostID, itemCfg.syntheticCostNum))
  161. {
  162. long has = ItemDataManager.GetItemNum(itemCfg.syntheticCostID);
  163. ItemUtil.BuyCurrency(itemCfg.syntheticCostID, itemCfg.syntheticCostNum - has);
  164. return;
  165. }
  166. List<ItemData> materiarsOfSelectedItem = ItemUtil.CreateItemDataList(itemCfg.syntheticMateriarsArr);
  167. for (int i = 0; i < materiarsOfSelectedItem.Count; i++)
  168. {
  169. ItemData itemData = materiarsOfSelectedItem[i];
  170. if (itemData == null || !ItemUtil.CheckItemEnough(itemData.id, itemData.num, true)) return;
  171. }
  172. bool result = await ClothingSyntheticSProxy.ClothtingSynthetic(_selectedItemId);
  173. if (result)
  174. {
  175. _selectedItemId = 0;
  176. UpdateClothingList(true);
  177. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.FU_ZHUANG_HE_CHENG, 2);
  178. Timers.inst.AddUpdate(CheckGuide);
  179. // 发送服装合成成功事件
  180. EventAgent.DispatchEvent(ConstMessage.CLOTHING_SYNTHETIC_SUCCESS);
  181. EventAgent.DispatchEvent(ConstMessage.STUDIO_FILING_UPDATE);
  182. }
  183. }
  184. private void ListClothingItemRender(int index, GObject item)
  185. {
  186. UI_ClothingListItem listItem = UI_ClothingListItem.Proxy(item);
  187. int itemId = _items[index];
  188. listItem.target.data = itemId;
  189. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  190. listItem.m_loaderIcon.url = ResPathUtil.GetIconPath(itemCfg);
  191. string itemName = itemCfg.name;
  192. listItem.m_txtName.text = itemName;
  193. listItem.m_imgOwned.visible = ItemDataManager.GetItemNum(itemId) > 0;
  194. RedDotController.Instance.SetComRedDot(listItem.target, RedDotDataManager.Instance.CheckCanSynthetic(itemId), "", -18, 20);
  195. UI_ClothingListItem.ProxyEnd();
  196. }
  197. private EaseType ease = EaseType.CubicOut;
  198. private void UpdateRole(bool tween)
  199. {
  200. // 隐藏遮罩
  201. _ui.m_loaBg2.visible = false;
  202. // 根据高度比例放大(越高越大)
  203. float rate = Screen.height * 1080f / 1920f / Screen.width;
  204. // 平板会比宽手机更宽,设定最小值防止缩小
  205. rate = Mathf.Max(rate, 1);
  206. _dressUpObjUI.dressUpObj.TakeOffAll();
  207. _dressUpObjUI.ResetSceneObj(45, true, true, null, false);
  208. _dressUpObjUI.dressUpObj.AddOrRemove(_selectedItemId, true, DressUpOption.Add);
  209. //_imgSelected.visible = _dressUpObjUI.dressUpObj.CheckDressUpItemIsOn(_selectedItemId);
  210. _imgSelected.visible = true;
  211. _dressUpObjUI.UpdateWrapper(_compMover.m_holder);
  212. int type = ItemUtilCS.GetItemSubType(_selectedItemId);
  213. float duration = DURATION;
  214. if (!tween)
  215. {
  216. duration = 0;
  217. _ui.m_hide.Play();
  218. }
  219. var dy = _ui.m_compHolder.target.height - 642;
  220. if (Array.IndexOf(HEAD_Y_ARR, type) >= 0)
  221. {
  222. _compMover.target.TweenMoveY(HEAD_Y + dy, duration).SetEase(ease);
  223. _compMover.target.TweenScale(new Vector2(HEAD_SCALE * rate, HEAD_SCALE * rate), duration).SetEase(ease);
  224. }
  225. else if (Array.IndexOf(FA_XING_Y_ARR, type) >= 0)
  226. {
  227. _compMover.target.TweenMoveY(FA_XING_Y + dy, duration).SetEase(ease);
  228. _compMover.target.TweenScale(new Vector2(FA_XING_SCALE * rate, FA_XING_SCALE * rate), duration).SetEase(ease);
  229. }
  230. else if (Array.IndexOf(UPPER_BODY_Y_ARR, type) >= 0)
  231. {
  232. _ui.m_compHolder.m_compHolder.m_compMover.target.TweenMoveY(UPPER_BODY_Y + dy, duration).SetEase(ease);
  233. _compMover.target.TweenScale(new Vector2(UPPER_BODY_SCALE * rate, UPPER_BODY_SCALE * rate), duration).SetEase(ease);
  234. }
  235. else if (Array.IndexOf(LOWER_BODY_Y_ARR, type) >= 0)
  236. {
  237. _ui.m_loaBg2.visible = true;
  238. _compMover.target.TweenMoveY(LOWER_BODY_Y + dy, duration).SetEase(ease);
  239. _compMover.target.TweenScale(new Vector2(LOWER_BODY_SCALE * rate, LOWER_BODY_SCALE * rate), duration).SetEase(ease);
  240. }
  241. else if (Array.IndexOf(SHOES_Y_ARR, type) >= 0)
  242. {
  243. _ui.m_loaBg2.visible = true;
  244. _compMover.target.TweenMoveY(SHOES_Y + dy, duration).SetEase(ease);
  245. _compMover.target.TweenScale(new Vector2(SHOES_SCALE * rate, SHOES_SCALE * rate), duration).SetEase(ease);
  246. }
  247. else
  248. {
  249. _compMover.target.TweenMoveY(BODY_Y + dy, duration).SetEase(ease);
  250. _compMover.target.TweenScale(new Vector2(BODY_SCALE * rate, BODY_SCALE * rate), duration).SetEase(ease);
  251. }
  252. if (!tween)
  253. {
  254. Timers.inst.StartCoroutine(DelayShow());
  255. }
  256. }
  257. /// <summary>
  258. /// 延迟一帧 防止闪一下
  259. /// </summary>
  260. /// <returns></returns>
  261. private IEnumerator DelayShow()
  262. {
  263. yield return new WaitForEndOfFrame();
  264. _ui.m_show.Play();
  265. }
  266. private void UpdateClothingList(bool tween)
  267. {
  268. //套装名称
  269. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  270. _ui.m_txtSuitName.text = suitCfg.name;
  271. //进度条
  272. UpdateSuitProgress();
  273. //服装列表
  274. _items = SuitCfgArray.Instance.GetSuitItems(_suitId).Clone() as int[];
  275. ItemUtil.SortItemIdsByOwned(_items);
  276. _ui.m_listClothing.RemoveChildrenToPool();
  277. _ui.m_listClothing.numItems = _items.Length;
  278. if (_ui.m_listClothing.numItems > 0)
  279. {
  280. UI_ClothingListItem listItem = null;
  281. int index = 0;
  282. if (_selectedItemId > 0)
  283. {
  284. int num = _ui.m_listClothing.numChildren;
  285. for (int i = 0; i < num; i++)
  286. {
  287. listItem = UI_ClothingListItem.Proxy(_ui.m_listClothing.GetChildAt(i));
  288. int temp = (int)listItem.target.data;
  289. if (temp == _selectedItemId)
  290. {
  291. index = i;
  292. }
  293. UI_ClothingListItem.ProxyEnd();
  294. }
  295. }
  296. _ui.m_listClothing.ScrollToView(index);
  297. _ui.m_listClothing.selectedIndex = index;
  298. UpdateSelectedItemInfo(_ui.m_listClothing.GetChildAt(index) as GComponent, tween);
  299. }
  300. }
  301. private void UpdateSelectedItemInfo(GComponent listItem, bool tween)
  302. {
  303. _selectedListItem = listItem;
  304. listItem.AddChildAt(_imgSelected, 1);
  305. _selectedItemId = (int)listItem.data;
  306. DressUpMenuSuitDataManager.chooseClothing = _selectedItemId;
  307. UpdateRole(tween);
  308. UpdateSelectedItemInfo();
  309. UpdateCardSyntheticBtn();
  310. }
  311. private void UpdateSelectedItemInfo()
  312. {
  313. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_selectedItemId);
  314. //属性展示
  315. _ui.m_compItemInfo.m_txtName.text = itemCfg.name;
  316. RarityIconController.UpdateRarityIcon(_ui.m_compItemInfo.m_rarity, _selectedItemId, false);
  317. _ui.m_compItemInfo.m_txtGong.text = "" + itemCfg.score1;
  318. _ui.m_compItemInfo.m_txtShang.text = "" + itemCfg.score2;
  319. _ui.m_compItemInfo.m_txtJue.text = "" + itemCfg.score3;
  320. _ui.m_compItemInfo.m_txtZhi.text = "" + itemCfg.score4;
  321. UI_ClothingListItem selectedItem = UI_ClothingListItem.Proxy(_selectedListItem);
  322. selectedItem.m_imgOwned.visible = ItemDataManager.GetItemNum(_selectedItemId) > 0;
  323. UI_ClothingListItem.ProxyEnd();
  324. //合成显示
  325. ItemCfg clothingSyntheticCfg = ItemCfgArray.Instance.GetCfg(_selectedItemId);
  326. // string costName = ItemUtil.GetItemName(clothingSyntheticCfg.syntheticCostID);
  327. // _ui.m_txtCost.SetVar("v1", "" + clothingSyntheticCfg.syntheticCostNum).SetVar("v2", costName).FlushVars();
  328. if (clothingSyntheticCfg.syntheticCostID <= 0)
  329. {
  330. Log.Error($"请为物品 {clothingSyntheticCfg.id} 增加合成相关配置!");
  331. return;
  332. }
  333. ItemUtil.UpdateItemNeedNum(_ui.m_comCostCurrency, clothingSyntheticCfg.syntheticCostID, clothingSyntheticCfg.syntheticCostNum);
  334. _materiarsOfSelectedItem = ItemUtil.CreateItemDataList(clothingSyntheticCfg.syntheticMateriarsArr);
  335. _ui.m_listMaterias.numItems = _materiarsOfSelectedItem.Count;
  336. _ui.m_listMaterias.selectedIndex = 0;
  337. _ui.m_btnProduction.grayed = ItemDataManager.GetItemNum(_selectedItemId) > 0;
  338. }
  339. private void RenderListMateriasItem(int index, GObject obj)
  340. {
  341. UI_MateriasListItem listItem = UI_MateriasListItem.Proxy(obj);
  342. ItemData itemData = _materiarsOfSelectedItem[index];
  343. ItemCfg materiasItemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  344. listItem.m_txtName.text = ItemUtil.GetItemName(itemData.id);
  345. listItem.m_loaderIcon.url = ResPathUtil.GetIconPath(materiasItemCfg);
  346. long num = ItemDataManager.GetItemNum(itemData.id);
  347. ItemCfg materialCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  348. bool isDressUp = materialCfg.itemType == ConstItemType.DRESS_UP;
  349. long numSynthetic = Math.Max(num, 0);
  350. listItem.m_txtProgess.text = numSynthetic + "/" + itemData.num;
  351. listItem.m_loaderIcon.visible = true;
  352. listItem.m_txtProgess.visible = true;
  353. // listItem.target.onClick.Clear();
  354. // if (listItem.target.data == null)
  355. // {
  356. // listItem.target.onClick.Add(OnClickMateriasItemPlus);
  357. // }
  358. listItem.target.data = index;
  359. UI_MateriasListItem.ProxyEnd();
  360. }
  361. private void OnClickMateriasItemPlus(EventContext context)
  362. {
  363. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.CLOTHING_SYNTHETIC);
  364. if (GuideDataManager.currentGuideId == cfg.id)
  365. {
  366. return;
  367. }
  368. if (ItemDataManager.GetItemNum(_selectedItemId) > 0)
  369. {
  370. PromptController.Instance.ShowFloatTextPrompt("该部件已制作完成");
  371. return;
  372. }
  373. int index = (int)(context.data as GObject).data;
  374. _ui.m_listMaterias.selectedIndex = index;
  375. ItemData itemData = _materiarsOfSelectedItem[index];
  376. if (itemData == null)
  377. {
  378. ET.Log.Error("OnClickMateriasItemPlus itemData is null");
  379. return;
  380. }
  381. object[] sourceDatas = new object[] { itemData.id, new object[] { typeof(ClothingSyntheticView).FullName, new object[] { _suitId, _selectedItemId } }, (int)itemData.num };
  382. GoodsItemTipsController.ShowItemTips(itemData.id, sourceDatas);
  383. }
  384. private void OnItemNumChanged()
  385. {
  386. UpdateSuitProgress();
  387. //列表选中项更新
  388. UI_ClothingListItem selectedItem = UI_ClothingListItem.Proxy(_selectedListItem);
  389. selectedItem.m_imgOwned.visible = ItemDataManager.GetItemNum(_selectedItemId) > 0;
  390. UI_ClothingListItem.ProxyEnd();
  391. _ui.m_listClothing.numItems = _ui.m_listClothing.numItems;
  392. UpdateSelectedItemInfo();
  393. }
  394. private void UpdateSuitProgress()
  395. {
  396. //进度条
  397. int count = 0;
  398. int totalCount = 0;
  399. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_suitId, out count, out totalCount);
  400. _ui.m_txtProgress.text = string.Format("{0}/{1}", count, totalCount);
  401. }
  402. private void OnClickBtnHome()
  403. {
  404. GameController.GoBackToMainView();
  405. }
  406. private void CheckGuide(object param)
  407. {
  408. if (GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_SYNTHETIC) <= 0
  409. || (GuideDataManager.IsGuideFinish(ConstGuideId.CARD_HECHENG) <= 0 && IsGetSuit()))
  410. {
  411. UpdateToCheckGuide(null);
  412. }
  413. else
  414. {
  415. Timers.inst.Remove(CheckGuide);
  416. }
  417. }
  418. protected override void UpdateToCheckGuide(object param)
  419. {
  420. if (ViewManager.isViewOpen(typeof(GuideView).Name))
  421. {
  422. (ViewManager.GetUIView(typeof(GuideView).Name) as GuideView).viewCom.visible = !ViewManager.isViewOpen(typeof(GetSuitItemVIew).Name);
  423. }
  424. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  425. int itemId = 10566;
  426. int itemIndex = 0;
  427. for (int i = 0; i < _ui.m_listClothing.numItems; i++)
  428. {
  429. UI_ClothingListItem listItem = UI_ClothingListItem.Proxy(_ui.m_listClothing.GetChildAt(i));
  430. int temp = (int)listItem.target.data;
  431. UI_ClothingListItem.ProxyEnd();
  432. if (temp == itemId)
  433. {
  434. itemIndex = i;
  435. break;
  436. }
  437. }
  438. bool guide = GuideController.TryGuide(_ui.m_listClothing, ConstGuideId.CLOTHING_SYNTHETIC, 3, "找到需要合成的物品。", itemIndex);
  439. if (guide) _ui.m_listClothing.ScrollToView(itemIndex);
  440. GuideController.TryGuide(_ui.m_listMaterias, ConstGuideId.CLOTHING_SYNTHETIC, 4, "这里可以查看合成需要的材料,和材料的获取途径。", 0);
  441. UI_MateriasListItem.ProxyEnd();
  442. GuideController.TryGuide(_ui.m_btnProduction, ConstGuideId.CLOTHING_SYNTHETIC, 5, "点击获得新的服饰。");
  443. GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.CLOTHING_SYNTHETIC, 6, "获得新衣服啦,继续通关主线剧情吧。");
  444. GuideController.TryGuide(_ui.m_cardSyntheticBtn, ConstGuideId.CARD_HECHENG, 1, "领取卡牌。");
  445. GuideController.TryGuide(null, ConstGuideId.CARD_HECHENG, 2, "获得套装卡牌后可进行技能书合成!", -1, true, _ui.target.height - 600);
  446. GuideController.TryGuide(_ui.m_cardSyntheticBtn, ConstGuideId.CARD_HECHENG, 3, "进入卡牌合成");
  447. }
  448. protected override void TryCompleteGuide()
  449. {
  450. base.TryCompleteGuide();
  451. GuideController.TryCompleteGuideIndex(ConstGuideId.CARD_HECHENG, 3);
  452. GuideController.TryCompleteGuide(ConstGuideId.CARD_HECHENG, 3);
  453. }
  454. /// <summary>
  455. /// 按照屏幕尺寸 更新遮罩的高度
  456. /// </summary>
  457. /// <returns></returns>
  458. private async Task UpdateMaskHeight()
  459. {
  460. await Task.Delay(5);
  461. _ui.m_compHolder.m_mask.height = _ui.m_posHelper.height;
  462. SetSoftMask();
  463. }
  464. /// <summary>
  465. /// 创建二层渐变背景遮罩
  466. /// </summary>
  467. private void SetSoftMask()
  468. {
  469. var handle = YooAssets.LoadAssetSync<Material>(ResPathUtil.GetMaterialPath("ImageGradient"));
  470. Material m = handle.AssetObject as Material;
  471. Material copyM = new Material(m.shader);
  472. handle.Release();
  473. copyM.CopyPropertiesFromMaterial(m);
  474. _ui.m_loaBg2.material = copyM;
  475. _ui.m_loaBg2.position = _ui.m_loaBg.position;
  476. float startY = _ui.m_loaBg2Pos.position.y;
  477. float endY = _ui.m_posHelper.position.y + ViewGlobal.GetRealTopOffset();
  478. float rate = 1 - ((Mathf.Abs(startY - endY)) / _ui.m_loaBg2.height);
  479. _ui.m_loaBg2.material.SetFloat("_MinHeight", rate - 0.01f);
  480. _ui.m_loaBg2.material.SetFloat("_MaxHeight", rate - 0.03f);
  481. }
  482. private void RemoveSoftMask()
  483. {
  484. _ui.m_loaBg2.material = null;
  485. }
  486. private void UpdateCardSyntheticBtn()
  487. {
  488. int count = ItemCfgArray.Instance.GetCfgsBysuitId(_suitId).Count - 1;
  489. ItemCfg item = ItemCfgArray.Instance.GetCfgsBysuitId(_suitId)[count];
  490. _cardID = item.id;
  491. int rewardStatus = DressUpMenuSuitDataManager.GetSuitSyntheticRewardStatus(_suitId);
  492. if(item.syntheticTimes > 0)
  493. {
  494. _ui.m_cardSyntheticBtn.visible = true;
  495. if(rewardStatus == 1)
  496. {
  497. _ui.m_cardSyntheticBtn.icon = ResPathUtil.GetIconPath(ItemCfgArray.Instance.GetCfg(_cardID).res,"png");
  498. RedDotController.Instance.SetComRedDot(_ui.m_cardSyntheticBtn, true, "", -18, 20);
  499. }
  500. else
  501. {
  502. _ui.m_cardSyntheticBtn.icon = "ui://ClothingSynthetic/kphc_huimeng";
  503. RedDotController.Instance.SetComRedDot(_ui.m_cardSyntheticBtn, (rewardStatus == 1), "", -18, 20);
  504. }
  505. }
  506. else
  507. {
  508. _ui.m_cardSyntheticBtn.visible = false;
  509. }
  510. }
  511. private async void OnClickBtnCardSyntheticView()
  512. {
  513. int rewardStatus = DressUpMenuSuitDataManager.GetSuitSyntheticRewardStatus(_suitId);
  514. if (DressUpMenuSuitDataManager.CheckHaveSuit(_suitId))
  515. {
  516. if(rewardStatus == 1)
  517. {
  518. bool result = await ClothingSyntheticSProxy.GetSuitGetReward(_suitId);
  519. UpdateCardSyntheticBtn();
  520. }
  521. else
  522. {
  523. ViewManager.Show<CardSyntheticView>(new object[] { _cardID, _selectedItemId });
  524. }
  525. }
  526. else
  527. {
  528. PromptController.Instance.ShowFloatTextPrompt("集齐套装后可领取卡牌奖励");
  529. }
  530. }
  531. private bool IsGetSuit()
  532. {
  533. int count = 0;//套装当前拥有的部件数量
  534. int totalCount = 1;
  535. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_suitId, out count, out totalCount);
  536. if (count >= totalCount)
  537. {
  538. return true;
  539. }
  540. return false;
  541. }
  542. }
  543. }