| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Collections.Generic;
- using cfg.GfgCfg;
- using UI.CommonGame;
- namespace GFGGame
- {
- public class TurnTableTipsView : BaseWindow
- {
- private UI_BuyTipsUI _ui;
- private int _itemId;
- private int _costId;
- private long _count;
- private int _costCount;
- private bool _result = false;
- private Action _onSuccess;
- private bool _showCheck = false;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- BuyTipsController.Dispose();
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui = UI_BuyTipsUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_btnSure.target.onClick.Add(OnClickBtnSure);
- _ui.m_btnCancel.target.onClick.Add(OnClickBtnCancel);
- _ui.m_btnCancel.target.onClick.Add(OnClickBtnCancel);
- _ui.m_btnCheck.onClick.Add(OnBtnCheckClick);
- }
- public void SetParams(int itemId, long count, Action onSuccess = null, bool showCheck = false)
- {
- _itemId = itemId;
- _count = count;
- _onSuccess = onSuccess;
- _showCheck = showCheck;
- }
- protected override void OnShown()
- {
- base.OnShown();
- UpdateView();
- }
- private void UpdateView()
- {
- ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, ItemDataManager.GetItemExchangeTimes(_itemId), (int)_count, out _costId, out _costCount, out int buyNum);
- ItemCfg itemCfg =CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemId);
- _ui.m_txtNeed.text = string.Format("还需要购买{0}个", _count);
- _ui.m_loaNeed.url = ResPathUtil.GetIconPath(itemCfg.Res, "png");
- ItemCfg costCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_costId);
- _ui.m_txtCost.text = string.Format("是否花费{0}{1}购买?", _costCount, costCfg.Name);
- if (_showCheck)
- _ui.m_checkType.selectedIndex = 1;
- else
- _ui.m_checkType.selectedIndex = 0;
- }
- private async void OnClickBtnSure()
- {
- _result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
- if (_result)
- {
- BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(_itemId, _count), _onSuccess);
- }
- this.Hide();
- }
- private void OnClickBtnCancel()
- {
- this.Hide();
- }
- private void OnBtnCheckClick()
- {
- ActivityDataManager.Instance.CHECK_TIPS_OPEN = _ui.m_btnCheck.selected;
- }
- }
- }
|