123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- using UI.CommonGame;
- using System.Collections.Generic;
- using FairyGUI;
- using System;
- namespace GFGGame
- {
- /// <summary>
- /// 获取途径
- /// </summary>
- public class ApproachOfItemView : BaseWindow
- {
- private UI_ApproachOfItemUI _ui;
- private List<string[]> _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<string[]>();
- 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;
- }
- }
- 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];
- var levelCfgId = int.Parse(value);
- var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
- if (levelCfg.type == ConstInstanceZonesType.Story)
- {
- var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId);
- string chapter = NumberUtil.GetChiniseNumberText(chapterCfg.order);
- string level = NumberUtil.GetChiniseNumberText(levelCfg.order);
- if (levelCfg.subType == ConstInstanceZonesSubType.Normal)
- {
- listItem.target.text = string.Format(gameFunctionCfg.name, chapter, level);
- }
- else if (levelCfg.subType == ConstInstanceZonesSubType.Hard)
- {
- listItem.target.text = string.Format("精英" + gameFunctionCfg.name, chapter, level);
- }
- }
- else if (levelCfg.type == ConstInstanceZonesType.Studio)
- {
- var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
- listItem.target.text = levelCfg.name;
- }
- }
- else if (functionId == ConstFunctionId.FU_ZHUANG_DIAN)
- {
- int shopId = int.Parse(infos[1]);
- if (shopId == ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID)
- {
- listItem.target.text = "活动商店";
- }
- else if (shopId == ConstStoreId.LUCKY_BOX_STORE_ID)
- {
- listItem.target.text = "落星商店";
- }
- else
- {
- listItem.target.text = "服装店";
- }
- }
- else
- {
- listItem.target.text = gameFunctionCfg.name;
- }
- listItem.target.data = infos;
- }
- private void OnClickListApproachItem(EventContext context)
- {
- GObject listItem = context.data as GObject;
- string[] infos = listItem.data as string[];
- string functionId = infos[0];
- bool isJump = true;
- switch (functionId)
- {
- case ConstFunctionId.FU_ZHUANG_DIAN:
- this.Hide();
- object[] temp = viewData as object[];
- int count = temp.Length > 2 ? (int)temp[2] : 0;
- int shopId = int.Parse(infos[1]);
- isJump = ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { shopId, null, _itemId, count }, _fromeViewDatas, true, true);
- break;
- case ConstFunctionId.FU_ZHUANG_DECOMPOSE:
- this.Hide();
- isJump = ViewManager.Show<ClothingDecomposeView>(null, _fromeViewDatas);
- break;
- case ConstFunctionId.SHOP_GIFT_BAG:
- this.Hide();
- int giftBagValue = int.Parse(infos[1]);
- isJump = ViewManager.Show<RechargeStoreView>(giftBagValue, _fromeViewDatas);
- break;
- case ConstFunctionId.SHOP_EXCHANGE:
- this.Hide();
- int exchangeValue = int.Parse(infos[1]);
- isJump = ViewManager.Show<RechargeStoreView>(exchangeValue, _fromeViewDatas);
- break;
- case ConstFunctionId.JU_QING_GUAN_QIA:
- string value = infos[1];
- var levelCfgId = int.Parse(value);
- var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
- isJump = false;
- if (levelCfg.type == ConstInstanceZonesType.Story)
- {
- if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(ViewName.STORY_CHAPTER_VIEW))
- {
- break;
- }
- if (!MainStoryDataManager.CheckLevelUnlock(levelCfgId))
- {
- PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
- break;
- }
- if ((string)_fromeViewDatas[0] == ViewName.DRESS_UP_FIGHT_VIEW)
- {
- //从战斗换装必需品来源跳转到剧情界面,在剧情界面点返回后直接返回章节界面,无需返回换装界面
- _fromeViewDatas = null;
- }
- isJump = ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, levelCfg.chapterId, _fromeViewDatas, true);
- InstanceZonesController.ShowLevelView(levelCfgId, StudioDataManager.Instance.OnFinishStoryLevel);
- }
- else if (levelCfg.type == ConstInstanceZonesType.Studio)
- {
- StudioCfg studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
- if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(studioCfg.funId))
- {
- break;
- }
- //TO DO
- List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgs(studioCfg.type, studioCfg.subType, studioCfg.id);
- StudioDataManager.Instance.IsCanFight(levelCfg.id, out bool canFight, out string content);
- if (!canFight)
- {
- PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
- break;
- }
- this.Hide();
- if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
- {
- PromptController.Instance.ShowFloatTextPrompt("不在活动周期内");
- break;
- }
- int type = studioCfg.funId == typeof(StudioPropertyView).Name ? 1 : 0;
- StudioDataManager.Instance.TYPE_SELECT_INDEX = type;
- StudioDataManager.Instance.PROPERTY_SELECT_INDEX = 0;
- if (studioCfg.funId == typeof(StudioPropertyView).Name)
- {
- List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgs(typeof(StudioPropertyView).Name);
- for (int i = 0; i < studioCfgs.Count; i++)
- {
- if (studioCfgs[i].id == studioCfg.id)
- {
- StudioDataManager.Instance.PROPERTY_SELECT_INDEX = i;
- break;
- }
- }
- }
- string viewName = "GFGGame." + studioCfg.funId;
- ViewManager.Show(viewName, new object[] { type, 0 }, _fromeViewDatas);
- StudioDataManager.Instance.VIEW_NAME = studioCfg.funId; ;
- InstanceZonesController.ShowLevelView(levelCfgId, StudioDataManager.Instance.OnFinishStoryLevel);
- isJump = true;
- break;
- }
- isJump = true;
- StoryController.ShowLevelView(levelCfgId);
- // StoryController.ShowLevelView(levelCfgId);
- break;
- case ConstFunctionId.FU_ZHUANG_HE_CHENG:
- isJump = false;
- int suitId = SuitCfgManager.Instance.GetItemSuitId(_itemId);
- if (suitId > 0)
- {
- this.Hide();
- isJump = ViewManager.Show(ViewName.CLOTHING_SYNTHETIC_VIEW, new object[] { suitId, _itemId }, _fromeViewDatas);
- }
- break;
- case ConstFunctionId.ZHAI_XING:
- this.Hide();
- isJump = ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, _fromeViewDatas, true);
- break;
- case ConstFunctionId.TAO_ZHUANG_TU_JIAN:
- isJump = false;
- if (ViewManager.isViewOpen(ViewName.SUIT_GUIDE_VIEW))
- {
- this.Hide();
- return;
- }
- this.Hide();
- isJump = ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, null, _fromeViewDatas);
- break;
- case ConstFunctionId.TAO_ZHUANG_HE_CHENG:
- this.Hide();
- isJump = ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW);
- break;
- case ConstFunctionId.SUIT_FOSTER:
- this.Hide();
- isJump = ViewManager.Show<SuitListView>(null, _fromeViewDatas);
- break;
- }
- if (isJump)
- {
- EventAgent.DispatchEvent(ConstMessage.JUMP_TO_SOURCE);
- }
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- if (_approachDatas == null) return;
- int index = 0;
- for (int i = 0; i < _approachDatas.Count; i++)
- {
- if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN)
- {
- index = i;
- break;
- }
- }
- GuideController.TryGuide(_ui.m_listApproach, ConstGuideId.BUY_CLOTHING, 4, "该物品可以在服装店购买,点开服装店看看", index, true, (int)(this.viewCom.y + this.viewCom.height + 10));
- }
- }
- }
|