MonthlyCardTipsView.cs 4.1 KB

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