| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 | 
							
- using System;
 
- using System.Collections.Generic;
 
- using ET;
 
- using FairyGUI;
 
- using UI.Bag;
 
- using UI.CommonGame;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     public class BagExchangeView : BaseWindow
 
-     {
 
-         private UI_ItemExchangeUI _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_ItemExchangeUI.PACKAGE_NAME;
 
-             _ui = UI_ItemExchangeUI.Create();
 
-             this.viewCom = _ui.target;
 
-             this.viewCom.Center();
 
-             this.modal = true;
 
-             _ui.m_btnAdd.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();
 
-         }
 
-     }
 
- }
 
 
  |