| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 | 
							- using UnityEngine;
 
- using UI.ClothingSynthetic;
 
- using UI.CardSynthetic;
 
- using FairyGUI;
 
- using System.Collections.Generic;
 
- using System;
 
- using ET;
 
- using System.Collections;
 
- using System.Threading.Tasks;
 
- using YooAsset;
 
- namespace GFGGame
 
- {
 
-     public class CardSyntheticView : BaseWindow
 
-     {
 
-         private UI_CardSyntheticUI _ui;
 
-         private DressUpObjUI _dressUpObjUI;
 
-         private ValueBarController _valueBarController;
 
-         private GImage _imgSelected;
 
-         private int _cardId;
 
-         private int _chapterID;
 
-         private int _itemId;
 
-         private int[] _items;
 
-         private int _selectedItemId;
 
-         private GComponent _selectedListItem;
 
-         private List<ItemData> _materiarsOfSelectedItem;
 
-         private UI_MateriasListItem listTypeItem_CloSynthetic;
 
-         private UI_Component2 _compMover;
 
-         public override void Dispose()
 
-         {
 
-             if (_valueBarController != null)
 
-             {
 
-                 _valueBarController.Dispose();
 
-                 _valueBarController = null;
 
-             }
 
-             if (_imgSelected != null)
 
-             {
 
-                 _imgSelected.RemoveFromParent();
 
-                 _imgSelected.Dispose();
 
-             }
 
-             if (_dressUpObjUI != null)
 
-             {
 
-                 _dressUpObjUI.Dispose();
 
-                 _dressUpObjUI = null;
 
-             }
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_CardSyntheticUI.PACKAGE_NAME;
 
-             _ui = UI_CardSyntheticUI.Create();
 
-             this.viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             //layer = ConstViewLayer.TOP;
 
-             isReturnView = true;
 
-             _valueBarController = new ValueBarController(_ui.m_valueBar);
 
-             _dressUpObjUI = new DressUpObjUI("SceneDressUpSynthetic");
 
-             _ui.m_listMaterias.itemRenderer = RenderListMateriasItem;
 
-             _ui.m_listMaterias.onClickItem.Add(OnClickMateriasItemPlus);
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_btnProduction.onClick.Add(OnClickBtnProcuction);
 
-             _ui.m_btnHome.onClick.Add(OnClickBtnHome);
 
-             _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
 
-         }
 
-         protected override void AddEventListener()
 
-         {
 
-             base.AddEventListener();
 
-             EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnItemNumChanged);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             _cardId = 0;
 
-             _selectedItemId = 0;
 
-             _chapterID = 0;
 
-             if (this.viewData != null)
 
-             {
 
-                 _cardId = (int)(this.viewData as object[])[0];
 
-                 _selectedItemId = (this.viewData as object[]).Length > 1 ? (int)(this.viewData as object[])[1] : 0;
 
-                 if ((this.viewData as object[]).Length > 2)
 
-                     _chapterID = (int)(this.viewData as object[])[2];
 
-             }
 
-             if (DressUpMenuSuitDataManager.chooseClothing > 0)
 
-                 _selectedItemId = DressUpMenuSuitDataManager.chooseClothing;
 
-             _valueBarController.OnShown();
 
-             _ui.m_loaBg2.url = ResPathUtil.GetBgImgPath("hc_bj_1");
 
-             UpdateView();
 
-             Timers.inst.AddUpdate(CheckGuide);
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             _valueBarController.OnHide();
 
-             _ui.m_listMaterias.selectedIndex = 0;
 
-             Timers.inst.Remove(CheckGuide);
 
-             _dressUpObjUI.dressUpObj.TakeOffAll();
 
-             if (_chapterID > 0)
 
-                 MainStoryDataManager.currentChapterCfgId = _chapterID;
 
-         }
 
-         protected override void RemoveEventListener()
 
-         {
 
-             base.RemoveEventListener();
 
-             EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, OnItemNumChanged);
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             DressUpMenuSuitDataManager.chooseClothing = 0;
 
-             ViewManager.GoBackFrom(typeof(ClothingSyntheticView).FullName);
 
-         }
 
-         private async void OnClickBtnProcuction()
 
-         {
 
-             if (ItemDataManager.GetItemNum(_selectedItemId) > 0)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("不能制作已经拥有的物品");
 
-                 return;
 
-             }
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_selectedItemId);
 
-             if (itemCfg == null)
 
-             {
 
-                 ET.Log.Error("OnClickBtnProcuction itemCfg is null");
 
-                 return;
 
-             }
 
-             if (!ItemUtil.CheckItemEnough(itemCfg.syntheticCostID, itemCfg.syntheticCostNum))
 
-             {
 
-                 long has = ItemDataManager.GetItemNum(itemCfg.syntheticCostID);
 
-                 ItemUtil.BuyCurrency(itemCfg.syntheticCostID, itemCfg.syntheticCostNum - has);
 
-                 return;
 
-             }
 
-             List<ItemData> materiarsOfSelectedItem = ItemUtil.CreateItemDataList(itemCfg.syntheticMateriarsArr);
 
-             for (int i = 0; i < materiarsOfSelectedItem.Count; i++)
 
-             {
 
-                 ItemData itemData = materiarsOfSelectedItem[i];
 
-                 if (itemData == null || !ItemUtil.CheckItemEnough(itemData.id, itemData.num, true)) return;
 
-             }
 
-             bool result = await ClothingSyntheticSProxy.ClothtingSynthetic(_selectedItemId);
 
-             if (result)
 
-             {
 
-                 _selectedItemId = 0;
 
-                 LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.FU_ZHUANG_HE_CHENG, 2);
 
-                 // 发送服装合成成功事件
 
-                 EventAgent.DispatchEvent(ConstMessage.CLOTHING_SYNTHETIC_SUCCESS);
 
-             }
 
-         }
 
-         private void UpdateView()
 
-         {
 
-             ItemCfg cardItem = ItemCfgArray.Instance.GetCfg(_cardId);
 
-             UpdateName(cardItem.name);
 
-             _ui.m_comImgCard.m_ComCardImgRes.m_loaCard.url = ResPathUtil.GetCardPath(cardItem.res);
 
-             UpdateSelectedItemInfo();
 
-         }
 
-         private void UpdateSelectedItemInfo()
 
-         {
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_cardId);
 
-             //属性展示
 
-             RarityIconController.UpdateRarityIcon(_ui.m_loaRarity, _cardId, false);
 
-             _ui.m_txtGong.text = "" + itemCfg.score1;
 
-             _ui.m_txtShang.text = "" + itemCfg.score2;
 
-             _ui.m_txtJue.text = "" + itemCfg.score3;
 
-             _ui.m_txtZhi.text = "" + itemCfg.score4;
 
-             //合成显示
 
-             ItemCfg clothingSyntheticCfg = ItemCfgArray.Instance.GetCfg(_selectedItemId);
 
-             // string costName = ItemUtil.GetItemName(clothingSyntheticCfg.syntheticCostID);
 
-             // _ui.m_txtCost.SetVar("v1", "" + clothingSyntheticCfg.syntheticCostNum).SetVar("v2", costName).FlushVars();
 
-             if (clothingSyntheticCfg.syntheticCostID <= 0)
 
-             {
 
-                 Log.Error($"请为物品 {clothingSyntheticCfg.id} 增加合成相关配置!");
 
-                 return;
 
-             }
 
-             ItemUtil.UpdateItemNeedNum(_ui.m_comCostCurrency, clothingSyntheticCfg.syntheticCostID, clothingSyntheticCfg.syntheticCostNum);
 
-             _materiarsOfSelectedItem = ItemUtil.CreateItemDataList(clothingSyntheticCfg.syntheticMateriarsArr);
 
-             _ui.m_listMaterias.numItems = _materiarsOfSelectedItem.Count;
 
-             _ui.m_listMaterias.selectedIndex = 0;
 
-             _ui.m_btnProduction.grayed = ItemDataManager.GetItemNum(_selectedItemId) > 0;
 
-         }
 
-         private void UpdateName(string name)
 
-         {
 
-             string names = name;
 
-             _ui.m_txtName0.text = "";
 
-             _ui.m_txtName1.text = "";
 
-             _ui.m_txtName2.text = "";
 
-             _ui.m_txtName3.text = "";
 
-             _ui.m_txtName4.text = "";
 
-             switch (names.Length)
 
-             {
 
-                 case 1:
 
-                     _ui.m_txtName0.text = names.Substring(0, 1);
 
-                     break;
 
-                 case 2:
 
-                     _ui.m_txtName0.text = names.Substring(0, 1);
 
-                     _ui.m_txtName2.text = names.Substring(1, 1);
 
-                     break;
 
-                 case 3:
 
-                     _ui.m_txtName0.text = names.Substring(0, 1);
 
-                     _ui.m_txtName1.text = names.Substring(1, 1);
 
-                     _ui.m_txtName2.text = names.Substring(2, 1);
 
-                     break;
 
-                 case 4:
 
-                     _ui.m_txtName0.text = names.Substring(0, 1);
 
-                     _ui.m_txtName1.text = names.Substring(1, 1);
 
-                     _ui.m_txtName2.text = names.Substring(2, 1);
 
-                     _ui.m_txtName3.text = names.Substring(3, 1);
 
-                     break;
 
-                 default:
 
-                     _ui.m_txtName0.text = names.Substring(0, 1);
 
-                     _ui.m_txtName1.text = names.Substring(1, 1);
 
-                     _ui.m_txtName2.text = names.Substring(2, 1);
 
-                     _ui.m_txtName3.text = names.Substring(3, 1);
 
-                     _ui.m_txtName4.text = names.Substring(4);
 
-                     break;
 
-             }
 
-         }
 
-         private void RenderListMateriasItem(int index, GObject obj)
 
-         {
 
-             UI_MateriasListItem listItem = UI_MateriasListItem.Proxy(obj);
 
-             ItemData itemData = _materiarsOfSelectedItem[index];
 
-             ItemCfg materiasItemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
 
-             listItem.m_txtName.text = ItemUtil.GetItemName(itemData.id);
 
-             listItem.m_loaderIcon.url = ResPathUtil.GetIconPath(materiasItemCfg);
 
-             long num = ItemDataManager.GetItemNum(itemData.id);
 
-             ItemCfg materialCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
 
-             bool isDressUp = materialCfg.itemType == ConstItemType.DRESS_UP;
 
-             long numSynthetic = Math.Max(num, 0);
 
-             listItem.m_txtProgess.text = numSynthetic + "/" + itemData.num;
 
-             listItem.m_loaderIcon.visible = true;
 
-             listItem.m_txtProgess.visible = true;
 
-             // listItem.target.onClick.Clear();
 
-             // if (listItem.target.data == null)
 
-             // {
 
-             //     listItem.target.onClick.Add(OnClickMateriasItemPlus);
 
-             // }
 
-             listItem.target.data = index;
 
-             UI_MateriasListItem.ProxyEnd();
 
-         }
 
-         private void OnClickMateriasItemPlus(EventContext context)
 
-         {
 
-             GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.CLOTHING_SYNTHETIC);
 
-             if (GuideDataManager.currentGuideId == cfg.id)
 
-             {
 
-                 return;
 
-             }
 
-             if (ItemDataManager.GetItemNum(_selectedItemId) > 0)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("该材料已获得");
 
-                 return;
 
-             }
 
-             int index = (int)(context.data as GObject).data;
 
-             _ui.m_listMaterias.selectedIndex = index;
 
-             ItemData itemData = _materiarsOfSelectedItem[index];
 
-             if (itemData == null)
 
-             {
 
-                 ET.Log.Error("OnClickMateriasItemPlus itemData is null");
 
-                 return;
 
-             }
 
-             object[] sourceDatas = new object[] { itemData.id, new object[] { typeof(ClothingSyntheticView).FullName, new object[] { _cardId, _selectedItemId } }, (int)itemData.num };
 
-             GoodsItemTipsController.ShowItemTips(itemData.id, sourceDatas);
 
-         }
 
-         private void OnItemNumChanged()
 
-         {
 
-             //列表选中项更新
 
-             UI_ClothingListItem selectedItem = UI_ClothingListItem.Proxy(_selectedListItem);
 
-             selectedItem.m_imgOwned.visible = ItemDataManager.GetItemNum(_selectedItemId) > 0;
 
-             UI_ClothingListItem.ProxyEnd();
 
-             UpdateSelectedItemInfo();
 
-         }
 
-         private void OnClickBtnHome()
 
-         {
 
-             GameController.GoBackToMainView();
 
-         }
 
-         private void CheckGuide(object param)
 
-         {
 
-             //if (GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_SYNTHETIC) <= 0)
 
-             //{
 
-             //    UpdateToCheckGuide(null);
 
-             //}
 
-             //else
 
-             //{
 
-             //    Timers.inst.Remove(CheckGuide);
 
-             //}
 
-         }
 
-         protected override void UpdateToCheckGuide(object param)
 
-         {
 
-             //if (ViewManager.isViewOpen(typeof(GuideView).Name))
 
-             //{
 
-             //    (ViewManager.GetUIView(typeof(GuideView).Name) as GuideView).viewCom.visible = !ViewManager.isViewOpen(typeof(GetSuitItemVIew).Name);
 
-             //}
 
-             //if (!ViewManager.CheckIsTopView(this.viewCom)) return;
 
-             //int itemId = 10566;
 
-             //int itemIndex = 0;
 
-             //for (int i = 0; i < _ui.m_listClothing.numItems; i++)
 
-             //{
 
-             //    UI_ClothingListItem listItem = UI_ClothingListItem.Proxy(_ui.m_listClothing.GetChildAt(i));
 
-             //    int temp = (int)listItem.target.data;
 
-             //    UI_ClothingListItem.ProxyEnd();
 
-             //    if (temp == itemId)
 
-             //    {
 
-             //        itemIndex = i;
 
-             //        break;
 
-             //    }
 
-             //}
 
-             //bool guide = GuideController.TryGuide(_ui.m_listClothing, ConstGuideId.CLOTHING_SYNTHETIC, 3, "找到需要合成的物品。", itemIndex);
 
-             //if (guide) _ui.m_listClothing.ScrollToView(itemIndex);
 
-             //GuideController.TryGuide(_ui.m_listMaterias, ConstGuideId.CLOTHING_SYNTHETIC, 4, "这里可以查看合成需要的材料,和材料的获取途径。", 0);
 
-             //UI_MateriasListItem.ProxyEnd();
 
-             //GuideController.TryGuide(_ui.m_btnProduction, ConstGuideId.CLOTHING_SYNTHETIC, 5, "点击获得新的服饰。");
 
-             //GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.CLOTHING_SYNTHETIC, 6, "获得新衣服啦,继续通关主线剧情吧。");
 
-         }
 
-     }
 
- }
 
 
  |