Beispiel #1
0
    private void GiveChunkReward(ChunkGeneratingConfig cnfg, bool boss)
    {
        BigDouble left = BigDouble.ZERO;

        if (boss)
        {
            int       value  = PlayerData.Instance.MainChunk.Value;
            BigDouble amount = Singleton <EconomyHelpers> .Instance.GetRelicsFromBoss(value) * PlayerData.Instance.BoostersEffect[2].Value;

            Singleton <FundRunner> .Instance.AddRelicsToBackpak(amount);

            bool        flag   = ChunkRunner.IsLastChunkForNode(value);
            BiomeConfig value2 = Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value;
            left  = ((!flag) ? value2.MiniBossReward : value2.BossReward);
            left *= Singleton <CumulativeBonusRunner> .Instance.BonusMult[2].Value;
        }
        int[] array = new int[7];
        int   num   = 0;

        if (Random.Range(0f, 1f) < cnfg.TNTChance)
        {
            num = Random.Range(cnfg.TNTMin, cnfg.TNTMax + 1) * 8;
        }
        int num2 = 0;

        if (Random.Range(0f, 1f) < cnfg.DiamondChance)
        {
            num2 = Random.Range(cnfg.DiamondMin, cnfg.DiamondMax);
        }
        Singleton <FundRunner> .Instance.AddGems(num2 *PersistentSingleton <GameSettings> .Instance.GemBlockReward, "debugMenu", "debug");

        for (int i = 0; i < cnfg.MaxBlocks - num2 - num - cnfg.GoldBlockAverage; i++)
        {
            array[(int)cnfg.Materials.AllotObject()]++;
        }
        for (int j = 0; j < array.Length; j++)
        {
            PlayerData.Instance.BlocksInBackpack[j].Value += array[j];
        }
        left += cnfg.MaxBlocks * Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value.BlockReward * Singleton <CumulativeBonusRunner> .Instance.BonusMult[1].Value * PlayerData.Instance.BoostersEffect[1].Value;
        Singleton <FundRunner> .Instance.AddCoins(left);
    }
Beispiel #2
0
    public void PostInit()
    {
        SceneLoader instance = SceneLoader.Instance;

        (from success in Singleton <BossBattleRunner> .Instance.BossSuccessNotification
         where success
         select success into _
         select Singleton <BossIndexRunner> .Instance.CurrentBossIndex.Value).Subscribe(delegate(int bossIndex)
        {
            StartRewardSequence(bossIndex);
        }).AddTo(instance);
        m_coinReward = (from chunk in Singleton <WorldRunner> .Instance.CurrentChunk
                        select ChunkRunner.IsLastChunkForNode(chunk.Index)).Select(delegate(bool last)
        {
            BiomeConfig value = Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value;
            return((!last) ? value.MiniBossReward : value.BossReward);
        }).CombineLatest(Singleton <CumulativeBonusRunner> .Instance.BonusMult[2], (BigDouble coins, BigDouble mult) => coins * mult).CombineLatest(Singleton <DrJellyRunner> .Instance.DrJellyBattle, (BigDouble coins, bool dr) => (!dr) ? coins : (coins * PersistentSingleton <GameSettings> .Instance.DrJellyRewardMult))
                       .TakeUntilDestroy(instance)
                       .ToReadOnlyReactiveProperty();
        m_relicReward = (from reward in (from chunk in Singleton <WorldRunner> .Instance.CurrentChunk
                                         select Singleton <EconomyHelpers> .Instance.GetRelicsFromBoss(chunk.Index)).CombineLatest(PlayerData.Instance.BoostersEffect[2], (BigDouble relic, float mult) => relic * mult).CombineLatest(Singleton <DrJellyRunner> .Instance.DrJellyBattle, (BigDouble relics, bool dr) => (!dr) ? relics : (relics * PersistentSingleton <GameSettings> .Instance.DrJellyRewardMult))
                         select new BigDouble(reward.ToLong())).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
    }
Beispiel #3
0
    public BossBattleRunner()
    {
        Singleton <PropertyManager> .Instance.AddRootContext(this);

        SceneLoader instance = SceneLoader.Instance;

        BossMaxDuration = (from duration in Singleton <CumulativeBonusRunner> .Instance.BonusMult[7]
                           select PersistentSingleton <GameSettings> .Instance.BossDurationSeconds + duration.ToInt()).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        UniRx.IObservable <long> left2 = (from dead in (from health in BossCurrentHP
                                                        select health <= BigDouble.ZERO).DistinctUntilChanged()
                                          select(!dead) ? TickerService.MasterTicks : Observable.Never <long>()).Switch();
        (from tuple in left2.CombineLatest(BossBattlePaused, (long ticks, bool paused) => new
        {
            ticks,
            paused
        })
         where !tuple.paused
         select tuple).Subscribe(tuple =>
        {
            if (ElapsedTime.Value < 864000000000L)
            {
                ElapsedTime.Value += tuple.ticks;
            }
        }).AddTo(instance);
        BattleSecondsLeft = (from left in ElapsedTime.CombineLatest(BossMaxDuration, (long elapsed, int dur) => dur - (int)(elapsed / 10000000))
                             select Mathf.Max(0, left)).TakeUntilDestroy(instance).ToReactiveProperty();
        BattleSecondsLeftNormalized = (from secs in BattleSecondsLeft
                                       select(float) secs / (float)BossMaxDuration.Value).ToReadOnlyReactiveProperty();
        UniRx.IObservable <bool> source = from secs in BattleSecondsLeft.Skip(1)
                                          select secs <= 0 into ranOut
                                          where ranOut
                                          select ranOut;

        UniRx.IObservable <bool> observable = from killed in (from health in BossCurrentHP
                                                              select health <= BigDouble.ZERO).DistinctUntilChanged()
                                              where killed
                                              select killed;

        observable.Subscribe(delegate
        {
            PlayerData.Instance.BossFailedLastTime.Value = false;
            PersistentSingleton <MainSaver> .Instance.PleaseSave("boss_killed_chunk_" + Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index + "_prestige_" + PlayerData.Instance.LifetimePrestiges.Value);
        }).AddTo(instance);
        (from order in Singleton <PrestigeRunner> .Instance.PrestigeTriggered
         select order == PrestigeOrder.PrestigeStart).Subscribe(delegate
        {
            if (BossBattleActive.Value)
            {
                ElapsedTime.Value = 85536000000000L;
            }
            PlayerData.Instance.BossFailedLastTime.Value = false;
        }).AddTo(instance);
        (from seq in Singleton <WorldRunner> .Instance.MapSequence
         where seq
         select seq).Subscribe(delegate
        {
            PlayerData.Instance.BossFailedLastTime.Value = false;
        }).AddTo(instance);
        UniRx.IObservable <bool> observable2 = (from pair in Singleton <ChunkRunner> .Instance.AllBlockAmount.Pairwise()
                                                select pair.Current == 1 && pair.Previous > 1).CombineLatest(Singleton <ChunkRunner> .Instance.BossBlock, (bool cleared, BossBlockController boss) => cleared && boss != null).StartWith(value: false);
        (from activated in observable2
         where activated
         select activated).Subscribe(delegate
        {
            StartCountdown();
        }).AddTo(instance);
        BossBattleActive = (from secs in BattleSecondsLeft
                            select secs > 0).CombineLatest(observable2, (bool time, bool block) => time && block).DistinctUntilChanged().TakeUntilDestroy(instance)
                           .ToReadOnlyReactiveProperty();
        BossLevelActive = (from boss in Singleton <ChunkRunner> .Instance.BossBlock
                           select boss != null).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        (from pair in BossLevelActive.Pairwise()
         select pair.Current&& !pair.Previous into start
         where start
         select start).Subscribe(delegate
        {
            StartBossLevel();
        }).AddTo(instance);
        BossPreludeActive       = BossLevelActive.CombineLatest(Singleton <ChunkRunner> .Instance.AllBlockAmount, (bool level, int blocks) => level && blocks > 1).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BossFailedActive        = BossLevelActive.CombineLatest(BossPreludeActive, BossBattleActive, (bool level, bool prelude, bool battle) => level && !prelude && !battle).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        TryBossAvailable        = PlayerData.Instance.BossFailedLastTime.CombineLatest(BossLevelActive, (bool failed, bool active) => failed && !active).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BossBattlePending       = TryBossAvailable.CombineLatest(BossLevelActive, (bool avail, bool level) => avail || level).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BossSuccessNotification = (from _ in observable
                                   select Observable.Merge(new UniRx.IObservable <bool>[2]
        {
            Observable.Return <bool>(value: true),
            Observable.Return <bool>(value: false).Delay(TimeSpan.FromSeconds(10.0))
        })).Switch().TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BossFailedNotification = (from _ in source
                                  select Observable.Merge(new UniRx.IObservable <bool>[2]
        {
            Observable.Return <bool>(value: true),
            Observable.Return <bool>(value: false).Delay(TimeSpan.FromSeconds(10.0))
        })).Switch().TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        BossBattleResult = (from _ in source
                            select false).Merge(observable).StartWith(value: false).ToSequentialReadOnlyReactiveProperty();
        BossFullHP = (from chunk in Singleton <WorldRunner> .Instance.CurrentChunk
                      select ChunkRunner.IsLastChunkForNode(chunk.Index)).Select(delegate(bool last)
        {
            BiomeConfig value = Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value;
            return((!last) ? value.MiniBossHP : value.BossHP);
        }).CombineLatest(Singleton <DrJellyRunner> .Instance.DrJellyBattle, (BigDouble hp, bool dr) => (!dr) ? hp : (hp * PersistentSingleton <GameSettings> .Instance.DrJellyHpMult)).TakeUntilDestroy(instance)
                     .ToReadOnlyReactiveProperty();
        BossHealthNormalized = (from hp in BossFullHP
                                select(!(hp > new BigDouble(1.0))) ? new BigDouble(1.0) : hp).CombineLatest(BossCurrentHP, (BigDouble full, BigDouble current) => (current / full).ToFloat()).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty();
        (from result in BossBattleResult.Skip(1)
         where !result
         select result).Subscribe(delegate
        {
            AudioController.Instance.QueueEvent(new AudioEvent("BossSequenceFailed", AUDIOEVENTACTION.Play));
        }).AddTo(instance);
        (from result in BossBattleResult.Skip(1)
         where result
         select result).Subscribe(delegate
        {
            PlayerData.Instance.RetryLevelNumber.Value = 0;
        }).AddTo(instance);
        if (PersistentSingleton <GameAnalytics> .Instance != null)
        {
            BossBattleResult.Subscribe(delegate(bool result)
            {
                PersistentSingleton <GameAnalytics> .Instance.BossBattleResult.Value = result;
            }).AddTo(instance);
        }
    }