MonthlyCardTipsView.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using FairyGUI;
  2. using UI.ActivityMain;
  3. using UI.CommonGame;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using cfg.GfgCfg;
  7. using ET;
  8. namespace GFGGame
  9. {
  10. public class MonthlyCardTipsView : BaseWindow
  11. {
  12. private UI_MonthlyCardTipsUI _ui;
  13. private int rewards = 3;
  14. private List<int> itemID = new List<int>() { 1000005, 1000004, 5005011 };
  15. private List<string> rarity = new List<string>() { "", "wpk_db_fp", "wpk_db_zx", "wpk_db_dc", "wpk_db_ty" };
  16. private List<string> rewardNum = new List<string>() { "x1800", "x300", "专属头像框" };
  17. public override void Dispose()
  18. {
  19. if (_ui != null)
  20. {
  21. _ui.Dispose();
  22. _ui = null;
  23. }
  24. base.Dispose();
  25. }
  26. protected override void OnInit()
  27. {
  28. base.OnInit();
  29. packageName = UI_MonthlyCardTipsUI.PACKAGE_NAME;
  30. _ui = UI_MonthlyCardTipsUI.Create();
  31. this.viewCom = _ui.target;
  32. isfullScreen = true;
  33. modal = true;
  34. _ui.m_rewardList.itemRenderer = ListItemRender;
  35. _ui.m_btnBuyTxt.onClick.Add(OnBtnAdJump);
  36. _ui.m_backBtn.onClick.Add(Hide);
  37. _ui.m_notTips.onClick.Add(OnClickTips);
  38. _ui.m_bg.onClick.Add(Hide);
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. _ui.m_t0.Play();
  44. UpdateView();
  45. }
  46. protected async override void OnHide()
  47. {
  48. bool result;
  49. result = await ActivitySProxy.ReqActivityTips(NumericType.IsPropCzykActivity,
  50. ActivityDataManager.Instance.todayMonthlyCardTips);
  51. base.OnHide();
  52. }
  53. private void UpdateView()
  54. {
  55. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.IsPropCzykActivity) == 0)
  56. {
  57. ActivityDataManager.Instance.todayMonthlyCardTips =
  58. GameGlobal.myNumericComponent.GetAsInt(NumericType.IsPropCzykActivity);
  59. _ui.m_notTips.url = "ui://ActivityMain/ts_jrbzts";
  60. _ui.m_TipImg.visible = false;
  61. }
  62. _ui.m_rewardList.numItems = rewards;
  63. }
  64. private void ListItemRender(int index, GObject obj)
  65. {
  66. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemID[index]);
  67. UI_rewardItem item = UI_rewardItem.Proxy(obj);
  68. if (itemCfg.Rarity != 0)
  69. {
  70. item.m_bg.url = ResPathUtil.GetCommonGameResPath(rarity[itemCfg.Rarity]);
  71. }
  72. else
  73. {
  74. item.m_bg.url = ResPathUtil.GetCommonGameResPath(rarity[1]);
  75. }
  76. if (index == rewards - 1)
  77. {
  78. item.m_icon.url = ResPathUtil.GetIconPath(itemCfg.Res, "png");
  79. }
  80. else
  81. {
  82. item.m_icon.url = ResPathUtil.GetIconPath(itemCfg.Res, "png");
  83. }
  84. item.m_txtNum.text = rewardNum[index];
  85. item.target.data = itemCfg;
  86. item.target.onClick.Add(OnClickItem);
  87. UI_rewardItem.ProxyEnd();
  88. }
  89. private void OnClickTips()
  90. {
  91. if (ActivityDataManager.Instance.todayMonthlyCardTips == 0)
  92. {
  93. _ui.m_TipImg.visible = true;
  94. ActivityDataManager.Instance.todayMonthlyCardTips = 1;
  95. }
  96. else
  97. {
  98. _ui.m_TipImg.visible = false;
  99. ActivityDataManager.Instance.todayMonthlyCardTips = 0;
  100. }
  101. }
  102. private void OnClickItem(EventContext param)
  103. {
  104. GObject comItem = (param.sender as GObject);
  105. ItemCfg itemCfg = comItem.data as ItemCfg;
  106. object[] sourceDatas = new object[]
  107. { itemCfg.Id, new object[] { typeof(BagView).FullName, this.viewData } };
  108. GoodsItemTipsController.ShowItemTips(itemCfg.Id, sourceDatas);
  109. }
  110. private void OnBtnAdJump()
  111. {
  112. ViewManager.Show<StoreView>(new object[]
  113. { ConstStoreTabId.STORE_MONTH_CARD, ConstStoreSubId.STORE_MONTH_GOLD_CARD });
  114. this.Hide();
  115. }
  116. }
  117. }