Example #1
0
    public BoosterRunner(int booster)
    {
        SceneLoader instance = SceneLoader.Instance;

        BoosterIndex    = booster;
        m_boosterConfig = PersistentSingleton <Economies> .Instance.Boosters[BoosterIndex];
        if (BoosterIndex == 0)
        {
            m_maxBoosterAmount = PersistentSingleton <GameSettings> .Instance.MaxDamageBoosterPurchaseAmount;
        }
        else
        {
            m_maxBoosterAmount = PersistentSingleton <GameSettings> .Instance.MaxBoosterPurchaseAmount;
        }
        BoosterMaxReached = (from currentAmount in PlayerData.Instance.BoostersBought[BoosterIndex]
                             select currentAmount >= m_maxBoosterAmount).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BoosterCost = (from amount in PlayerData.Instance.BoostersBought[BoosterIndex]
                       select Singleton <EconomyHelpers> .Instance.GetBoosterCost(BoosterIndex, amount)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BoosterAvailable  = BoosterCost.CombineLatest(PlayerData.Instance.Gems, (int cost, int gems) => cost <= gems).TakeUntilDestroy(instance).ToSequentialReadOnlyReactiveProperty();
        BoosterName.Value = PersistentSingleton <LocalizationService> .Instance.Text("GemBooster.Title." + (BoosterEnum)BoosterIndex);

        BoosterDescription.Value = PersistentSingleton <LocalizationService> .Instance.Text("GemBooster.Desc." + (BoosterEnum)BoosterIndex);

        BoosterBonus = (from _ in PlayerData.Instance.BoostersEffect[BoosterIndex]
                        select BoosterCollectionRunner.GetBoosterBonusString((BoosterEnum)BoosterIndex)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BoosterNextUpgrade = (from _ in BoosterCost
                              select BoosterCollectionRunner.GetBoosterNextUpgradeString((BoosterEnum)BoosterIndex)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        ActiveBooster = (from active in Singleton <BoosterCollectionRunner> .Instance.ActiveBooster
                         select active == BoosterIndex).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
    }
Example #2
0
    public HammerTimeRunner()
    {
        Singleton <PropertyManager> .Instance.AddRootContext(this);

        SceneLoader            instance         = SceneLoader.Instance;
        ReactiveProperty <int> reactiveProperty = (from dur in PlayerData.Instance.BoostersEffect[5]
                                                   select(int) dur + PersistentSingleton <GameSettings> .Instance.GoldenHammerInitialDuration).TakeUntilDestroy(instance).ToReactiveProperty();
        ReactiveProperty <int> right = reactiveProperty.CombineLatest(PlayerData.Instance.HammerTimeBonusDuration, (int dura, int bonus) => dura + bonus).TakeUntilDestroy(instance).ToReactiveProperty();

        TickerService.MasterTicks.Subscribe(delegate(long ticks)
        {
            if (PlayerData.Instance.HammerTimeElapsedTime.Value < 1728000000000L)
            {
                PlayerData.Instance.HammerTimeElapsedTime.Value += ticks;
            }
        }).AddTo(instance);
        UniRx.IObservable <int> source = PlayerData.Instance.HammerTimeElapsedTime.CombineLatest(right, (long ticks, int dur) => dur - (int)(ticks / 10000000));
        Active = (from secs in source
                  select secs > 0).TakeUntilDestroy(instance).ToReactiveProperty();
        DurationLeft = (from seconds in source
                        select TextUtils.FormatSecondsShort(seconds)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        DurationString = (from dur in reactiveProperty
                          select PersistentSingleton <LocalizationService> .Instance.Text("Attribute.Duration") + ": " + BoosterCollectionRunner.FormatSecondsForBoosters(dur)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        HammerTimeEnded = (from act in Active
                           select act && (HammerTimeActive = true) into sit
                           select(!sit && HammerTimeActive) ? true : false).TakeUntilDestroy(instance).ToReactiveProperty();
        (from elapsed in PlayerData.Instance.HammerTimeElapsedTime
         where elapsed < 0
         select elapsed).CombineLatest(right, (long cheat, int dur) => dur).Subscribe(delegate(int dur)
        {
            PlayerData.Instance.HammerTimeElapsedTime.Value = dur;
        }).AddTo(instance);
    }
Example #3
0
    public void PostInit()
    {
        SceneLoader instance = SceneLoader.Instance;

        if (PlayerData.Instance.WelcomebackTimeStamp.Value == 0)
        {
            PlayerData.Instance.WelcomebackTimeStamp.Value = ServerTimeService.NowTicks();
        }
        UniRx.IObservable <bool> source = from p in Observable.EveryApplicationPause().StartWith(value: false)
                                          select(p);
        (from _ in (from pause in source
                    where !pause
                    select pause into _
                    select(from sync in ServerTimeService.IsSynced
                           where sync
                           select sync).Take(1)).Switch()
         select new TimeSpan(ServerTimeService.NowTicks() - PlayerData.Instance.WelcomebackTimeStamp.Value).TotalSeconds into awaySecs
         where awaySecs >= 90.0 && PlayerData.Instance.TutorialStep.Value >= m_stepIndex
         select awaySecs into _
         select ServerTimeService.NowTicks() - PlayerData.Instance.WelcomebackTimeStamp.Value into deltaTicks
         select GetWelcomeBackCoins(deltaTicks)).Subscribe(delegate(BigDouble coins)
        {
            PlayerData.Instance.WelcomebackTimeStamp.Value = ServerTimeService.NowTicks();
            PlayerData.Instance.WelcomebackCoins.Value    += coins;
        }).AddTo(instance);
        (from _ in PersistentSingleton <MainSaver> .Instance.Saving
         select(from sync in ServerTimeService.IsSynced
                where sync
                select sync).Take(1)).Switch().Subscribe(delegate
        {
            PlayerData.Instance.WelcomebackTimeStamp.Value = ServerTimeService.NowTicks();
        }).AddTo(instance);
        (from prestige in Singleton <PrestigeRunner> .Instance.PrestigeTriggered
         where prestige == PrestigeOrder.PrestigeInit
         select prestige).Subscribe(delegate
        {
            PlayerData.Instance.WelcomebackCoins.Value = 0L;
        }).AddTo(instance);
        DoubleAdTime = (from _ in TickerService.MasterTicksSlow
                        select(float) Singleton <AdRunner> .Instance.GetNextTimeToShowAd(AdPlacement.DailyDouble).TotalSeconds into secsLeft
                        select(int) Mathf.Max(0f, secsLeft)).DistinctUntilChanged().TakeUntilDestroy(instance).ToReactiveProperty();
        DoubleAdAvailable = (from time in DoubleAdTime
                             select time <= 0).CombineLatest(Singleton <AdRunner> .Instance.AdReady, (bool time, bool ad) => time && ad).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        DoubleAdTimeLeft = DoubleAdTime.Select(delegate(int seconds)
        {
            string empty = string.Empty;
            return((seconds > 0) ? TextUtils.FormatSecondsShort(seconds) : PersistentSingleton <LocalizationService> .Instance.Text("AD.Placement.NotAvailable"));
        }).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        (from ad in Singleton <AdRunner> .Instance.AdPlacementFinished
         where ad == AdPlacement.DailyDouble
         select ad).Subscribe(delegate
        {
            DailyDoubleAdFinished();
        }).AddTo(instance);
        (from ad in Singleton <AdRunner> .Instance.AdPlacementSkipped
         where ad == AdPlacement.DailyDouble
         select ad).Subscribe(delegate
        {
            DailyDoubleAdSkipped();
        }).AddTo(instance);
        (from ad in Singleton <AdRunner> .Instance.AdPlacementFailed
         where ad == AdPlacement.DailyDouble
         select ad).Subscribe(delegate
        {
            DailyDoubleAdSkipped();
        }).AddTo(instance);
        WelcomeBackMultiplier = (from _ in PlayerData.Instance.BoostersEffect[3].AsObservable()
                                 select BoosterCollectionRunner.GetBoosterBonusString(BoosterEnum.DailyDoubleBoost)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
    }
Example #4
0
    public override void FillBaseData(JSONObject json, BaseData baseData)
    {
        base.FillBaseData(json, baseData);
        PlayerData playerData = (PlayerData)baseData;

        playerData.Coins.Value             = json.asBigDouble("Coins", () => 0L);
        playerData.WelcomebackCoins.Value  = json.asBigDouble("WelcomebackCoins", () => 0L);
        playerData.LifetimeCoins.Value     = json.asBigDouble("LifetimeCoins", () => 0L);
        playerData.LifetimeRelics.Value    = json.asLong("LifetimeRelics", () => 0L);
        playerData.LifetimeBerries.Value   = json.asLong("LifetimeBerries", () => 0L);
        playerData.LifetimePrestiges.Value = json.asInt("LifetimePrestiges", () => 0);
        playerData.RetryLevelNumber.Value  = json.asInt("RetryLevelNumber", () => 0);
        playerData.Gems.Value              = json.asInt("Gems", () => 100);
        playerData.LifetimeGems.Value      = json.asInt("LifetimeGems", () => 100);
        playerData.Keys.Value              = json.asInt("Keys", () => 0);
        playerData.LifetimeKeys.Value      = json.asInt("LifetimeKeys", () => 0);
        playerData.Medals.Value            = json.asInt("Medals", () => 0);
        playerData.LifetimeMedals.Value    = json.asInt("LifetimeMedals", () => 0);
        playerData.Trophies.Value          = json.asInt("Trophies", () => 0);
        playerData.LifetimeGamblings.Value = json.asInt("LifetimeGamblings", () => 0);
        playerData.BoostersBought          = new List <ReactiveProperty <int> >();
        playerData.BoostersEffect          = new List <ReactiveProperty <float> >();
        for (int i = 0; i < 7; i++)
        {
            ReactiveProperty <int> reactiveProperty = new ReactiveProperty <int>();
            reactiveProperty.Value = json.asInt("BoostersBought_" + (BoosterEnum)i, () => 0);
            playerData.BoostersBought.Add(reactiveProperty);
            ReactiveProperty <float> reactiveProperty2 = new ReactiveProperty <float>();
            if (BoosterCollectionRunner.IsBoosterMultiplier((BoosterEnum)i))
            {
                if (i == 3)
                {
                    reactiveProperty2.Value = json.asFloat("BoostersEffect_" + (BoosterEnum)i, () => 2f);
                }
                else
                {
                    reactiveProperty2.Value = json.asFloat("BoostersEffect_" + (BoosterEnum)i, () => 1f);
                }
            }
            else
            {
                reactiveProperty2.Value = json.asFloat("BoostersEffect_" + (BoosterEnum)i, () => 0f);
            }
            playerData.BoostersEffect.Add(reactiveProperty2);
        }
        playerData.HammerTimeElapsedTime.Value   = json.asLong("HammerTimeElapsedTime", () => 85536000000000L);
        playerData.HammerTimeBonusDuration.Value = json.asInt("HammerTimeBonusDuration", () => 0);
        playerData.CurrentBundleEnum.Value       = json.asInt("CurrentBundleEnum", () => int.MinValue);
        playerData.CurrentBundleGearIndex.Value  = json.asInt("CurrentBundleGearIndex", () => 0);
        playerData.BundleTimeStamp.Value         = json.asLong("BundleTimeStamp", () => 0L);
        playerData.LifetimeBundles.Value         = json.asInt("LifetimeBundles", () => 0);
        playerData.LifetimeBlocksTaps.Value      = json.asLong("LifetimeBlocksTaps", () => 0L);
        playerData.LifetimeCreatures.Value       = json.asInt("LifetimeCreatures", () => 0);
        playerData.LifetimeGears.Value           = json.asInt("LifetimeGears", () => 0);
        playerData.LifetimeGearLevels.Value      = json.asInt("LifetimeGearLevels", () => 0);
        playerData.LifetimeBlocksDestroyed       = new List <ReactiveProperty <long> >();
        playerData.BlocksInBackpack = new List <ReactiveProperty <long> >();
        playerData.BlocksCollected  = new List <ReactiveProperty <long> >();
        for (int j = 0; j < 7; j++)
        {
            ReactiveProperty <long> reactiveProperty3 = new ReactiveProperty <long>();
            reactiveProperty3.Value = json.asLong("LifetimeBlocksDestroyed_" + (BlockType)j, () => 0L);
            playerData.LifetimeBlocksDestroyed.Add(reactiveProperty3);
            ReactiveProperty <long> reactiveProperty4 = new ReactiveProperty <long>();
            reactiveProperty4.Value = json.asLong("BlocksInBackpack_" + (BlockType)j, () => 0L);
            playerData.BlocksInBackpack.Add(reactiveProperty4);
            ReactiveProperty <long> reactiveProperty5 = new ReactiveProperty <long>();
            reactiveProperty5.Value = json.asLong("BlocksCollected_" + (BlockType)j, () => 0L);
            playerData.BlocksCollected.Add(reactiveProperty5);
        }
        playerData.GearChestsToCollect = new List <ReactiveProperty <int> >();
        for (int k = 0; k < 4; k++)
        {
            ReactiveProperty <int> reactiveProperty6 = new ReactiveProperty <int>();
            reactiveProperty6.Value = json.asInt("GearChestsToCollect_" + (ChestEnum)k, () => 0);
            playerData.GearChestsToCollect.Add(reactiveProperty6);
        }
        playerData.NormalChests.Value            = json.asInt("NormalChests", () => 0);
        playerData.SilverChests.Value            = json.asInt("SilverChests", () => 0);
        playerData.GoldChests.Value              = json.asInt("GoldChests", () => 0);
        playerData.LifetimeAllOpenedChests.Value = json.asInt("LifetimeAllOpenedChests", () => 0);
        playerData.PlayerGoalsSeen      = json.asCustom("PlayerGoalsSeen", (JSONObject jobj) => new ReactiveCollection <string>(DataHelper.JSONToStringList(jobj)), () => new ReactiveCollection <string>());
        playerData.TutorialStep.Value   = json.asInt("TutorialStep", () => 0);
        playerData.ARTutorialStep.Value = json.asInt("ARTutorialStep", () => 0);
        playerData.MainChunk.Value      = json.asInt("MainChunk", () => 0);
        playerData.BonusChunk.Value     = json.asInt("BonusChunk", () => - 1);
        playerData.LifetimeChunk.Value  = json.asInt("LifetimeChunk", () => 0);
        playerData.BiomeStarted.Value   = json.asBool("BiomeStarted", () => true);
        playerData.LevelSkipsBought     = new List <ReactiveProperty <int> >();
        for (int l = 0; l < 3; l++)
        {
            ReactiveProperty <int> reactiveProperty7 = new ReactiveProperty <int>();
            reactiveProperty7.Value = json.asInt("LevelSkipsBought_" + (LevelSkipEnum)l, () => 0);
            playerData.LevelSkipsBought.Add(reactiveProperty7);
        }
        playerData.GamblingTimeStamp.Value = json.asLong("GamblingTimeStamp", () => 0L);
        playerData.Gambling.Value          = json.asCustom("Gambling", DataHelper.JSONToGamlingState, () => new GamblingState());
        playerData.SkillStates             = json.asCustom("SkillStates", (JSONObject jobj) => DataHelper.JSONToList(jobj, DataHelper.JSONToSkillState), () => new List <SkillState>());
        playerData.HeroStates                      = json.asCustom("HeroStates", (JSONObject jobj) => DataHelper.JSONToList(jobj, DataHelper.JSONToHeroState), () => new List <HeroState>());
        playerData.GearStates                      = json.asCustom("GearStates", (JSONObject jobj) => DataHelper.JSONToList(jobj, DataHelper.JSONToGearState), () => new List <GearState>());
        playerData.PlayerGoalStates                = json.asCustom("PlayerGoalStates", (JSONObject jobj) => DataHelper.JSONToList(jobj, DataHelper.JSONToPlayerGoalState), () => new List <PlayerGoalState>());
        playerData.BossFailedLastTime.Value        = json.asBool("BossFailedLastTime", () => false);
        playerData.WelcomebackTimeStamp.Value      = json.asLong("WelcomebackTimeStamp", () => 0L);
        playerData.DrillTimeStamp.Value            = json.asLong("DrillTimeStamp", () => 0L);
        playerData.DrillLevel.Value                = json.asInt("DrillLevel", () => 0);
        playerData.DrJellyLevel.Value              = json.asInt("DrJellyLevel", () => - 1);
        playerData.DrJellySpawningLevel.Value      = json.asInt("DrJellySpawningLevel", () => - 1);
        playerData.TournamentTimeStamp.Value       = json.asLong("TournamentTimeStamp", () => 0L);
        playerData.TournamentIdCurrent.Value       = json.asInt("TournamentIdCurrent", () => - 1);
        playerData.TournamentLastPointOnline.Value = json.asLong("TournamentLastPointOnline", () => 0L);
        playerData.TournamentRun.Value             = DataHelper.ConvertStringToInt16Array(json.asString("TournamentRun", () => DataHelper.ConvertInt16ArrayToString(new short[90])));
        playerData.TournamentEnteringDevice.Value  = json.asString("TournamentEnteringDevice", () => string.Empty);
        playerData.DisplayName.Value               = json.asString("DisplayName", () => string.Empty);
        playerData.AREditorChosen.Value            = json.asBool("AREditorChosen", () => false);
        playerData.AndroidEarlyAccess.Value        = json.asBool("AndroidEarlyAccess", () => false);
    }
Example #5
0
    public string[] GetRewardStringAndPrefabPath(RewardData reward, bool mainType)
    {
        string str = string.Empty;

        if (mainType)
        {
            str = "Main_";
        }
        string str2 = string.Empty;
        string str3 = "+";

        str3 = ((reward.Type != RewardEnum.AddToGems) ? (str3 + BigString.ToString(reward.Amount)) : (str3 + reward.Amount.ToInt().ToString()));
        switch (reward.Type)
        {
        case RewardEnum.AddBoosterDailyDoubleBoost:
            str2  = "Booster_DailyDouble";
            str3 += "X";
            break;

        case RewardEnum.AddBoosterDamageMultiplier:
            str2  = "Booster_Damage";
            str3 += "X";
            break;

        case RewardEnum.AddBoosterGoldMultiplier:
            str2  = "Booster_Gold";
            str3 += "X";
            break;

        case RewardEnum.AddBoosterHammerDuration:
            str2 = "Booster_Hammer";
            str3 = BoosterCollectionRunner.FormatSecondsForBoosters(reward.Amount.ToInt());
            break;

        case RewardEnum.AddBoosterKeyDropChance:
            str2  = "Booster_KeyChance";
            str3 += "X";
            break;

        case RewardEnum.AddBoosterShardMultiplier:
            str2  = "Booster_ShardMultiplier";
            str3 += "X";
            break;

        case RewardEnum.AddBoosterBerryDropChance:
            str2  = "Booster_BerryChance";
            str3 += "X";
            break;

        case RewardEnum.AddChestBronze:
            str2 = "Chest_Bronze";
            break;

        case RewardEnum.AddChestGold:
            str2 = "Chest_Gold";
            break;

        case RewardEnum.AddChestSilver:
            str2 = "Chest_Silver";
            break;

        case RewardEnum.AddToCoins:
        case RewardEnum.AddToCoinsSmall:
        case RewardEnum.AddToCoinsMedium:
        case RewardEnum.AddToCoinsLarge:
            str2 = "Coins";
            break;

        case RewardEnum.MultiplyCoins:
            str2  = "Coins";
            str3 += "X";
            break;

        case RewardEnum.AddToGems:
            str2 = "Gems";
            break;

        case RewardEnum.AddToRelics:
            str2 = "Jelly";
            break;

        case RewardEnum.AddToSkillAutoMine:
            str2 = "Tornado";
            break;

        case RewardEnum.AddToSkillGoldfinger:
            str2 = "Goldfinger";
            break;

        case RewardEnum.AddToSkillTapBoost:
            str2 = "Dynamite";
            break;

        case RewardEnum.AddToSkillTeamBoost:
            str2 = "EnchantedCreatures";
            break;

        case RewardEnum.AddToSkillTNT:
            str2 = "TNT";
            break;

        case RewardEnum.AddToSkillRandomUnlocked:
            str2 = "Skill";
            break;

        case RewardEnum.AddToGearLevel:
            str2 = "Gear";
            break;
        }
        return(new string[2]
        {
            str3,
            "UI/BundleItems/" + str + "BundleItem_" + str2
        });
    }