ReDailySignTipsView.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using ET;
  2. using FairyGUI;
  3. using UI.DailyWelfare;
  4. using System;
  5. using System.Collections.Generic;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. //改弹窗只用与每日签到补签
  10. //public delegate void TipsCallback();
  11. class ReDailySignTipsView : BaseWindow
  12. {
  13. private UI_DailySignRechargeTipsUI _ui;
  14. //private TipsCallback m_leftButtonCallback = null;
  15. //private TipsCallback m_rightButtonCallback = null;
  16. private int itemId = 0;
  17. private string showTipsText = "";
  18. private long hasNum;
  19. private int type;
  20. private int day = 1;
  21. public override void Dispose()
  22. {
  23. if (_ui != null)
  24. {
  25. _ui.Dispose();
  26. _ui = null;
  27. }
  28. base.Dispose();
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. packageName = UI_DailySignRechargeTipsUI.PACKAGE_NAME;
  34. _ui = UI_DailySignRechargeTipsUI.Create();
  35. this.viewCom = _ui.target;
  36. this.modal = true;
  37. this.viewCom.Center();
  38. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  39. _ui.m_btnConfirm.onClick.Add(OnClickBtnConfirm);
  40. _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
  41. //_ui.m_btnCancel.onClick.Add(() =>
  42. //{
  43. // this.Hide();
  44. // m_leftButtonCallback?.Invoke();
  45. //});
  46. //_ui.m_btnConfirm.onClick.Add(() =>
  47. //{
  48. // this.Hide();
  49. // m_rightButtonCallback?.Invoke();
  50. //});
  51. }
  52. protected override void OnShown()
  53. {
  54. base.OnShown();
  55. day = (int)this.viewData;
  56. UpdateView();
  57. }
  58. private void UpdateView()
  59. {
  60. CheckItemId();
  61. }
  62. protected override void OnHide()
  63. {
  64. //m_leftButtonCallback = null;
  65. //m_rightButtonCallback = null;
  66. base.OnHide();
  67. }
  68. private void CheckItemId()
  69. {
  70. int[][] SecondCost = GlobalCfgArray.globalCfg.dailySignConsumeArr;
  71. int[][] FirstCost = GlobalCfgArray.globalCfg.SecDailySignConsumeArr;
  72. int needNum = 1;
  73. hasNum = ItemDataManager.GetItemNum(FirstCost[0][0]);
  74. if(hasNum >= FirstCost[0][1])
  75. {
  76. _ui.m_txtTips.text = string.Format("是否确定花费{0}{1}补签?", FirstCost[0][1], ItemCfgArray.Instance.GetCfg(FirstCost[0][0]).name);
  77. type = 1;
  78. itemId = FirstCost[0][0];
  79. needNum = FirstCost[0][1];
  80. }
  81. else
  82. {
  83. type = 0;
  84. itemId = SecondCost[0][0];
  85. needNum = SecondCost[0][1];
  86. hasNum = ItemDataManager.GetItemNum(SecondCost[0][0]);
  87. _ui.m_txtTips.text = string.Format("{0}不足,是否确定花费{1}{2}补签?", ItemCfgArray.Instance.GetCfg(SecondCost[0][0]).name, SecondCost[0][1], ItemCfgArray.Instance.GetCfg(SecondCost[0][0]).name);
  88. }
  89. ItemUtil.UpdateItemNumAndNeedNum(_ui.m_comCostItem, itemId, needNum, true);
  90. }
  91. private void OnClickBtnCancel()
  92. {
  93. this.Hide();
  94. }
  95. private async void OnClickBtnConfirm()
  96. {
  97. if (!ItemUtil.CheckItemEnough(itemId, (int)hasNum) && itemId == 1000005)
  98. {
  99. long has = ItemDataManager.GetItemNum((int)hasNum);
  100. ItemUtil.BuyCurrency(itemId, (int)hasNum - has);
  101. return;
  102. }
  103. bool result = await DailyWelfareSProxy.ReqReSign(day,type);
  104. this.Hide();
  105. }
  106. }
  107. }