Esempio n. 1
0
        public bool IsUIDForAShardUpgradableDeployable(string uid)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            IDeployableVO        optional             = staticDataController.GetOptional <TroopTypeVO>(uid);

            if (optional == null)
            {
                optional = staticDataController.GetOptional <SpecialAttackTypeVO>(uid);
            }
            return(optional != null && !string.IsNullOrEmpty(optional.UpgradeShardUid));
        }
Esempio n. 2
0
        public int GetUpgradeQualityForDeployableUID(string uid)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            IDeployableVO        optional             = staticDataController.GetOptional <TroopTypeVO>(uid);

            if (optional == null)
            {
                optional = staticDataController.GetOptional <SpecialAttackTypeVO>(uid);
            }
            if (optional == null)
            {
                return(0);
            }
            return(this.GetUpgradeQualityForDeployable(optional));
        }
Esempio n. 3
0
        public bool FindAvailableIAP(TargetedBundleVO offerVO, out string currentIapId, out string offerCost)
        {
            bool result = false;
            StaticDataController staticDataController = Service.StaticDataController;

            currentIapId = string.Empty;
            offerCost    = string.Empty;
            if (offerVO == null)
            {
                return(result);
            }
            InAppPurchaseController inAppPurchaseController = Service.InAppPurchaseController;
            int i     = 0;
            int count = offerVO.LinkedIAPs.Count;

            while (i < count)
            {
                string uid = offerVO.LinkedIAPs[i];
                InAppPurchaseTypeVO optional = staticDataController.GetOptional <InAppPurchaseTypeVO>(uid);
                if (optional != null)
                {
                    InAppPurchaseProductInfo iAPProduct = inAppPurchaseController.GetIAPProduct(optional.ProductId);
                    if (iAPProduct != null)
                    {
                        currentIapId = optional.ProductId;
                        offerCost    = iAPProduct.FormattedRealCost;
                        result       = true;
                        break;
                    }
                }
                i++;
            }
            return(result);
        }
Esempio n. 4
0
        public CrateVO GetCrateVOFromTargetedOffer(TargetedBundleVO offerVO)
        {
            StaticDataController staticDataController = Service.StaticDataController;

            if (offerVO == null)
            {
                return(null);
            }
            if (offerVO.RewardUIDs == null || offerVO.RewardUIDs.Count < 1)
            {
                return(null);
            }
            int i     = 0;
            int count = offerVO.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = Service.StaticDataController.GetOptional <RewardVO>(offerVO.RewardUIDs[i]);
                if (optional != null)
                {
                    string crateReward = optional.CrateReward;
                    if (!string.IsNullOrEmpty(crateReward))
                    {
                        return(staticDataController.GetOptional <CrateVO>(crateReward));
                    }
                }
                i++;
            }
            return(null);
        }
Esempio n. 5
0
        public static void GrantInstantSpecialAttackUpgrade(string rewardString)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            UnlockedLevelData    unlockedLevels       = Service.CurrentPlayer.UnlockedLevels;

            string[]            array    = RewardUtils.ParsePairedStrings(rewardString, ':');
            string              uid      = array[0];
            int                 level    = Convert.ToInt32(array[1]);
            SpecialAttackTypeVO optional = staticDataController.GetOptional <SpecialAttackTypeVO>(uid);

            if (optional != null)
            {
                StarshipUpgradeCatalog starshipUpgradeCatalog = Service.StarshipUpgradeCatalog;
                SpecialAttackTypeVO    byLevel = starshipUpgradeCatalog.GetByLevel(optional, level);
                if (byLevel != null)
                {
                    unlockedLevels.Starships.SetLevel(byLevel);
                }
            }
            else
            {
                Service.Logger.WarnFormat("Instant spec Attack upgrade {0} does not exist", new object[]
                {
                    rewardString
                });
            }
        }
Esempio n. 6
0
        public bool PlayMostRecentStoryAction()
        {
            StaticDataController staticDataController = Service.StaticDataController;
            EpisodeProgressInfo  episodeProgressInfo  = Service.CurrentPlayer.EpisodeProgressInfo;
            EpisodeDataVO        episodeDataVO        = staticDataController.Get <EpisodeDataVO>(episodeProgressInfo.uid);
            string text = string.Empty;

            if (episodeProgressInfo.grindInfo.Started > 0)
            {
                text = staticDataController.Get <EpisodeTaskVO>(episodeDataVO.GrindTask).StoryID;
            }
            if (string.IsNullOrEmpty(text))
            {
                int num = Math.Min(episodeProgressInfo.currentTaskIndex, episodeDataVO.Tasks.Length - 1);
                for (int i = num; i >= 0; i--)
                {
                    EpisodeTaskVO optional = staticDataController.GetOptional <EpisodeTaskVO>(episodeDataVO.Tasks[i]);
                    if (optional != null && !string.IsNullOrEmpty(optional.StoryID))
                    {
                        text = optional.StoryID;
                        break;
                    }
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                Service.Logger.Error("EpisodeInfoScreen: Could not determine most recent story ID");
            }
            return(this.PlayTaskStoryAction(text));
        }
Esempio n. 7
0
        private void LoadCurrentTargetedOffer(string offerId, uint triggeredTime)
        {
            StaticDataController staticDataController = Service.StaticDataController;

            this.CurrentTargetedOffer = staticDataController.GetOptional <TargetedBundleVO>(offerId);
            if (this.CurrentTargetedOffer != null)
            {
                this.OfferExpiresAt = triggeredTime + (uint)this.CurrentTargetedOffer.Duration;
            }
            Service.EventManager.SendEvent(EventId.TargetedBundleContentPrepared, null);
        }
Esempio n. 8
0
        private void RefreshEpisodeData()
        {
            StaticDataController staticDataController = Service.StaticDataController;
            EpisodeProgressInfo  episodeProgressInfo  = Service.CurrentPlayer.EpisodeProgressInfo;

            if (episodeProgressInfo == null)
            {
                this.CurrentEpisodeData = null;
                return;
            }
            string uid = episodeProgressInfo.uid;

            if (string.IsNullOrEmpty(uid))
            {
                Service.EventManager.RegisterObserver(this, EventId.FueCompleted);
                this.CurrentEpisodeData = null;
            }
            else if (this.CurrentEpisodeData == null || (this.CurrentEpisodeData != null && this.CurrentEpisodeData.Uid != uid))
            {
                EpisodeDataVO optional = staticDataController.GetOptional <EpisodeDataVO>(uid);
                if (optional != null)
                {
                    this.CurrentEpisodeData = staticDataController.GetOptional <EpisodeDataVO>(uid);
                }
            }
            if (this.CurrentEpisodeData != null)
            {
                Service.Logger.Debug(string.Concat(new string[]
                {
                    "Current Episode: ",
                    this.CurrentEpisodeData.Uid,
                    " is active: ",
                    this.CurrentEpisodeData.StartTime.ToString(),
                    " ---> ",
                    this.CurrentEpisodeData.EndTime.ToString()
                }));
            }
        }
Esempio n. 9
0
        public void GrantTargetedBundleRewards(TargetedBundleVO offerVO)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            int i     = 0;
            int count = offerVO.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = staticDataController.GetOptional <RewardVO>(offerVO.RewardUIDs[i]);
                if (optional == null)
                {
                    Service.Logger.WarnFormat("Trying to grant {0} which cannot be found.", new object[]
                    {
                        offerVO.RewardUIDs[i]
                    });
                }
                else
                {
                    bool flag = true;
                    if (optional.CurrencyRewards != null)
                    {
                        Dictionary <string, int> dictionary = GameUtils.ListToMap(optional.CurrencyRewards);
                        int num = 0;
                        dictionary.TryGetValue("crystals", out num);
                        if (num > 0)
                        {
                            flag = false;
                        }
                    }
                    else if (!string.IsNullOrEmpty(optional.DroidRewards))
                    {
                        flag = false;
                    }
                    else if (optional.BuildingInstantRewards != null || optional.BuildingInstantUpgrades != null || optional.HeroResearchInstantUpgrades != null || optional.TroopResearchInstantUpgrades != null || optional.SpecAttackResearchInstantUpgrades != null)
                    {
                        flag = false;
                    }
                    if (flag)
                    {
                        RewardUtils.GrantInAppPurchaseRewardToHQInventory(optional);
                    }
                    else
                    {
                        RewardUtils.GrantReward(Service.CurrentPlayer, optional);
                    }
                }
                i++;
            }
        }
Esempio n. 10
0
        public bool PlayStoryActionForTaskUid(string uid)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            EpisodeTaskVO        optional             = staticDataController.GetOptional <EpisodeTaskVO>(uid);

            if (optional == null)
            {
                Service.Logger.ErrorFormat("EpisodeController: Cannot play story action! Missing EpisodeTaskVO data for uid:{0}", new object[]
                {
                    uid
                });
                return(false);
            }
            return(Service.EpisodeController.PlayTaskStoryAction(optional.StoryID));
        }
Esempio n. 11
0
        public static void GetInstantSpecialAttackReward(string rewardString, ref RewardComponentTag rct)
        {
            StaticDataController staticDataController = Service.StaticDataController;

            string[]            array    = RewardUtils.ParsePairedStrings(rewardString, ':');
            string              uid      = array[0];
            SpecialAttackTypeVO optional = staticDataController.GetOptional <SpecialAttackTypeVO>(uid);

            if (optional != null)
            {
                rct.RewardName           = LangUtils.GetStarshipDisplayName(optional);
                rct.Quantity             = Service.Lang.Get("LABEL_REWARD_UPGRADE", new object[0]);
                rct.RewardAssetName      = optional.AssetName;
                rct.RewardGeometryConfig = optional;
                rct.Type = RewardType.Troop;
            }
        }
Esempio n. 12
0
        public int getTaskActionTargetAmount(EpisodeTaskActionVO vo, int hqLevel)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            EpisodeTaskScaleVO   optional             = staticDataController.GetOptional <EpisodeTaskScaleVO>(vo.ScaleId);

            switch (hqLevel)
            {
            case 1:
                return(optional.HQ1);

            case 2:
                return(optional.HQ2);

            case 3:
                return(optional.HQ3);

            case 4:
                return(optional.HQ4);

            case 5:
                return(optional.HQ5);

            case 6:
                return(optional.HQ6);

            case 7:
                return(optional.HQ7);

            case 8:
                return(optional.HQ8);

            case 9:
                return(optional.HQ9);

            case 10:
                return(optional.HQ10);

            default:
                Service.Logger.WarnFormat("EpisodeController: Unhandled HQ level of {0}", new object[]
                {
                    hqLevel
                });
                return(0);
            }
        }
Esempio n. 13
0
        public List <PlanetLootEntryVO> GetFeaturedLootEntriesForEpisodeTask(EpisodeTaskVO vo, int maxEntries)
        {
            StaticDataController     staticDataController = Service.StaticDataController;
            CurrentPlayer            currentPlayer        = Service.CurrentPlayer;
            List <PlanetLootEntryVO> list = new List <PlanetLootEntryVO>();

            string[] array;
            if (currentPlayer.Faction == FactionType.Empire)
            {
                array = vo.EmpireRewardItemIds;
            }
            else
            {
                array = vo.RebelRewardItemIds;
            }
            if (array == null)
            {
                return(list);
            }
            int i   = 0;
            int num = array.Length;

            while (i < num)
            {
                PlanetLootEntryVO optional = staticDataController.GetOptional <PlanetLootEntryVO>(array[i]);
                if (optional == null)
                {
                    Service.Logger.ErrorFormat("Couldn't find PlanetLootEntryVO: {0} specified in EpisodeTaskVO: {1}", new object[]
                    {
                        array[i],
                        vo.Uid
                    });
                }
                else if (this.IsPlanetLootEntryValidToShow(currentPlayer, optional))
                {
                    list.Add(optional);
                    if (list.Count >= maxEntries)
                    {
                        break;
                    }
                }
                i++;
            }
            return(list);
        }
Esempio n. 14
0
        public EpisodeTaskActionVO getValidActionForTask(EpisodeTaskVO taskVo)
        {
            EpisodeTaskActionVO result = null;

            string[]             actions = taskVo.Actions;
            StaticDataController staticDataController = Service.StaticDataController;

            for (int i = 0; i < actions.Length; i++)
            {
                EpisodeTaskActionVO optional = staticDataController.GetOptional <EpisodeTaskActionVO>(actions[i]);
                if (this.doesPlayerQualifyForTaskAction(optional))
                {
                    result = optional;
                    break;
                }
            }
            return(result);
        }
Esempio n. 15
0
        public List <PlanetLootEntryVO> GetFeaturedLootEntriesForPlanet(Planet currentPlanet)
        {
            StaticDataController     staticDataController = Service.StaticDataController;
            CurrentPlayer            currentPlayer        = Service.CurrentPlayer;
            List <PlanetLootEntryVO> list         = new List <PlanetLootEntryVO>();
            PlanetLootVO             planetLootVO = staticDataController.Get <PlanetLootVO>(currentPlanet.VO.PlanetLootUid);

            string[] array;
            if (currentPlayer.Faction == FactionType.Empire)
            {
                array = planetLootVO.EmpirePlanetLootEntryUids;
            }
            else
            {
                array = planetLootVO.RebelPlanetLootEntryUids;
            }
            int i   = 0;
            int num = array.Length;

            while (i < num)
            {
                PlanetLootEntryVO optional = staticDataController.GetOptional <PlanetLootEntryVO>(array[i]);
                if (optional == null)
                {
                    Service.Logger.ErrorFormat("Couldn't find PlanetLootEntryVO: {0} specified in PlanetLoot: {1}", new object[]
                    {
                        array[i],
                        currentPlanet.VO.PlanetLootUid
                    });
                }
                else if (this.IsPlanetLootEntryValidToShow(currentPlayer, optional))
                {
                    list.Add(optional);
                    if (list.Count >= GameConstants.PLANET_REWARDS_ITEM_THROTTLE)
                    {
                        break;
                    }
                }
                i++;
            }
            return(list);
        }
Esempio n. 16
0
        private bool CanPurchaseIAPLinkedOffer(TargetedBundleVO currentOffer)
        {
            bool flag = true;
            StaticDataController staticDataController = Service.StaticDataController;
            int i     = 0;
            int count = currentOffer.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = staticDataController.GetOptional <RewardVO>(currentOffer.RewardUIDs[i]);
                if (optional != null && optional.BuildingInstantRewards != null)
                {
                    flag = this.CanPlaceAllRewardBuildings(optional.BuildingInstantRewards);
                    if (!flag)
                    {
                        AlertScreen.ShowModal(false, Service.Lang.Get("promo_error_nospace_title", new object[0]), Service.Lang.Get("promo_error_nospace_desc", new object[0]), null, null);
                        break;
                    }
                }
                i++;
            }
            return(flag);
        }
Esempio n. 17
0
        public EpisodePointScaleVO GetCurrentEpisodePointScaleVO()
        {
            if (this.CurrentEpisodeData == null)
            {
                return(null);
            }
            StaticDataController          staticDataController = Service.StaticDataController;
            EpisodePointScaleVO           result = staticDataController.Get <EpisodePointScaleVO>(this.CurrentEpisodeData.PointScale);
            List <EpisodePointScheduleVO> list   = new List <EpisodePointScheduleVO>();

            foreach (EpisodePointScheduleVO current in staticDataController.GetAll <EpisodePointScheduleVO>())
            {
                EpisodePointScheduleVO episodePointScheduleVO = current;
                if ((long)episodePointScheduleVO.EndTimeEpochSecs > (long)((ulong)ServerTime.Time))
                {
                    if ((long)episodePointScheduleVO.StartTimeEpochSecs <= (long)((ulong)ServerTime.Time))
                    {
                        list.Add(episodePointScheduleVO);
                    }
                }
            }
            if (list.Count > 0)
            {
                List <EpisodePointScheduleVO> arg_C9_0 = list;
                if (EpisodeController.< > f__mg$cache0 == null)
                {
                    EpisodeController.< > f__mg$cache0 = new Comparison <EpisodePointScheduleVO>(EpisodeController.CompareSchedules);
                }
                arg_C9_0.Sort(EpisodeController.< > f__mg$cache0);
                EpisodePointScaleVO optional = staticDataController.GetOptional <EpisodePointScaleVO>(list[0].ScaleId);
                if (optional != null)
                {
                    return(optional);
                }
            }
            return(result);
        }
Esempio n. 18
0
        public void SetPerkImage(UXTexture perkImage, PerkVO perkVO)
        {
            FactionType faction = Service.CurrentPlayer.Faction;
            string      text    = string.Empty;

            if (faction == FactionType.Empire)
            {
                text = perkVO.TextureIdEmpire;
            }
            else
            {
                text = perkVO.TextureIdRebel;
            }
            if (!string.IsNullOrEmpty(text))
            {
                StaticDataController staticDataController = Service.StaticDataController;
                TextureVO            optional             = staticDataController.GetOptional <TextureVO>(text);
                if (optional != null && perkImage.Tag != optional)
                {
                    perkImage.LoadTexture(optional.AssetName);
                    perkImage.Tag = optional;
                }
            }
        }
Esempio n. 19
0
        private void UpdateFromTargetedOfferSummary(TargetedOfferSummary offerSummary)
        {
            DateTime             serverDateTime       = Service.ServerAPI.ServerDateTime;
            StaticDataController staticDataController = Service.StaticDataController;
            bool             flag             = false;
            TargetedBundleVO targetedBundleVO = null;

            if (!string.IsNullOrEmpty(offerSummary.AvailableOffer))
            {
                string availableOffer = offerSummary.AvailableOffer;
                targetedBundleVO = staticDataController.GetOptional <TargetedBundleVO>(availableOffer);
                if (targetedBundleVO != null)
                {
                    flag = targetedBundleVO.IgnoreCooldown;
                }
            }
            int  secondsFromEpoch        = DateUtils.GetSecondsFromEpoch(serverDateTime);
            uint globalCooldownExpiresAt = offerSummary.GlobalCooldownExpiresAt;

            if (!flag && globalCooldownExpiresAt != 0u && (long)secondsFromEpoch < (long)((ulong)globalCooldownExpiresAt))
            {
                Service.Logger.DebugFormat("Offer global cooldown is in effect until {0}", new object[]
                {
                    LangUtils.FormatTime((long)offerSummary.GlobalCooldownExpiresAt)
                });
                this.GlobalCooldownExpiresAt = offerSummary.GlobalCooldownExpiresAt;
                this.OfferExpiresAt          = 0u;
                this.NextOfferAvailableAt    = 0u;
                this.SetBoundedTimer((long)((ulong)this.GlobalCooldownExpiresAt - (ulong)((long)secondsFromEpoch)), new TimerDelegate(this.CheckForNewOffer), false);
            }
            else if (targetedBundleVO != null)
            {
                Service.Logger.DebugFormat("Available offer: {0}", new object[]
                {
                    offerSummary.AvailableOffer
                });
                if (targetedBundleVO.StartTime <= serverDateTime && serverDateTime < targetedBundleVO.EndTime && AudienceConditionUtils.IsValidForClient(targetedBundleVO.AudienceConditions))
                {
                    this.InitializeTriggerOffer(targetedBundleVO);
                }
                else
                {
                    Service.Logger.WarnFormat("Server provided offer {0} was outside of date range {1} to {2}.", new object[]
                    {
                        offerSummary.AvailableOffer,
                        targetedBundleVO.StartTime,
                        targetedBundleVO.EndTime
                    });
                }
            }
            else if (offerSummary.NextOfferAvailableAt > 0u)
            {
                Service.Logger.DebugFormat("Next offer available at {0}.", new object[]
                {
                    LangUtils.FormatTime((long)offerSummary.NextOfferAvailableAt)
                });
                this.NextOfferAvailableAt    = offerSummary.NextOfferAvailableAt;
                this.GlobalCooldownExpiresAt = 0u;
                this.OfferExpiresAt          = 0u;
                this.SetBoundedTimer((long)((ulong)this.NextOfferAvailableAt - (ulong)((long)DateUtils.GetSecondsFromEpoch(serverDateTime))), new TimerDelegate(this.CheckForNewOffer), false);
            }
            else
            {
                this.GlobalCooldownExpiresAt = 0u;
                this.OfferExpiresAt          = 0u;
                this.NextOfferAvailableAt    = 0u;
            }
            this.lastKnownTargetedOffer = null;
            this.FetchingNewOffer       = false;
            if (this.CurrentTargetedOffer != null)
            {
                Service.EventManager.SendEvent(EventId.TargetedBundleContentPrepared, null);
            }
        }
Esempio n. 20
0
        public string GetCrateSupplyRewardName(CrateSupplyVO supplyData)
        {
            string text = string.Empty;

            if (supplyData == null)
            {
                return(text);
            }
            Lang lang = Service.Lang;
            StaticDataController staticDataController = Service.StaticDataController;
            string     rewardUid = supplyData.RewardUid;
            SupplyType type      = supplyData.Type;

            switch (type)
            {
            case SupplyType.Currency:
                text = lang.Get(supplyData.RewardUid.ToUpper(), new object[0]);
                break;

            case SupplyType.Shard:
            {
                EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(rewardUid);
                if (currentEquipmentDataByID != null)
                {
                    text = lang.Get(currentEquipmentDataByID.EquipmentName, new object[0]);
                }
                break;
            }

            case SupplyType.Troop:
            case SupplyType.Hero:
            {
                TroopTypeVO optional = staticDataController.GetOptional <TroopTypeVO>(rewardUid);
                if (optional != null)
                {
                    text = LangUtils.GetTroopDisplayName(optional);
                }
                break;
            }

            case SupplyType.SpecialAttack:
            {
                SpecialAttackTypeVO optional2 = staticDataController.GetOptional <SpecialAttackTypeVO>(rewardUid);
                if (optional2 != null)
                {
                    text = LangUtils.GetStarshipDisplayName(optional2);
                }
                break;
            }

            case SupplyType.ShardTroop:
            {
                ShardVO optional3 = staticDataController.GetOptional <ShardVO>(rewardUid);
                if (optional3 != null)
                {
                    text = LangUtils.GetTroopDisplayNameFromTroopID(optional3.TargetGroupId);
                }
                break;
            }

            case SupplyType.ShardSpecialAttack:
            {
                ShardVO optional4 = staticDataController.GetOptional <ShardVO>(rewardUid);
                if (optional4 != null)
                {
                    text = LangUtils.GetStarshipDisplayNameFromAttackID(optional4.TargetGroupId);
                }
                break;
            }
            }
            if (string.IsNullOrEmpty(text))
            {
                Service.Logger.ErrorFormat("CrateSupplyVO Uid:{0}, Cannot find reward for RewardUid:{1}, Type:{2}", new object[]
                {
                    supplyData.Uid,
                    rewardUid,
                    type
                });
            }
            return(text);
        }