1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections.Generic;
- using UI.CommonGame;
- namespace GFGGame
- {
- public class BuyTipsView : BaseWindow
- {
- private UI_BuyTipsUI _ui;
- private int _itemId;
- private int _costId;
- private long _count;
- private int _costCount;
- private bool _result = false;
- private Action _onSuccess;
- 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.onClick.Add(OnClickBtnSure);
- _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
- }
- public void SetParams(int itemId, long count, Action onSuccess = null)
- {
- _itemId = itemId;
- _count = count;
- _onSuccess = onSuccess;
- }
- 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 = ItemCfgArray.Instance.GetCfg(_itemId);
- _ui.m_txtNeed.text = string.Format("还需要购买{0}个", _count);
- _ui.m_loaNeed.url = ResPathUtil.GetCommonGameResPath(itemCfg.res);
- ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(_costId);
- _ui.m_txtCost.text = string.Format("是否花费{0}{1}购买?", _costCount, costCfg.name);
- }
- 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();
- }
- }
- }
|