public void PostInit() { SceneLoader instance = SceneLoader.Instance; PlayerData.Instance.MainChunk.Subscribe(delegate(int chunk) { RefreshDrJellyLevels(chunk); }).AddTo(instance); (from drActive in DrJellyBattle.CombineLatest(Singleton <BossBattleRunner> .Instance.BossBattleActive, (bool dr, bool active) => dr && active) where drActive select drActive).Do(delegate { Singleton <BossBattleRunner> .Instance.PauseBossBattle(); }).Delay(TimeSpan.FromSeconds(1.0)).Subscribe(delegate { Singleton <BossBattleRunner> .Instance.UnpauseBossBattle(); }) .AddTo(instance); (from battle in DrJellyBattle.Pairwise() where !battle.Current && battle.Previous select battle).Subscribe(delegate { DrJellyExitLevel.Value = DrJellyLevel.Value; }).AddTo(instance); }
public GearSetCollectionRunner() { Singleton <PropertyManager> .Instance.AddRootContext(this); SceneLoader instance = SceneLoader.Instance; for (int i = 0; i < 25; i++) { BonusMult[i] = CreateObservableForAll((BonusTypeEnum)i).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); } ReactiveProperty <int> mainChunk = PlayerData.Instance.LifetimeChunk; MaxSetsToShow = (from lvl in mainChunk select GetMaxSetsToShow(lvl)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); SetUnlocked = (from pair in MaxSetsToShow.Pairwise() where pair.Previous < pair.Current select pair into _ select GetUnlockedGears(mainChunk.Value)).Do(delegate { BindingManager.Instance.HeroLevelParent.ShowInfo(); }).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); NextSetUnlockAt = (from lvl in mainChunk select GetNextSetUnlockAt(lvl)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); AllSetsUnlocked = (from lvl in mainChunk select IsAllSetsUnlocked(lvl)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); AllAvailableGearsUnlocked = (from unlockAvailable in (from lvl in mainChunk select GetMaxSetsToShow(lvl)).CombineLatest(PlayerData.Instance.LifetimeGears, (int maxSets, int unlocks) => maxSets * 3 > unlocks) select !unlockAvailable).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); }
public WorldRunner() { Singleton <PropertyManager> .Instance.AddRootContext(this); SceneLoader instance = SceneLoader.Instance; BindingManager bind = BindingManager.Instance; CurrentChunk = PlayerData.Instance.MainChunk.CombineLatest(PlayerData.Instance.BonusChunk, (int main, int bonus) => (bonus <= -1) ? new ChunkStruct(main, bonus: false) : new ChunkStruct(bonus, bonus: true)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); MainBiomeConfig = (from chunk in PlayerData.Instance.MainChunk select Singleton <EconomyHelpers> .Instance.GetBiomeConfig(chunk)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); CurrentBiomeConfig = (from cs in CurrentChunk select Singleton <EconomyHelpers> .Instance.GetBiomeConfig(cs.Index)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); MainChunk = PlayerData.Instance.MainChunk; RelativeChunk = PlayerData.Instance.MainChunk; InBaseCamp = (from chunk in CurrentChunk select chunk.Index == 0).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); BiomeName = (from cnfg in CurrentBiomeConfig select PersistentSingleton <LocalizationService> .Instance.Text("Biome.Name." + cnfg.BiomeIndex)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); ProgressString = (from chunk in CurrentChunk where chunk.Index >= 0 select Mathf.FloorToInt(chunk.Index % 10 / 10) + 1 into curr select curr.ToString() + "/" + 1.ToString()).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); CurrentProgress = (from chunk in CurrentChunk select(float)((chunk.Index - CurrentBiomeConfig.Value.Chunk) % 10) + 1f).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); CurrentProgressInt = CurrentProgress.Select(Mathf.RoundToInt).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); (from seq in MapSequence.Pairwise() where !seq.Current && seq.Previous select seq).Delay(TimeSpan.FromSeconds(1.5)).Subscribe(delegate { bind.ChunkProgressNotification.SetActive(value: true); }).AddTo(instance); (from chunk in CurrentChunk.Pairwise() select chunk.Previous.Index < chunk.Current.Index into chunkChanged where chunkChanged select chunkChanged).Delay(TimeSpan.FromSeconds(3.0)).Subscribe(delegate { bind.ChunkProgressNotification.SetActive(value: true); }).AddTo(instance); (from chunk in CurrentChunk.Pairwise() select chunk.Previous.Index < chunk.Current.Index into progressed where progressed select progressed).Subscribe(delegate(bool progressed) { HaveProgressedInCurrentSession.SetValueAndForceNotify(progressed); }).AddTo(instance); }
public LevelSkipRunner() { Singleton <PropertyManager> .Instance.AddRootContext(this); SceneLoader instance = SceneLoader.Instance; FreeSkipAvailable = (from chunk in PlayerData.Instance.MainChunk.CombineLatest(PlayerData.Instance.LifetimeChunk, (int curr, int high) => new { curr, high }).Delay(TimeSpan.FromSeconds(1.5)) select chunk.curr < (int)(Mathf.Max(PersistentSingleton <GameSettings> .Instance.FreeSkipMinimum, (float)chunk.high * PersistentSingleton <GameSettings> .Instance.FreeLevelSkipPercent) * 0.5f)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); SmallSkipAvailable = (from small in PlayerData.Instance.LifetimePrestiges.CombineLatest(PlayerData.Instance.LevelSkipsBought[0], (int pres, int skips) => skips) select small < PersistentSingleton <GameSettings> .Instance.LevelSkipAmount).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); MediumSkipAvailable = (from medium in PlayerData.Instance.LifetimePrestiges.CombineLatest(PlayerData.Instance.LevelSkipsBought[1], (int pres, int skips) => skips) select medium < PersistentSingleton <GameSettings> .Instance.LevelSkipAmount).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); LargeSkipAvailable = (from large in PlayerData.Instance.LifetimePrestiges.CombineLatest(PlayerData.Instance.LevelSkipsBought[2], (int pres, int skips) => skips) select large < PersistentSingleton <GameSettings> .Instance.LevelSkipAmount).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); NoSkipsAvailable = (from avail in SmallSkipAvailable.CombineLatest(MediumSkipAvailable, LargeSkipAvailable, (bool small, bool medium, bool large) => !small && !medium && !large).Delay(TimeSpan.FromSeconds(1.5)) select(avail)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); FreeSkipToLevel = (from chunk in PlayerData.Instance.LifetimeChunk select PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevel", (int)Mathf.Max(PersistentSingleton <GameSettings> .Instance.FreeSkipMinimum, (float)chunk * PersistentSingleton <GameSettings> .Instance.FreeLevelSkipPercent))).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); FreeSkipCost.Value = PersistentSingleton <GameSettings> .Instance.FreeLevelSkipCost; SmallSkipToLevel = (from lvl in PlayerData.Instance.MainChunk select PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevel", lvl + PersistentSingleton <GameSettings> .Instance.SmallLevelSkipEffect)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); SmallSkipCost.Value = PersistentSingleton <GameSettings> .Instance.SmallLevelSkipCost; MediumSkipToLevel = (from lvl in PlayerData.Instance.MainChunk select PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevel", lvl + PersistentSingleton <GameSettings> .Instance.MediumLevelSkipEffect)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); MediumSkipCost.Value = PersistentSingleton <GameSettings> .Instance.MediumLevelSkipCost; LargeSkipToLevel = (from lvl in PlayerData.Instance.MainChunk select PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevel", lvl + PersistentSingleton <GameSettings> .Instance.LargeLevelSkipEffect)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); LargeSkipCost.Value = PersistentSingleton <GameSettings> .Instance.LargeLevelSkipCost; SkipToLevel = (from lvl in PlayerData.Instance.MainChunk select PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevel", lvl)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); MediumSkipUnlocked = (from lvl in PlayerData.Instance.LifetimeChunk select lvl >= PersistentSingleton <GameSettings> .Instance.MediumSkipUnlockLevel).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); MediumSkipUnlockLevel.Value = PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevel", PersistentSingleton <GameSettings> .Instance.MediumSkipUnlockLevel); LargeSkipUnlocked = (from lvl in PlayerData.Instance.LifetimeChunk select lvl >= PersistentSingleton <GameSettings> .Instance.LargeSkipUnlockLevel).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); LargeSkipUnlockLevel.Value = PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevel", PersistentSingleton <GameSettings> .Instance.LargeSkipUnlockLevel); PlayerData.Instance.LifetimePrestiges.Skip(1).Subscribe(delegate { for (int i = 0; i < 3; i++) { PlayerData.Instance.LevelSkipsBought[i].Value = 0; } }).AddTo(instance); LevelSkipUnlocked = PlayerData.Instance.LifetimePrestiges.CombineLatest(PlayerData.Instance.MainChunk, (int prest, int chunk) => prest > 1 || (prest == 1 && chunk >= 5)).ToReadOnlyReactiveProperty().AddTo(instance); (from unlocked in LevelSkipUnlocked.Pairwise() where !unlocked.Previous && unlocked.Current select unlocked).Subscribe(delegate { BindingManager.Instance.GoatUnlockedParent.ShowInfo(); }).AddTo(instance); }
public void PostInit() { SceneLoader instance = SceneLoader.Instance; (from pair in Gears.Pairwise() where pair.Current == 0 && pair.Previous > 0 select pair).Subscribe(delegate { PlayerData.Instance.GearChestsToCollect[1].Value++; AnimationTriggered.Value = true; }).AddTo(instance); }
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); } }
public TournamentRunner() { SceneLoader instance = SceneLoader.Instance; Singleton <PropertyManager> .Instance.AddRootContext(this); PFIDsUsed.Add("D1E872B9C9DA0648"); LoggedInPlayfab = (from id in PersistentSingleton <PlayFabService> .Instance.LoggedOnPlayerId.StartWith(string.Empty) select id != string.Empty).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); TimeTillTournament = TickerService.MasterTicksSlow.CombineLatest(ServerTimeService.IsSynced, (long tick, bool sync) => (!sync) ? (-1) : GetTimeTillTournament()).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); TimeTillTournamentClock = (from time in TimeTillTournament.DistinctUntilChanged() select(time <= 0) ? string.Empty : TextUtils.FormatSecondsShortWithDays(time)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); (from till in TimeTillTournament where till == 0 select till).Subscribe(delegate { ResetIfDifferentDevice(); }).AddTo(instance); TournamentAccessable = TimeTillTournament.CombineLatest(PlayerData.Instance.TournamentIdCurrent, TournamentFetched, ConnectivityService.InternetConnectionAvailable, (long time, int id, bool fetched, bool connected) => connected && time == 0 && id < 0 && fetched).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); CurrentlyInTournament = (from id in PlayerData.Instance.TournamentIdCurrent select id >= 0 && CheckIfSameDevice()).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); (from should in TournamentFetched.CombineLatest(TimeTillTournament, FetchAttempt, LoggedInPlayfab, (bool fetched, long till, int attempt, bool loggedIn) => !fetched && attempt == 0 && till == 0) where should select should).Subscribe(delegate { TryToFetchTournament(); }).AddTo(instance); (from timestamp in PlayerData.Instance.TournamentTimeStamp where timestamp + 10000000L * (long)PersistentSingleton <GameSettings> .Instance.TournamentDurationSeconds >= ServerTimeService.NowTicks() && ServerTimeService.NowTicks() >= timestamp && CheckIfSameDevice() select timestamp).Subscribe(delegate { TournamentRuns.SetValueAndForceNotify(LoadTournamentRuns()); TournamentActive.SetValueAndForceNotify(value: true); }).AddTo(instance); TimeTillTournamentEnd = (from should in TickerService.MasterTicks.CombineLatest(ServerTimeService.IsSynced, PlayerData.Instance.TournamentIdCurrent, (long tick, bool sync, int id) => sync && id >= 0 && CheckIfSameDevice()) where should select should into _ select GetTimeTillTournamentEnd()).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); TournamentEndClock = (from time in TimeTillTournamentEnd.DistinctUntilChanged() select(time <= 0) ? string.Empty : TextUtils.FormatSecondsShort(time)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); TournamentEnded = TimeTillTournamentEnd.CombineLatest(PlayerData.Instance.TournamentIdCurrent, (long time, int id) => time < 0 && id >= 0).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); (from ended in TournamentEnded where ended select ended).Subscribe(delegate { LoadTournamentEndedValues(); }).AddTo(instance); TournamentWorldReached = (from world in PlayerData.Instance.MainChunk select world >= 70).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); DisplayNameGiven = (from name in PlayerData.Instance.DisplayName select name != string.Empty).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); TournamentsUnlocked = PlayerData.Instance.LifetimePrestiges.CombineLatest(PlayerData.Instance.LifetimeChunk, (int prest, int chunk) => prest > 0 || chunk >= 45).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); (from unlocked in TournamentsUnlocked.Pairwise() where !unlocked.Previous && unlocked.Current select unlocked).Subscribe(delegate { BindingManager.Instance.TournamentUnlockedParent.ShowInfo(); }).AddTo(instance); PlayerData.Instance.Medals.Take(1).Subscribe(delegate { TryToBuyTrophy(showUnlocking: false); }).AddTo(instance); PlayerData.Instance.Trophies.Subscribe(delegate(int trophies) { CalculateTrophiesMultiplier(trophies); }).AddTo(instance); InternetConnectionAvailable = (from avail in ConnectivityService.InternetConnectionAvailable select(avail)).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); }