| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 | 
							- 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;
 
-         private List<int[]> _itemList = new List<int[]>();
 
-         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);
 
-             _ui.m_listItem.itemRenderer = ListItemRenderer;
 
-         }
 
-         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;
 
-             UpdateThItemList(itemCfg);
 
-             _ui.m_listItem.numItems = _itemList.Count; //itemCfg.itemsArr.Length;
 
-             _ui.m_listItem.visible = itemCfg.itemType == ConstItemType.USEABLE &&
 
-                                      itemCfg.subType != ConstItemSubType.USEABLE_AUTO;
 
-         }
 
-         private void UpdateThItemList(ItemCfg itemCfg)
 
-         {
 
-             _itemList.Clear();
 
-             //普通物品
 
-             foreach (var t in itemCfg.itemsArr)
 
-             {
 
-                 var itemId = t[0];
 
-                 var itemNum = t.Length > 1 ? t[1] : 1;
 
-                 _itemList.Add(new[] { itemId, itemNum });
 
-             }
 
-             if (itemCfg.subType == ConstItemSubType.USEABLE_GIFT_BAG_RANDOM)
 
-             {
 
-                 if (itemCfg.param2Arr.Length > 0)
 
-                 {
 
-                     //特殊物品 不存在的套装部件id
 
-                     List<int> noExistSuitItemIds = new List<int>();
 
-                     foreach (var suitId in itemCfg.param2Arr)
 
-                     {
 
-                         noExistSuitItemIds.Clear();
 
-                         SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
 
-                         foreach (var suitItemId in suitCfg.partsArr)
 
-                         {
 
-                             if (!ItemUtil.CheckItemEnough(suitItemId, 1))
 
-                             {
 
-                                 noExistSuitItemIds.Add(suitItemId);
 
-                             }
 
-                         }
 
-                         foreach (var noExistSuitItemId in noExistSuitItemIds)
 
-                         {
 
-                             _itemList.Add(new[] { noExistSuitItemId, 1 });
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             //保底物品
 
-             if (itemCfg.param1Arr.Length > 0)
 
-             {
 
-                 foreach (var t in itemCfg.param1Arr)
 
-                 {
 
-                     var itemId = t[0];
 
-                     var itemNum = t.Length > 1 ? t[1] : 1;
 
-                     _itemList.Add(new[] { itemId, itemNum });
 
-                 }
 
-             }
 
-         }
 
-         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 ListItemRenderer(int index, GObject obj)
 
-         {
 
-             //ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
 
-             ItemData itemData = ItemUtil.createItemData(_itemList[index]);
 
-             if (obj.data == null)
 
-             {
 
-                 obj.data = new ItemView(obj as GComponent);
 
-             }
 
-             (obj.data as ItemView).SetData(itemData);
 
-             (obj.data as ItemView).ChangeTxtCountStyle();
 
-         }
 
-         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()
 
-         {
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
 
-             if (itemCfg.itemType == ConstItemType.USEABLE &&
 
-                 itemCfg.subType == ConstItemSubType.USEABLE_GIFT_BAG_RANDOM)
 
-             {
 
-                 ItemProxy.ReqUseRandomItem(_itemId, _count).Coroutine();
 
-             }
 
-             else
 
-             {
 
-                 ItemProxy.ReqUseItem(_itemId, _count).Coroutine();
 
-             }
 
-             
 
-             this.Hide();
 
-         }
 
-         private void OnBtnCancleClick()
 
-         {
 
-             this.Hide();
 
-         }
 
-     }
 
- }
 
 
  |