|
@@ -0,0 +1,129 @@
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using ET;
|
|
|
+using FairyGUI;
|
|
|
+using UI.Bag;
|
|
|
+using UI.CommonGame;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+namespace GFGGame
|
|
|
+{
|
|
|
+ public class GiftBoxSelectorView : BaseWindow
|
|
|
+ {
|
|
|
+ private UI_GiftBoxSelectorUI _ui;
|
|
|
+ private int _itemId;
|
|
|
+ private long _count;
|
|
|
+ public override void Dispose()
|
|
|
+ {
|
|
|
+ base.Dispose();
|
|
|
+
|
|
|
+ if (_ui != null)
|
|
|
+ {
|
|
|
+ _ui.Dispose();
|
|
|
+ _ui = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnInit()
|
|
|
+ {
|
|
|
+ base.OnInit();
|
|
|
+
|
|
|
+ packageName = UI_GiftBoxSelectorUI.PACKAGE_NAME;
|
|
|
+ _ui = UI_GiftBoxSelectorUI.Create();
|
|
|
+ this.viewCom = _ui.target;
|
|
|
+ this.viewCom.Center();
|
|
|
+ this.modal = true;
|
|
|
+
|
|
|
+ _ui.m_.target.onClick.Add(OnBtnAddClick);
|
|
|
+ _ui.m_btnMinus.target.onClick.Add(OnBtnMinusClick);
|
|
|
+ _ui.m_btnMax.target.onClick.Add(OnBtnMaxClick);
|
|
|
+ _ui.m_btnConfirm.onClick.Add(OnBtnConfirmClick);
|
|
|
+ _ui.m_btnCancle.onClick.Add(OnBtnCancleClick);
|
|
|
+
|
|
|
+ }
|
|
|
+ protected override void AddEventListener()
|
|
|
+ {
|
|
|
+ base.AddEventListener();
|
|
|
+
|
|
|
+ }
|
|
|
+ protected override void OnShown()
|
|
|
+ {
|
|
|
+ base.OnShown();
|
|
|
+ _itemId = (int)this.viewData;
|
|
|
+ _count = 1;
|
|
|
+
|
|
|
+ UpdateView();
|
|
|
+ UpdateUseView();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnHide()
|
|
|
+ {
|
|
|
+
|
|
|
+ base.OnHide();
|
|
|
+ }
|
|
|
+ protected override void RemoveEventListener()
|
|
|
+ {
|
|
|
+ base.RemoveEventListener();
|
|
|
+ // EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UpdateView()
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
|
|
|
+ _ui.m_txtName.text = itemCfg.name;
|
|
|
+ _ui.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemCfg.id)).FlushVars();
|
|
|
+ _ui.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.desc) ? "暂无描述" : itemCfg.desc;
|
|
|
+ _ui.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+ RarityIconController.UpdateRarityIcon(_ui.m_loaRarity, itemCfg.id, false);
|
|
|
+ _ui.m_loaRarity.visible = itemCfg.itemType == ConstItemType.DRESS_UP;
|
|
|
+ _ui.m_txtExchangeCount.visible = false;
|
|
|
+ _ui.m_comCost.target.visible = false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UpdateUseView()
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
|
|
|
+ _ui.m_txtCostCount.text = _count.ToString();
|
|
|
+ _ui.m_btnMinus.m_c1.selectedIndex = _count == 1 ? 1 : 0;
|
|
|
+ _ui.m_btnMinus.target.touchable = _count == 1 ? false : true;
|
|
|
+ long hasCount = ItemDataManager.GetItemNum(_itemId);
|
|
|
+ _ui.m_btnAdd.m_c1.selectedIndex = _count == hasCount ? 1 : 0;
|
|
|
+ _ui.m_btnAdd.target.touchable = _count == hasCount ? false : true;
|
|
|
+ _ui.m_btnMax.m_c1.selectedIndex = _count == hasCount ? 1 : 0;
|
|
|
+ _ui.m_btnMax.target.touchable = _count == hasCount ? false : true;
|
|
|
+
|
|
|
+ _ui.m_txtShow.text = "选择使用数量";
|
|
|
+ _ui.m_txtTips.text = string.Format("是否使用{0}个{1}?", _count, itemCfg.name);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnBtnAddClick()
|
|
|
+ {
|
|
|
+ _count++;
|
|
|
+ long hasCount = ItemDataManager.GetItemNum(_itemId);
|
|
|
+ _count = Math.Min(hasCount, _count);
|
|
|
+ UpdateUseView();
|
|
|
+ }
|
|
|
+ private void OnBtnMinusClick()
|
|
|
+ {
|
|
|
+ _count--;
|
|
|
+ _count = Math.Max(1, _count);
|
|
|
+ UpdateUseView();
|
|
|
+ }
|
|
|
+ private void OnBtnMaxClick()
|
|
|
+ {
|
|
|
+ _count = ItemDataManager.GetItemNum(_itemId);
|
|
|
+ UpdateUseView();
|
|
|
+ }
|
|
|
+ private void OnBtnConfirmClick()
|
|
|
+ {
|
|
|
+ ItemProxy.ReqUseItem(_itemId, _count).Coroutine();
|
|
|
+ this.Hide();
|
|
|
+ }
|
|
|
+ private void OnBtnCancleClick()
|
|
|
+ {
|
|
|
+ this.Hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|