TurnTableTipsView.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using System.Collections.Generic;
  3. using cfg.GfgCfg;
  4. using UI.CommonGame;
  5. namespace GFGGame
  6. {
  7. public class TurnTableTipsView : BaseWindow
  8. {
  9. private UI_BuyTipsUI _ui;
  10. private int _itemId;
  11. private int _costId;
  12. private long _count;
  13. private int _costCount;
  14. private bool _result = false;
  15. private Action _onSuccess;
  16. private bool _showCheck = false;
  17. public override void Dispose()
  18. {
  19. if (_ui != null)
  20. {
  21. _ui.Dispose();
  22. _ui = null;
  23. }
  24. BuyTipsController.Dispose();
  25. base.Dispose();
  26. }
  27. protected override void OnInit()
  28. {
  29. base.OnInit();
  30. _ui = UI_BuyTipsUI.Create();
  31. this.viewCom = _ui.target;
  32. this.viewCom.Center();
  33. this.modal = true;
  34. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  35. _ui.m_btnSure.target.onClick.Add(OnClickBtnSure);
  36. _ui.m_btnCancel.target.onClick.Add(OnClickBtnCancel);
  37. _ui.m_btnCancel.target.onClick.Add(OnClickBtnCancel);
  38. _ui.m_btnCheck.onClick.Add(OnBtnCheckClick);
  39. }
  40. public void SetParams(int itemId, long count, Action onSuccess = null, bool showCheck = false)
  41. {
  42. _itemId = itemId;
  43. _count = count;
  44. _onSuccess = onSuccess;
  45. _showCheck = showCheck;
  46. }
  47. protected override void OnShown()
  48. {
  49. base.OnShown();
  50. UpdateView();
  51. }
  52. private void UpdateView()
  53. {
  54. ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, ItemDataManager.GetItemExchangeTimes(_itemId), (int)_count, out _costId, out _costCount, out int buyNum);
  55. ItemCfg itemCfg =CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemId);
  56. _ui.m_txtNeed.text = string.Format("还需要购买{0}个", _count);
  57. _ui.m_loaNeed.url = ResPathUtil.GetIconPath(itemCfg.Res, "png");
  58. ItemCfg costCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_costId);
  59. _ui.m_txtCost.text = string.Format("是否花费{0}{1}购买?", _costCount, costCfg.Name);
  60. if (_showCheck)
  61. _ui.m_checkType.selectedIndex = 1;
  62. else
  63. _ui.m_checkType.selectedIndex = 0;
  64. }
  65. private async void OnClickBtnSure()
  66. {
  67. _result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
  68. if (_result)
  69. {
  70. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(_itemId, _count), _onSuccess);
  71. }
  72. this.Hide();
  73. }
  74. private void OnClickBtnCancel()
  75. {
  76. this.Hide();
  77. }
  78. private void OnBtnCheckClick()
  79. {
  80. ActivityDataManager.Instance.CHECK_TIPS_OPEN = _ui.m_btnCheck.selected;
  81. }
  82. }
  83. }