| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 | using System.Collections.Generic;using FairyGUI;using UI.CommonGame;namespace GFGGame{    public class ApproachView    {        private UI_ComTipsApproach _ui;        private object[] _viewData;        private int _itemId;        private object[] _fromeViewDatas;        private int _needCount;//需求总量        private List<string[]> _approachDatas = new List<string[]>();        public void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            UI_ComTipsApproach.ProxyEnd();        }        public void OnHide()        {            // _ui.m_list.onClickItem.Remove(OnClickListApproachItem);            if (_ui.m_list.numItems > 0)            {                _ui.m_list.ScrollToView(0);                _ui.m_list.numItems = 0;            }            _approachDatas.Clear();            _fromeViewDatas = null;        }        public void OnInit(GComponent component)        {            _ui = UI_ComTipsApproach.Proxy(component);            _ui.m_list.itemRenderer = ListApproachItemRenderer;        }        public void OnShow(object[] viewData)        {            _viewData = viewData;            _itemId = (int)viewData[0];            _fromeViewDatas = viewData[1] as object[];            // _needCount = viewData.Length > 2 ? (int)viewData[2] : 0;            int needCount = viewData.Length > 2 ? (int)viewData[2] : 0;            _needCount = (int)needCount;            SetData();            UpdateView();        }        private void SetData()        {            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);            if (string.IsNullOrEmpty(itemCfg.approach)) return;            string[] approachStrs = itemCfg.approach.Split(';');            foreach (string approachStr in approachStrs)            {                if (string.IsNullOrEmpty(approachStr)) continue;                string[] infos = approachStr.Split('=');                _approachDatas.Add(infos);            }        }        private void UpdateView()        {            _ui.m_txtNone.visible = _approachDatas.Count == 0;            _ui.m_list.numItems = _approachDatas.Count;            _ui.m_list.data = _approachDatas;        }        private void ListApproachItemRenderer(int index, GObject item)        {            UI_ListSourceItem listItem = UI_ListSourceItem.Proxy(item);            string[] infos = _approachDatas[index];            string functionId = infos[0];            GameFunctionCfg gameFunctionCfg = GameFunctionCfgArray.Instance.GetCfg(functionId);            // FunctionOpenCfg functionOpenCfg = FunctionOpenCfgArray.Instance.GetCfg(gameFunctionCfg.functionId);            // listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(functionOpenCfg.res);            if (functionId == ConstFunctionId.JU_QING_GUAN_QIA)            {                var levelCfgId = int.Parse(infos[1]);                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.m_txtSourceName.text = string.Format(gameFunctionCfg.name, chapter, level);                    }                    else if (levelCfg.subType == ConstInstanceZonesSubType.Hard)                    {                        listItem.m_txtSourceName.text = string.Format("精英" + gameFunctionCfg.name, chapter, level);                    }                }                else if (levelCfg.type == ConstInstanceZonesType.Studio)                {                    var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);                    listItem.m_txtSourceName.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.m_txtSourceName.text = "活动商店";                }                else if (shopId == ConstStoreId.LUCKY_BOX_STORE_ID)                {                    listItem.m_txtSourceName.text = "落星商店";                }                else if (shopId == ConstStoreId.GALLERY_STORE_ID)                {                    listItem.m_txtSourceName.text = "画廊商店";                }                else                {                    listItem.m_txtSourceName.text = "服装店";                }            }            else if (functionId == ConstFunctionId.STORE)            {                int storeTabId = int.Parse(infos[1]);                int storeSubId = int.Parse(infos[2]);                listItem.m_txtSourceName.text = StoreTabCfgArray.Instance.GetCfg(storeTabId).subTabArr[storeSubId][0];            }            else            {                listItem.m_txtSourceName.text = gameFunctionCfg.name;            }            if (listItem.target.data == null)            {                listItem.m_btnGo.target.onClick.Add(OnClickListApproachItem);            }            listItem.m_btnGo.target.data = infos;            UI_ListSourceItem.ProxyEnd();        }        private void OnClickListApproachItem(EventContext context)        {            GObject btnGo = context.sender as GObject;            string[] infos = btnGo.data as string[];            string functionId = infos[0];            long hasNum = ItemDataManager.GetItemNum(_itemId);            long needCount = 0;            bool isJump = true;            switch (functionId)            {                case ConstFunctionId.FU_ZHUANG_DIAN:                    // this.Hide();                    needCount = (_needCount - hasNum) <= 0 ? 1 : _needCount - hasNum;                    int shopId = int.Parse(infos[1]);                    // if (shopId == ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID)                    // {                    //     PromptController.Instance.ShowFloatTextPrompt("活动暂未开启");                    //     isJump = false;                    //     break;                    // }                    isJump = ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { shopId, null, _itemId, needCount }, _fromeViewDatas, true, true);                    break;                case ConstFunctionId.FU_ZHUANG_DECOMPOSE:                    // this.Hide();                    isJump = ViewManager.Show<ClothingDecomposeView>(null, _fromeViewDatas);                    break;                case ConstFunctionId.STORE:                    int storeTabId = int.Parse(infos[1]);                    int storeSubId = int.Parse(infos[2]);                    isJump = ViewManager.Show<StoreView>(new object[] { storeTabId, storeSubId });                    return;                // case ConstFunctionId.SHOP_GIFT_BAG:                //     // this.Hide();                //     int giftBagValue = int.Parse(infos[1]);                //     isJump = ViewManager.Show<StoreView>(new object[] { ConstFunctionId.STORE_CHARGE, giftBagValue }, _fromeViewDatas);                //     break;                // case ConstFunctionId.SHOP_EXCHANGE:                //     // this.Hide();                //     int exchangeValue = int.Parse(infos[1]);                //     isJump = ViewManager.Show<StoreView>(new object[] { ConstFunctionId.STORE_CHARGE, 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.Studio)                    {                        StudioCfg studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);                        if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(studioCfg.funId))                        {                            break;                        }                        //TO DO                        List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(studioCfg.type, studioCfg.subType, studioCfg.id);                        StudioDataManager.Instance.IsCanFight(levelCfg.id, out bool canFight, out string content);                        if (!canFight)                        {                            PromptController.Instance.ShowFloatTextPrompt("关卡未开启");                            break;                        }                        if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))                        {                            PromptController.Instance.ShowFloatTextPrompt("不在活动周期内");                            break;                        }                        if (studioCfg.funId == typeof(StudioFilingView).Name)                        {                            StudioDataManager.Instance.filingChapterId = studioCfg.id;                            ViewManager.Show<StudioFilingView>(null, _fromeViewDatas);                            MainStoryDataManager.currentLevelCfgId = levelCfg.id;                            InstanceZonesController.ShowLevelView(levelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel, _itemId, _needCount);                            isJump = true;                        }                        else                        {                            StudioDataManager.Instance.PROPERTY_SELECT_INDEX = 0;                            if (studioCfg.funId == typeof(StudioPropertyView).Name)                            {                                List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(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, StudioDataManager.Instance.PROPERTY_SELECT_INDEX, _fromeViewDatas);                            StudioDataManager.Instance.VIEW_NAME = viewName;                            InstanceZonesController.ShowLevelView(levelCfgId, StudioDataManager.Instance.OnFinishStudioStoryLevel, _itemId, _needCount);                            isJump = true;                        }                        break;                    }                    else                    {                        // 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);                        StoryController.ShowLevelView(levelCfgId, _itemId, _needCount);                        break;                    }                case ConstFunctionId.FU_ZHUANG_HE_CHENG:                    isJump = false;                    int suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemId);                    if (suitId > 0)                    {                        SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);                        bool isPass = InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId);                        if (suitCfg.syntheticStoryLevelId > 0 && !isPass)                        {                            isJump = ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW, suitId, _fromeViewDatas);                        }                        else                        {                            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))                    {                        return;                    }                    isJump = ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, null, _fromeViewDatas);                    break;                case ConstFunctionId.TAO_ZHUANG_HE_CHENG:                    isJump = ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW);                    break;                case ConstFunctionId.SUIT_FOSTER:                    isJump = ViewManager.Show<ClothingListView>(null, _fromeViewDatas);                    break;                case ConstFunctionId.DAILY_TASK:                    isJump = ViewManager.Show<TaskView>(null, _fromeViewDatas);                    break;                case ConstFunctionId.LEAGUE_PRAY:                    isJump = ViewManager.Show<LeaguePrayView>(null, _fromeViewDatas);                    break;                case ConstFunctionId.LEAGUE_ANSWER:                    if (LeagueDataManager.Instance.Type == LeagueJoinType.Join)                    {                        ViewManager.Show<LeagueView>(null, _fromeViewDatas);                        isJump = ViewManager.Show<LeagueAnswerView>();                    }                    else                    {                        if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(nameof(LeagueView))) return;                        PromptController.Instance.ShowFloatTextPrompt("暂未加入雅集");                    }                    break;            }            if (isJump)            {                EventAgent.DispatchEvent(ConstMessage.JUMP_TO_SOURCE);            }        }    }}
 |