| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using FairyGUI;
 
- using UI.ClothingFoster;
 
- using UI.CommonGame;
 
- using UnityEngine;
 
- using ET;
 
- namespace GFGGame
 
- {
 
-     public class SuitView : BaseWindow
 
-     {
 
-         private UI_SuitUI _ui;
 
-         private GameObject _scenePrefab;
 
-         private GameObject _sceneObject;
 
-         private GoWrapper _wrapper;
 
-         private DressUpObjDataCache _dressUpObjDataCache;
 
-         private bool _actionIsPic;
 
-         private List<int> _suitIds;//已解锁套装列表
 
-         private SortedList _propertyList = new SortedList();
 
-         private SortedList _addPropertyList = new SortedList();
 
-         private int _suitId;
 
-         private int _index;
 
-         private bool _canRenew;
 
-         public override void Dispose()
 
-         {
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_SuitUI.PACKAGE_NAME;
 
-             _ui = UI_SuitUI.Create();
 
-             this.viewCom = _ui.target;
 
-             // this.viewCom.Center();
 
-             isfullScreen = true;
 
-             // this.clickBlankToClose = false;
 
-             _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
 
-             _dressUpObjDataCache = new DressUpObjDataCache();
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_btnLeft.onClick.Add(() => { OnClickBtnDirection(-1); });
 
-             _ui.m_btnRight.onClick.Add(() => { OnClickBtnDirection(1); });
 
-             _ui.m_comFosterReward.target.onClick.Add(OnClickComFosterReward);
 
-             _ui.m_btnPropertyShow.onClick.Add(OnClickBtnPropertyShow);
 
-             _ui.m_listFoster.itemRenderer = ListFosterItemRender;
 
-             _ui.m_listFoster.onClickItem.Add(OnClickListFosterItem);
 
-             _ui.m_listProperty.itemRenderer = ListPropertyItemRender;
 
-             _ui.m_listRenewMaterial.itemRenderer = ListRenewMaterialItemRender;
 
-             _ui.m_listRenewMaterial.onClickItem.Add(OnListRenewMaterialsItem);
 
-             _ui.m_btnRenew.onClick.Add(OnClickBtnRenew);
 
-             _ui.m_c1.onChanged.Add(OnTabChange);
 
-             // EventAgent.AddEventListener(ConstMessage.GET_SUIT_INFOS)
 
-             EventAgent.AddEventListener(ConstMessage.MAINTAIN_SUIT, OnListenerFoster);
 
-             EventAgent.AddEventListener(ConstMessage.GET_MAINTAIN_SUIT_BONUS, OnListenerGetFosterReward);
 
-             EventAgent.AddEventListener(ConstMessage.MAKE_NEW_SUIT, OnListenerRenew);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             object[] datas = this.viewData as object[];
 
-             _suitId = (int)datas[0];
 
-             List<int> suitIds = datas[1] as List<int>;
 
-             _suitIds = new List<int>();
 
-             foreach (int suitId in suitIds)
 
-             {
 
-                 if (DressUpMenuSuitDataManager.CheckHaveSuit(suitId))
 
-                 {
 
-                     _suitIds.Add(suitId);
 
-                 }
 
-             }
 
-             _index = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId).maintainStep;
 
-             _ui.m_c1.selectedIndex = 0;
 
-             UpdateView();
 
-             Debug.Log("养护奖励:" + ItemDataManager.GetItemNum(100169));
 
-             Debug.Log("换新奖励:" + ItemDataManager.GetItemNum(10370));
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             ViewManager.GoBackFrom(typeof(SuitView).FullName);
 
-         }
 
-         private void OnTabChange()
 
-         {
 
-             if (_ui.m_c1.selectedIndex == 0)
 
-             {
 
-                 UpdateFoster();
 
-             }
 
-             else
 
-             {
 
-                 UpdateRenew();
 
-             }
 
-         }
 
-         private void UpdateView()
 
-         {
 
-             SuitCfg cfg = SuitCfgArray.Instance.GetCfg(_suitId);
 
-             _ui.m_loaRarity.url = ResPathUtil.GetCommonGameResPath("hd_sxicon_" + cfg.rarity);// "ui://LuckyBox/;
 
-             UpdateArrows();
 
-             UpdateSuitView();
 
-             UpdateFoster();
 
-             UpdateRenew();
 
-         }
 
-         private void UpdateArrows()
 
-         {
 
-             int index = _suitIds.IndexOf(_suitId);
 
-             int count = _suitIds.Count;
 
-             _ui.m_btnRight.visible = (index + 1 < count);
 
-             _ui.m_btnLeft.visible = (index - 1 >= 0);
 
-         }
 
-         private void UpdateSuitView(bool isPic = true)
 
-         {
 
-             _actionIsPic = isPic;
 
-             SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
 
-             _ui.m_txtName.text = suitCfg.name;
 
-             if (_sceneObject != null)
 
-             {
 
-                 GameObject.Destroy(_sceneObject);
 
-                 _sceneObject = null;
 
-             }
 
-             _sceneObject = GameObject.Instantiate(_scenePrefab);
 
-             int scale = 100;
 
-             _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
 
-             _dressUpObjDataCache.setSceneObj(_sceneObject);
 
-             _dressUpObjDataCache.PutOnDefaultSuitSaved(false);
 
-             _dressUpObjDataCache.PutOnSuitCfg(_suitId, isPic, false, new int[] { ConstDressUpItemType.BEI_JING });
 
-             if (_wrapper == null)
 
-             {
 
-                 _wrapper = new GoWrapper(_sceneObject);
 
-                 _ui.m_holder.SetNativeObject(_wrapper);
 
-             }
 
-             else
 
-             {
 
-                 _wrapper.wrapTarget = _sceneObject;
 
-             }
 
-         }
 
-         private void OnClickBtnDirection(int direction)
 
-         {
 
-             int index = _suitIds.IndexOf(_suitId);
 
-             int targetIndex = index + direction;
 
-             if (targetIndex >= 0 && direction == -1 || targetIndex < _suitIds.Count && direction == 1)
 
-             {
 
-                 _suitId = _suitIds[targetIndex];
 
-                 _index = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId).maintainStep;
 
-                 UpdateView();
 
-             }
 
-         }
 
-         /*************************************************养护************************************************/
 
-         private void UpdateFoster()
 
-         {
 
-             _index = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId).maintainStep;
 
-             UpdateFosterReward();
 
-             _propertyList.Clear();
 
-             _addPropertyList.Clear();
 
-             _ui.m_listFoster.numItems = SuitFosterCfgArray.Instance.GetCfgs(_suitId).Length;
 
-             SuitFosterDataManager.Instance.GetPropertyData(_suitId, _index, out _propertyList, out _addPropertyList);
 
-             _ui.m_listProperty.numItems = _propertyList.Count;
 
-         }
 
-         private void UpdateFosterReward()
 
-         {
 
-             SuitFosterDataManager.Instance.GetFosterRewardState(_suitId, out int state, out int index);
 
-             SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[index];
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.rewardsArr[0][0]);
 
-             _ui.m_comFosterReward.m_loaReward.url = ResPathUtil.GetIconPath(itemCfg);
 
-             _ui.m_comFosterReward.m_c1.selectedIndex = state;
 
-         }
 
-         private void ListFosterItemRender(int index, GObject obj)
 
-         {
 
-             UI_ListFosterItem item = UI_ListFosterItem.Proxy(obj);
 
-             item.target.data = index;
 
-             item.m_finish.selectedIndex = SuitFosterDataManager.Instance.GetFosterState(_suitId, index);
 
-             item.m_txtName.text = SuitFosterDataManager.Instance.stepNames[index];
 
-         }
 
-         private void ListPropertyItemRender(int index, GObject obj)
 
-         {
 
-             UI_ListPropertyItem item = UI_ListPropertyItem.Proxy(obj);
 
-             int score = (int)_propertyList.GetKey(index);
 
-             item.m_txtProperty.text = _propertyList[score].ToString();
 
-             item.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (score));
 
-         }
 
-         private void OnClickListFosterItem(EventContext context)
 
-         {
 
-             int index = (int)(context.data as GObject).data;
 
-             int state = SuitFosterDataManager.Instance.GetFosterState(_suitId, index);
 
-             if (state == 0)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("已完成该阶段");
 
-             }
 
-             else if (state == 1)
 
-             {
 
-                 ViewManager.Show<SuitFosterView>(new object[] { _suitId, index, _propertyList, _addPropertyList });
 
-             }
 
-             else
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt(string.Format("请完成{0}阶段", SuitFosterDataManager.Instance.stepNames[_index]));
 
-             }
 
-         }
 
-         private void OnClickComFosterReward()
 
-         {
 
-             SuitFosterDataManager.Instance.GetFosterRewardState(_suitId, out int state, out int index);
 
-             if (state == 1 || state == 2)
 
-             {
 
-                 ViewManager.Show<SuitRewardView>(_suitId);
 
-             }
 
-             else
 
-             {
 
-                 SuitFosterHelper.SendGetMaintainSuitBonus(_suitId, index + 1).Coroutine();
 
-             }
 
-         }
 
-         private void OnClickBtnPropertyShow()
 
-         {
 
-             ViewManager.Show<SuitPropertyShowView>(new object[] { _suitId, _index });
 
-         }
 
-         private void OnListenerFoster()
 
-         {
 
-             _ui.m_comFosterAni.target.visible = true;
 
-             _ui.m_comFosterAni.m_txtContent.text = string.Format("服装{0}中......", SuitFosterDataManager.Instance.stepNames[_index]);
 
-             _ui.m_comFosterAni.m_proFoster.value = 0;
 
-             _ui.m_comFosterAni.m_proFoster.TweenValue(100, 2f).OnComplete(() =>
 
-             {
 
-                 ViewManager.Show<SuitFosterFinishView>(new object[] { _suitId, _index, _propertyList });
 
-                 UpdateFoster();
 
-                 _ui.m_comFosterAni.target.visible = false;
 
-             });
 
-         }
 
-         private void OnListenerGetFosterReward(EventContext context)
 
-         {
 
-             SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[(int)(context.data) - 1];
 
-             ViewManager.Show<RewardView>(ItemUtil.CreateItemDataList(cfg.rewardsArr));
 
-             UpdateFosterReward();
 
-             Debug.Log("养护奖励:" + ItemDataManager.GetItemNum(100169));
 
-         }
 
-         /*************************************************换新************************************************/
 
-         private void UpdateRenew()
 
-         {
 
-             _index = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId).maintainStep;
 
-             SuitFosterData suitFosterData = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId);
 
-             if (suitFosterData.makeNewState > 0)
 
-             {
 
-                 _ui.m_c2.selectedIndex = 1;
 
-                 UpdateRenewFinish();
 
-             }
 
-             else
 
-             {
 
-                 _ui.m_c2.selectedIndex = 0;
 
-                 UpdateRenewView();
 
-             }
 
-         }
 
-         private void UpdateRenewView()
 
-         {
 
-             int suitrarity = SuitCfgArray.Instance.GetCfg(_suitId).rarity;
 
-             SuitRenewCfg renewCfg = SuitRenewCfgArray.Instance.GetCfg(suitrarity);
 
-             SuitFosterListCfg cfg = SuitFosterListCfgArray.Instance.GetCfg(_suitId);
 
-             _ui.m_comRenewReward.target.visible = false;
 
-             if (cfg.renewRewardsArr.Length > 0)
 
-             {
 
-                 _ui.m_comRenewReward.target.visible = true;
 
-                 ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.renewRewardsArr[0][0]);
 
-                 _ui.m_comRenewReward.m_loaReward.url = ResPathUtil.GetIconPath(itemCfg);
 
-             }
 
-             _ui.m_txtRenewProperty.text = string.Format("套装所有部件属性+{0}%", renewCfg.addition * 100 / 10000);
 
-             _ui.m_txtRenewTips.text = string.Format("完成{0}阶段", SuitFosterDataManager.Instance.stepNames[cfg.renewOpenLv - 1]);
 
-             _ui.m_listRenewMaterial.numItems = renewCfg.materialsArr.Length;
 
-             _canRenew = true;
 
-             UI_ComConsumeCurrency comConsumeCurrency = UI_ComConsumeCurrency.Proxy(_ui.m_comRenewCost);
 
-             int has = ItemDataManager.GetItemNum(renewCfg.costId);
 
-             int need = renewCfg.costNum;
 
-             comConsumeCurrency.m_txtNeed.text = StringUtil.GetColorText(need.ToString(), has >= need ? "#FFF8EA" : "#C9F1A5");
 
-             comConsumeCurrency.m_txtLine.text = "";
 
-             if (_canRenew && has < need) _canRenew = false;
 
-         }
 
-         private void UpdateRenewFinish()
 
-         {
 
-             int suitrarity = SuitCfgArray.Instance.GetCfg(_suitId).rarity;
 
-             SuitRenewCfg renewCfg = SuitRenewCfgArray.Instance.GetCfg(suitrarity);
 
-             _ui.m_txtRenewShow.text = string.Format("套装所有部件属性+{0}%", renewCfg.addition * 100 / 10000);
 
-             _ui.m_comRenewRewardGet.target.visible = true;
 
-             SuitFosterListCfg cfg = SuitFosterListCfgArray.Instance.GetCfg(_suitId);
 
-             if (cfg.renewRewardsArr.Length <= 0)
 
-             {
 
-                 _ui.m_comRenewRewardGet.target.visible = false;
 
-                 return;
 
-             }
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.renewRewardsArr[0][0]);
 
-             _ui.m_comRenewRewardGet.m_loaReward.url = ResPathUtil.GetIconPath(itemCfg);
 
-         }
 
-         private void ListRenewMaterialItemRender(int index, GObject obj)
 
-         {
 
-             UI_ListMaterialsItem item = UI_ListMaterialsItem.Proxy(obj);
 
-             int suitrarity = SuitCfgArray.Instance.GetCfg(_suitId).rarity;
 
-             int[][] materialsArr = SuitRenewCfgArray.Instance.GetCfg(suitrarity).materialsArr;
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(materialsArr[index][0]);
 
-             item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
 
-             int has = ItemDataManager.GetItemNum(itemCfg.id);
 
-             int need = materialsArr[index][1];
 
-             item.m_txtHas.text = StringUtil.GetColorText(has.ToString(), has >= need ? "#F2DB96" : "#C9F1A5");
 
-             item.m_txtNeed.text = need.ToString();
 
-             if (_canRenew && has < need) _canRenew = false;
 
-             item.target.data = materialsArr[index][0];
 
-         }
 
-         private void OnListRenewMaterialsItem(EventContext context)
 
-         {
 
-             int itemId = (int)(context.data as GComponent).data;
 
-             // GoodsItemTipsController.ShowItemTips(itemId);
 
-             ViewManager.Show(ViewName.APPROACH_OF_ITEM_VIEW, new object[] { itemId, new object[] { typeof(SuitView).FullName, this.viewData } });
 
-         }
 
-         private void OnClickBtnRenew()
 
-         {
 
-             if (!_canRenew)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("材料不足");
 
-                 return;
 
-             }
 
-             SuitFosterData data = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId);
 
-             SuitFosterListCfg cfg = SuitFosterListCfgArray.Instance.GetCfg(_suitId);
 
-             if (data.maintainStep < cfg.renewOpenLv)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt(string.Format("完成{0}开启换新", SuitFosterDataManager.Instance.stepNames[cfg.renewOpenLv - 1]));
 
-                 return;
 
-             }
 
-             SuitFosterHelper.SendMakeNewSuit(_suitId).Coroutine();
 
-         }
 
-         private void OnListenerRenew()
 
-         {
 
-             ViewManager.Show<SuitRenewFinishView>(_suitId);
 
-             UpdateRenew();
 
-             Debug.Log("换新奖励:" + ItemDataManager.GetItemNum(10370));
 
-         }
 
-     }
 
- }
 
 
  |