| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 | 
							- using UI.ClothingShop;
 
- using UI.CommonGame;
 
- using FairyGUI;
 
- using UnityEngine;
 
- using System.Collections.Generic;
 
- using System;
 
- namespace GFGGame
 
- {
 
-     public class ClothingShopView : BaseView
 
-     {
 
-         private const int SHOES_Y = 105;
 
-         private const int HEAD_Y = 609;
 
-         private const int BODY_Y = 412;
 
-         private const float SCALE_MAX = 1.5f;
 
-         private const float DURATION = 0.6f;
 
-         private readonly int[] HEAD_Y_ARR = new int[] { ConstDressUpItemType.FA_XING, ConstDressUpItemType.NEI_DA, ConstDressUpItemType.SHANG_YI, ConstDressUpItemType.TOU_SHI, ConstDressUpItemType.ER_SHI, ConstDressUpItemType.JING_SHI };
 
-         private readonly int[] SHOES_Y_ARR = new int[] { ConstDressUpItemType.XIA_ZHUANG, ConstDressUpItemType.WA_ZI, ConstDressUpItemType.XIE_ZI, ConstDressUpItemType.SHOU_SHI, ConstDressUpItemType.YAO_SHI };
 
-         private UI_ClothingShopUI _ui;
 
-         private GameObject _scenePrefab;
 
-         private GameObject _sceneObject;
 
-         private GoWrapper _wrapper;
 
-         private DressUpObjDataCache _dressUpObjDataCache;
 
-         private ValueBarController _valueBarController;
 
-         private List<ShopCfg> _dataList;
 
-         private GComponent _comSelected;
 
-         private ShopCfg _cfgSelected;
 
-         private const int MAX_COUNT = 99;
 
-         private const int INIT_COUNT = 1;
 
-         private int _scoreType;
 
-         private int _storeId = 1;
 
-         private GObject _selectedListItem;
 
-         private int _selectedItemId;//打开界面时选中的物品id
 
-         private int _selectedType = 0;//打开界面时选中的物品类型
 
-         private int _selectedItemCount;
 
-         private int _selectedItemClothingId;
 
-         public override void Dispose()
 
-         {
 
-             _valueBarController.Dispose();
 
-             _valueBarController = null;
 
-             if (_scenePrefab != null)
 
-             {
 
-                 GameObject.Destroy(_scenePrefab);
 
-                 _scenePrefab = null;
 
-             }
 
-             if (_comSelected != null)
 
-             {
 
-                 _comSelected.RemoveFromParent();
 
-                 _comSelected.Dispose();
 
-             }
 
-             if (_dressUpObjDataCache != null)
 
-             {
 
-                 _dressUpObjDataCache.Dispose();
 
-                 _dressUpObjDataCache = null;
 
-             }
 
-             _cfgSelected = null;
 
-             EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateItemChange);
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_ClothingShopUI.PACKAGE_NAME;
 
-             _ui = UI_ClothingShopUI.Create();
 
-             this.viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             _valueBarController = new ValueBarController(_ui.m_valueBar);
 
-             _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
 
-             _dressUpObjDataCache = new DressUpObjDataCache();
 
-             _comSelected = new GComponent();
 
-             _comSelected.x = -5;
 
-             _comSelected.y = -3;
 
-             _comSelected = UIPackage.CreateObject(UI_ClothingShopUI.PACKAGE_NAME, "ComSelect").asCom;
 
-             _ui.m_listShop.itemRenderer = ListShopItemRender;
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_compItemInfo.m_btnBuy.onClick.Add(OnclickBtnBuy);
 
-             _ui.m_listType.onClickItem.Add(OnClickListTypeItem);
 
-             _ui.m_listShop.onClickItem.Add(OnClickListShopItem);
 
-             _ui.m_compItemInfo.m_listTag.itemRenderer = RenderListTagItem;
 
-             EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateItemChange);
 
-             EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateItemChange);
 
-             // EventAgent.DispatchEvent(ConstMessage.MONEY_CHANGE, RoleDataManager.gold);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
 
-             _storeId = ConstStoreId.CLOTHING_STORE_ID;
 
-             _scoreType = 0;
 
-             _selectedItemId = 0;
 
-             _selectedType = 0;
 
-             if (this.viewData != null)
 
-             {
 
-                 //this.viewData[0]=storeId(商店Id)
 
-                 //this.viewData[1]=_scoreType(服装属性:风花雪月)
 
-                 //this.viewData[2]=_selectedItemId
 
-                 //this.viewData[3]=_selectedItemCount
 
-                 object[] objs = this.viewData as object[];
 
-                 if (objs.Length > 0 && objs[0] != null)
 
-                 {
 
-                     _storeId = (int)objs[0];//从抽奖跳转到商店会区分商店Id
 
-                 }
 
-                 if (objs.Length > 1 && objs[1] != null)
 
-                 {
 
-                     _scoreType = (int)objs[1];//从战斗跳转到商店需要服装突出属性用来服装排序
 
-                 }
 
-                 if (objs.Length > 2 && objs[2] != null)
 
-                 {
 
-                     _selectedItemId = (int)objs[2];//从物品来源面板跳转到商店,需要物品id方便打开界面时做选中处理
 
-                     _selectedItemCount = (int)objs[3];
 
-                     ShopCfg[] dataArray = ClothingShopCfgManager.Instance.GetShopCfgs(_storeId);
 
-                     for (int i = 0; i < dataArray.Length; i++)
 
-                     {
 
-                         if (dataArray[i].itemID == _selectedItemId)
 
-                         {
 
-                             _selectedType = dataArray[i].typeIndex;
 
-                             _selectedItemClothingId = dataArray[i].id;
 
-                             // ShopCfg clothingShopCfg = ShopCfgClothingArray.Instance.GetCfg(_selectedItemClothingId);
 
-                             _ui.m_listType.selectedIndex = _selectedType;
 
-                             break;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             _ui.m_c1.selectedIndex = _storeId;
 
-             _ui.m_compItemInfo.m_c1.selectedIndex = _storeId;
 
-             _ui.m_listType.selectedIndex = _selectedType;
 
-             _ui.m_listType.ScrollToView(_selectedType);
 
-             UpdateList(false);
 
-             _ui.m_listShop.height = _ui.target.height - _ui.m_listShop.y;
 
-             _ui.m_bgList.height = _ui.target.height - _ui.m_bgList.y;
 
-             EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateSelectedItemInfo);
 
-             UpdateCJGoodsCount();
 
-             _valueBarController.OnShown();
 
-             _valueBarController.Controller(1);
 
-             if (_storeId == ConstStoreId.CLOTHING_STORE_ID)
 
-             {
 
-                 _valueBarController.Controller(1);
 
-             }
 
-             else if (_storeId == ConstStoreId.LUCKY_BOX_STORE_ID)
 
-             {
 
-                 _valueBarController.Controller(2);
 
-             }
 
-             else if (_storeId == ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID)
 
-             {
 
-                 _valueBarController.Controller(3);
 
-             }
 
-             if (_selectedItemId > 0 && _selectedItemCount > 0)
 
-             {
 
-                 ShopDataManager.Instance.BuyItem(_cfgSelected.id, _selectedItemCount, _storeId, _cfgSelected);
 
-             }
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             _valueBarController.OnHide();
 
-             if (_sceneObject != null)
 
-             {
 
-                 GameObject.Destroy(_sceneObject);
 
-                 _sceneObject = null;
 
-             }
 
-             if (_wrapper != null)
 
-             {
 
-                 _wrapper.wrapTarget = null;
 
-             }
 
-             _selectedItemId = 0;
 
-             EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateSelectedItemInfo);
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             ViewManager.GoBackFrom(ViewName.CLOTHING_SHOP_VIEW);
 
-             this.Hide();
 
-         }
 
-         private void OnclickBtnBuy()
 
-         {
 
-             int count = _selectedItemId > 0 && _cfgSelected.itemID == _selectedItemId ? _selectedItemCount : INIT_COUNT;
 
-             // BuyItemConteoller.Show(_cfgSelected.itemID, _cfgSelected.costID, INIT_COUNT, _cfgSelected.costNum, count, null, true, false, MAX_COUNT);
 
-             ShopDataManager.Instance.BuyItem(_cfgSelected.id, count, _storeId, _cfgSelected);
 
-         }
 
-         private void UpdateItemChange()
 
-         {
 
-             UpdateCJGoodsCount();
 
-             UpdateList(false);
 
-         }
 
-         private void UpdateCJGoodsCount()
 
-         {
 
-             int luckyBoxId1 = LuckyBoxDataManager.BOX_ID_3;
 
-             LuckyBoxCfg luckyBoxCfg1 = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId1);
 
-             _ui.m_txtCount0.text = "" + ItemDataManager.GetItemNum(luckyBoxCfg1.bonusArr[0][0]);
 
-             _ui.m_loaIcon0.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg1.bonusArr[0][0]).res);
 
-             int luckyBoxId2 = LuckyBoxDataManager.BOX_ID_2;
 
-             LuckyBoxCfg luckyBoxCfg2 = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId2);
 
-             _ui.m_txtCount1.text = "" + ItemDataManager.GetItemNum(luckyBoxCfg2.bonusArr[0][0]);
 
-             _ui.m_loaIcon1.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg2.bonusArr[0][0]).res);
 
-         }
 
-         private void UpdateRole(bool tween)
 
-         {
 
-             if (_sceneObject != null)
 
-             {
 
-                 GameObject.Destroy(_sceneObject);
 
-                 _sceneObject = null;
 
-             }
 
-             _sceneObject = GameObject.Instantiate(_scenePrefab);
 
-             int scale = 70;
 
-             _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
 
-             _dressUpObjDataCache.setSceneObj(_sceneObject);
 
-             _dressUpObjDataCache.PutOnDefaultSuitSaved(false);
 
-             _dressUpObjDataCache.AddOrRemove(_cfgSelected.itemID, true);
 
-             if (_wrapper == null)
 
-             {
 
-                 _wrapper = new GoWrapper(_sceneObject);
 
-                 _ui.m_compHolder.m_compMover.m_holder.SetNativeObject(_wrapper);
 
-             }
 
-             else
 
-             {
 
-                 _wrapper.wrapTarget = _sceneObject;
 
-             }
 
-             int type = ItemUtilCS.GetItemSubType(_cfgSelected.itemID);
 
-             float duration = DURATION;
 
-             if (!tween)
 
-             {
 
-                 duration = 0;
 
-             }
 
-             if (Array.IndexOf(HEAD_Y_ARR, type) >= 0)
 
-             {
 
-                 _ui.m_compHolder.m_compMover.target.TweenMoveY(HEAD_Y, duration);
 
-                 _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(SCALE_MAX, SCALE_MAX), duration);
 
-             }
 
-             else if (Array.IndexOf(SHOES_Y_ARR, type) >= 0)
 
-             {
 
-                 _ui.m_compHolder.m_compMover.target.TweenMoveY(SHOES_Y, duration);
 
-                 _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(SCALE_MAX, SCALE_MAX), duration);
 
-             }
 
-             else
 
-             {
 
-                 _ui.m_compHolder.m_compMover.target.TweenMoveY(BODY_Y, duration);
 
-                 _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(1, 1), duration);
 
-             }
 
-         }
 
-         private void UpdateList(bool tween)
 
-         {
 
-             _ui.m_listShop.RemoveChildrenToPool();
 
-             int typeIndex = _ui.m_listType.selectedIndex;
 
-             _dataList = ClothingShopCfgManager.Instance.GetList(_storeId, typeIndex, _scoreType);
 
-             _ui.m_listShop.numItems = _dataList.Count;
 
-             if (_ui.m_listShop.numItems > 0)
 
-             {
 
-                 ShopCfg clothingShopCfg = ClothingShopCfgManager.Instance.GetShopCfg(_selectedItemClothingId, _storeId);//  ShopCfgClothingArray.Instance.GetCfg(_selectedItemClothingId);
 
-                 int itemIndex = 0;
 
-                 if (_selectedItemId > 0 && clothingShopCfg != null)
 
-                 {
 
-                     // itemIndex = _dataList.IndexOf(clothingShopCfg);
 
-                     for (int i = 0; i < _dataList.Count; i++)
 
-                     {
 
-                         if (_dataList[i].id == _selectedItemClothingId)
 
-                         {
 
-                             itemIndex = i;
 
-                             break;
 
-                         }
 
-                     }
 
-                     _ui.m_listShop.ScrollToView(itemIndex < 0 ? 0 : itemIndex);
 
-                     // _selectedItemId = 0;
 
-                 }
 
-                 UpdateSelectedItemInfo(_ui.m_listShop.GetChildAt(itemIndex) as GComponent, tween);
 
-             }
 
-         }
 
-         private void OnClickListTypeItem(EventContext context)
 
-         {
 
-             UpdateList(true);
 
-         }
 
-         private void OnClickListShopItem(EventContext context)
 
-         {
 
-             _selectedItemId = 0;
 
-             // UI_ShopListItemRender selectedListItem = UI_ShopListItemRender.Proxy(_selectedListItem);
 
-             // selectedListItem.m_grpSelect.visible = false;
 
-             UpdateSelectedItemInfo(context.data as GComponent, true);
 
-         }
 
-         private void ListShopItemRender(int index, GObject item)
 
-         {
 
-             UI_ShopListItemRender listItem = UI_ShopListItemRender.Proxy(item);
 
-             ShopCfg cfg = _dataList[index];
 
-             listItem.target.data = cfg;
 
-             // listItem.m_grpSelect.visible = false;
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.itemID);
 
-             listItem.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
 
-             string itemName = itemCfg.name;
 
-             listItem.m_txtName.text = itemName;
 
-             RarityIconController.UpdateRarityIcon(listItem.m_rarity, cfg.itemID, false);
 
-             ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(cfg.costID);
 
-             listItem.m_iconPrice.url = "ui://CommonGame/" + costItemCfg.res;
 
-             listItem.m_imgOwned.visible = ItemDataManager.GetItemNum(cfg.itemID) > 0;
 
-             listItem.m_txtPrice.text = ItemDataManager.GetItemNum(cfg.costID) >= cfg.costNum ? StringUtil.GetColorText(cfg.costNum.ToString(), "#DD994A") : StringUtil.GetColorText(cfg.costNum.ToString(), "#F2989B");
 
-         }
 
-         private void UpdateSelectedItemInfo(GComponent listItem, bool tween)
 
-         {
 
-             _selectedListItem = listItem;
 
-             listItem.AddChild(_comSelected);
 
-             // UI_ShopListItemRender item = UI_ShopListItemRender.Proxy(listItem);
 
-             // item.m_grpSelect.visible = true;
 
-             // item.target.AddChild()
 
-             ShopCfg cfg = listItem.data as ShopCfg;
 
-             _cfgSelected = cfg;
 
-             UpdateRole(tween);
 
-             UpdateSelectedItemInfo();
 
-         }
 
-         private void UpdateSelectedItemInfo()
 
-         {
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_cfgSelected.itemID);
 
-             string itemName = itemCfg.name;
 
-             _ui.m_compItemInfo.m_txtName.text = itemName;
 
-             _ui.m_compItemInfo.m_txtDesc.text = itemCfg.desc;
 
-             RarityIconController.UpdateRarityIcon(_ui.m_compItemInfo.m_rarity, _cfgSelected.itemID, false);
 
-             ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(_cfgSelected.costID);
 
-             _ui.m_compItemInfo.m_iconPrice.url = "ui://CommonGame/" + costItemCfg.res;
 
-             _ui.m_compItemInfo.m_txtPrice.text = "" + _cfgSelected.costNum;
 
-             _ui.m_compItemInfo.m_txtGong.text = "" + itemCfg.score1;
 
-             _ui.m_compItemInfo.m_txtShang.text = "" + itemCfg.score2;
 
-             _ui.m_compItemInfo.m_txtJue.text = "" + itemCfg.score3;
 
-             _ui.m_compItemInfo.m_txtZhi.text = "" + itemCfg.score4;
 
-             _ui.m_compItemInfo.m_txtOwned.SetVar("v1", "" + ItemDataManager.GetItemNum(_cfgSelected.itemID)).FlushVars();
 
-             UI_ShopListItemRender listItem = UI_ShopListItemRender.Proxy(_selectedListItem);
 
-             listItem.m_imgOwned.visible = ItemDataManager.GetItemNum(_cfgSelected.itemID) > 0;
 
-             _ui.m_compItemInfo.m_listTag.numItems = itemCfg.tagsArr.Length;
 
-         }
 
-         private void RenderListTagItem(int index, GObject obj)
 
-         {
 
-             UI_ListTagItem item = UI_ListTagItem.Proxy(obj);
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_cfgSelected.itemID);
 
-             string[] tag = itemCfg.tagsArr[index].Split('_');
 
-             item.m_loaTag.url = ResPathUtil.GetCommonGameResPath("fzd_bqbq_" + tag[0]);
 
-             item.m_txtTag.text = tag[1];
 
-         }
 
-         protected override void UpdateToCheckGuide(object param)
 
-         {
 
-             if (!ViewManager.CheckIsTopView(this.viewCom)) return;
 
-             GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.BUY_CLOTHING, 6, "回到换装", -1, true, 140);
 
-         }
 
-     }
 
- }
 
 
  |