using UI.CommonGame; using System.Collections.Generic; using FairyGUI; namespace GFGGame { /// /// 获取途径 /// public class ApproachOfItemView : BaseWindow { private UI_ApproachOfItemUI _ui; private List _approachDatas; private int _itemId; private object[] _fromeViewDatas; protected override void OnInit() { base.OnInit(); _ui = UI_ApproachOfItemUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; _ui.m_listApproach.itemRenderer = ListApproachItemRenderer; _ui.m_listApproach.onClickItem.Add(OnClickListApproachItem); } protected override void OnShown() { base.OnShown(); object[] temp = viewData as object[]; _itemId = (int)temp[0]; _fromeViewDatas = temp[1] as object[]; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId); _ui.m_txtName.text = itemCfg.name; _ui.m_listApproach.RemoveChildrenToPool(); if (itemCfg.approach.Length > 0) { _ui.m_txtNone.visible = false; string[] approachStrs = itemCfg.approach.Split(';'); _approachDatas = new List(); foreach (string approachStr in approachStrs) { if (approachStr.Length > 0) { string[] infos = approachStr.Split('='); _approachDatas.Add(infos); } } _ui.m_listApproach.numItems = _approachDatas.Count; _ui.m_listApproach.ResizeToFit(); } else { _ui.m_txtNone.visible = true; _ui.m_listApproach.height = 162; } GuideController.TryGuideApproachOfItemViewList(_ui.m_listApproach); } protected override void OnHide() { base.OnHide(); _fromeViewDatas = null; } private void ListApproachItemRenderer(int index, GObject item) { UI_ButtonApproach listItem = UI_ButtonApproach.Proxy(item); string[] infos = _approachDatas[index]; string functionId = infos[0]; GameFunctionCfg gameFunctionCfg = GameFunctionCfgArray.Instance.GetCfg(functionId); if (functionId == ConstFunctionId.JU_QING_GUAN_QIA) { string value = infos[1]; string[] values = value.Split('_'); int chapterInt = int.Parse(values[0]); int levelInt = int.Parse(values[1]); string chapter = NumberUtil.GetChiniseNumberText(chapterInt); string level = NumberUtil.GetChiniseNumberText(levelInt); listItem.target.text = string.Format(gameFunctionCfg.name, chapter, level); } else { listItem.target.text = gameFunctionCfg.name; } listItem.target.data = infos; } private void OnClickListApproachItem(EventContext context) { GuideController.HideGuide(); GObject listItem = context.data as GObject; string[] infos = listItem.data as string[]; string functionId = infos[0]; switch (functionId) { case ConstFunctionId.FU_ZHUANG_DIAN: this.Hide(); ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { null, null, _itemId }, null, false, true); break; case ConstFunctionId.JU_QING_GUAN_QIA: string value = infos[1]; string[] values = value.Split('_'); int chapterInt = int.Parse(values[0]); int levelInt = int.Parse(values[1]); if ((string)_fromeViewDatas[0] == ViewName.DRESS_UP_FIGHT_VIEW) { //从战斗换装必需品来源跳转到剧情界面,在剧情界面点返回后直接返回章节界面,无需返回换装界面 _fromeViewDatas = null; } ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, chapterInt, _fromeViewDatas, true); StoryController.ShowLevelView(chapterInt, levelInt); break; case ConstFunctionId.FU_ZHUANG_HE_CHENG: int suitId = SuitCfgManager.Instance.GetItemSuitId(_itemId); if (suitId > 0) { this.Hide(); ViewManager.Show(ViewName.CLOTHING_SYNTHETIC_VIEW, suitId); } break; case ConstFunctionId.ZHAI_XING: this.Hide(); ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, _fromeViewDatas); break; case ConstFunctionId.TAO_ZHUANG_TU_JIAN: this.Hide(); ViewManager.Show(ViewName.SUIT_GUIDE_VIEW); break; case ConstFunctionId.TAO_ZHUANG_HE_CHENG: this.Hide(); ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW); break; } } } }