Esempio n. 1
0
        private BannerParam[] makeValidBannerParams()
        {
            GameManager instance = MonoSingleton <GameManager> .Instance;

            BannerParam[] banners = instance.MasterParam.Banners;
            if (banners == null)
            {
                return(new BannerParam[0]);
            }
            List <BannerParam> bannerParamList = new List <BannerParam>();

            GachaParam[] gachas          = instance.Gachas;
            QuestParam[] availableQuests = instance.Player.AvailableQuests;
            QuestParam   questParam1     = (QuestParam)null;
            QuestParam   lastStoryQuest  = instance.Player.FindLastStoryQuest();
            long         serverTime      = Network.GetServerTime();
            DateTime     now             = TimeManager.FromUnixTime(serverTime);

            for (int index = 0; index < banners.Length; ++index)
            {
                BannerParam banner = banners[index];
                if (!string.IsNullOrEmpty(banner.banner) && bannerParamList.FindIndex((Predicate <BannerParam>)(p => p.iname == banner.iname)) == -1 && banner.IsHomeBanner)
                {
                    if (banner.type == BannerType.shop)
                    {
                        if (instance.IsLimitedShopOpen)
                        {
                            if (instance.LimitedShopList != null && !string.IsNullOrEmpty(banner.sval))
                            {
                                JSON_ShopListArray.Shops shops = Array.Find <JSON_ShopListArray.Shops>(instance.LimitedShopList, (Predicate <JSON_ShopListArray.Shops>)(p => p.gname == banner.sval));
                                if (shops != null)
                                {
                                    banner.begin_at = TimeManager.FromUnixTime(shops.start).ToString();
                                    banner.end_at   = TimeManager.FromUnixTime(shops.end).ToString();
                                    if (!banner.IsAvailablePeriod(now))
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            else if (!banner.IsAvailablePeriod(now))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.storyQuest)
                    {
                        if (lastStoryQuest != null)
                        {
                            if (string.IsNullOrEmpty(banner.sval))
                            {
                                questParam1 = lastStoryQuest;
                                if (!banner.IsAvailablePeriod(now))
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                QuestParam questParam2 = Array.Find <QuestParam>(availableQuests, (Predicate <QuestParam>)(p => p.iname == banner.sval));
                                if (questParam2 == null || questParam2.iname != lastStoryQuest.iname && questParam2.state == QuestStates.New)
                                {
                                    questParam2 = lastStoryQuest;
                                }
                                if (!questParam2.IsDateUnlock(serverTime))
                                {
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.eventQuest || banner.type == BannerType.multiQuest)
                    {
                        if (!string.IsNullOrEmpty(banner.sval))
                        {
                            QuestParam questParam2 = Array.Find <QuestParam>(availableQuests, (Predicate <QuestParam>)(p => p.iname == banner.sval));
                            if (questParam2 == null || !questParam2.IsDateUnlock(serverTime))
                            {
                                continue;
                            }
                        }
                        else if (!banner.IsAvailablePeriod(now))
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.gacha)
                    {
                        if (!string.IsNullOrEmpty(banner.sval))
                        {
                            GachaParam gachaParam = Array.Find <GachaParam>(gachas, (Predicate <GachaParam>)(p => p.iname == banner.sval));
                            if (gachaParam != null)
                            {
                                banner.begin_at = TimeManager.FromUnixTime(gachaParam.startat).ToString();
                                banner.end_at   = TimeManager.FromUnixTime(gachaParam.endat).ToString();
                                if (!banner.IsAvailablePeriod(now))
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else if (!banner.IsAvailablePeriod(now))
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.url)
                    {
                        if (string.IsNullOrEmpty(banner.sval) || !banner.IsAvailablePeriod(now))
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.towerQuest)
                    {
                        if (!banner.IsAvailablePeriod(now))
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.arena)
                    {
                        if (!banner.IsAvailablePeriod(now))
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.pvp)
                    {
                        if (!banner.IsAvailablePeriod(now))
                        {
                            continue;
                        }
                    }
                    else if (banner.type == BannerType.ordealQuest)
                    {
                        if (!string.IsNullOrEmpty(banner.sval))
                        {
                            QuestParam questParam2 = Array.Find <QuestParam>(availableQuests, (Predicate <QuestParam>)(p => p.iname == banner.sval));
                            if (questParam2 == null || !questParam2.IsDateUnlock(serverTime))
                            {
                                continue;
                            }
                        }
                        else if (!banner.IsAvailablePeriod(now))
                        {
                            continue;
                        }
                    }
                    bannerParamList.Add(banner);
                }
            }
            for (int index1 = 0; index1 < bannerParamList.Count - 1; ++index1)
            {
                for (int index2 = index1 + 1; index2 < bannerParamList.Count; ++index2)
                {
                    if (bannerParamList[index1].priority > bannerParamList[index2].priority)
                    {
                        BannerParam bannerParam = bannerParamList[index1];
                        bannerParamList[index1] = bannerParamList[index2];
                        bannerParamList[index2] = bannerParam;
                    }
                }
            }
            return(bannerParamList.ToArray());
        }
Esempio n. 2
0
        public static BannerParam[] MakeValidBannerParams(bool _is_home_banner = true)
        {
            List <BannerParam> bannerParamList = new List <BannerParam>();
            GameManager        instance        = MonoSingleton <GameManager> .Instance;

            BannerParam[] banners = instance.MasterParam.Banners;
            if (banners == null)
            {
                DebugUtility.LogError("バナーの設定がありません、有効なバナーを1つ以上設定してください");
                return((BannerParam[])null);
            }
            QuestParam lastStoryQuest = instance.Player.FindLastStoryQuest();

            QuestParam[] availableQuests = instance.Player.AvailableQuests;
            long         serverTime      = Network.GetServerTime();
            DateTime     now             = TimeManager.FromUnixTime(serverTime);

            for (int index = 0; index < banners.Length; ++index)
            {
                BannerParam param = banners[index];
                bool        flag  = true;
                if (param != null && !string.IsNullOrEmpty(param.banner) && bannerParamList.FindIndex((Predicate <BannerParam>)(p => p.iname == param.iname)) == -1 && (!_is_home_banner || param.IsHomeBanner))
                {
                    if (param.type == BannerType.shop)
                    {
                        if (instance.IsLimitedShopOpen)
                        {
                            if (instance.LimitedShopList != null && !string.IsNullOrEmpty(param.sval))
                            {
                                JSON_ShopListArray.Shops shops = Array.Find <JSON_ShopListArray.Shops>(instance.LimitedShopList, (Predicate <JSON_ShopListArray.Shops>)(p => p.gname == param.sval));
                                if (shops != null)
                                {
                                    param.begin_at = TimeManager.FromUnixTime(shops.start).ToString();
                                    param.end_at   = TimeManager.FromUnixTime(shops.end).ToString();
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (param.type == BannerType.storyQuest)
                    {
                        flag = false;
                        if (lastStoryQuest != null)
                        {
                            QuestParam questParam;
                            if (string.IsNullOrEmpty(param.sval))
                            {
                                questParam = lastStoryQuest;
                            }
                            else
                            {
                                questParam = Array.Find <QuestParam>(availableQuests, (Predicate <QuestParam>)(p => p.iname == param.sval));
                                if (questParam == null || questParam.iname != lastStoryQuest.iname && questParam.state == QuestStates.New)
                                {
                                    questParam = lastStoryQuest;
                                }
                            }
                            if (!questParam.IsDateUnlock(serverTime))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (param.type == BannerType.eventQuest || param.type == BannerType.multiQuest)
                    {
                        if (!string.IsNullOrEmpty(param.sval))
                        {
                            QuestParam questParam = Array.Find <QuestParam>(availableQuests, (Predicate <QuestParam>)(p => p.iname == param.sval));
                            if (questParam == null || !questParam.IsDateUnlock(serverTime))
                            {
                                continue;
                            }
                        }
                    }
                    else if (param.type != BannerType.towerQuest && param.type != BannerType.gacha)
                    {
                        if (param.type == BannerType.url)
                        {
                            if (string.IsNullOrEmpty(param.sval))
                            {
                                continue;
                            }
                        }
                        else if (param.type == BannerType.arena || param.type == BannerType.pvp || param.type != BannerType.ordealQuest)
                        {
                            ;
                        }
                    }
                    if (!flag || param.IsAvailablePeriod(now))
                    {
                        bannerParamList.Add(param);
                    }
                }
            }
            bannerParamList.Sort((Comparison <BannerParam>)((a, b) => a.priority - b.priority));
            return(bannerParamList.ToArray());
        }