public override void UpdateUI(Object value) { GearConfig config = value as GearConfig; if (config != null) { isEventFake = true; ToggleButton.IsChecked = config.Enabled; isEventFake = false; } }
public GearRunner(int gearIndex) { SceneLoader instance = SceneLoader.Instance; GearIndex = gearIndex; Config = PersistentSingleton <Economies> .Instance.Gears[gearIndex]; GearState orCreateGearState = GearStateFactory.GetOrCreateGearState(gearIndex); Level = orCreateGearState.Level; Level.Skip(1).Subscribe(delegate { if (PersistentSingleton <GameAnalytics> .Instance != null) { PersistentSingleton <GameAnalytics> .Instance.GearUpgraded.Value = this; } }).AddTo(instance); SalvageRelicAmount = (from lvl in Level select GetSalvageAmount(GearIndex, lvl)).TakeUntilDestroy(instance).ToReactiveProperty(); SalvageGemCost = SalvageRelicAmount.Select(SalvageRelicsToGems.Evaluate).ToReactiveProperty(); Unlocked = (from lvl in Level select lvl >= 1).TakeUntilDestroy(instance).ToReactiveProperty(); (from pair in Unlocked.Pairwise() where pair.Current && !pair.Previous select pair).Subscribe(delegate { PlayerData.Instance.LifetimeGears.Value++; }).AddTo(instance); SalvageAvailable = PlayerData.Instance.Gems.CombineLatest(SalvageGemCost, (int gems, int cost) => gems >= cost).TakeUntilDestroy(instance).ToReactiveProperty(); UpgradeRequirement = (from lvl in Level select Singleton <EconomyHelpers> .Instance.GetGearUpgradeCost(GearIndex, lvl)).TakeUntilDestroy(instance).ToReactiveProperty(); MaxLevelReached = (from level in Level select level >= Config.MaxLevel).TakeUntilDestroy(instance).ToReactiveProperty(); UniRx.IObservable <CraftingRequirement> left = GearCollectionRunner.CreateBlocksObservable(); UpgradeAvailable = left.CombineLatest(UpgradeRequirement, (CraftingRequirement have, CraftingRequirement req) => have.Satisfies(req)).CombineLatest(MaxLevelReached, (bool sat, bool max) => sat && !max).TakeUntilDestroy(instance) .ToReactiveProperty(); UpgradeGemCost = left.CombineLatest(UpgradeRequirement, (CraftingRequirement have, CraftingRequirement req) => Singleton <EconomyHelpers> .Instance.GetCraftingGemCost(have, req)).TakeUntilDestroy(instance).ToReactiveProperty(); UpgradeAvailableWithGems = (from comb in UpgradeGemCost.CombineLatest(PlayerData.Instance.Gems, (int cost, int gems) => new { cost, gems }) select(comb.cost <= comb.gems) ? true : false).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); UniRx.IObservable <CraftingRequirement> left2 = GearCollectionRunner.CreateAfterPrestigeBlocksObservable(); UpgradeAfterPrestigeAvailable = left2.CombineLatest(UpgradeRequirement, (CraftingRequirement have, CraftingRequirement req) => have.Satisfies(req)).CombineLatest(MaxLevelReached, (bool sat, bool max) => sat && !max).TakeUntilDestroy(instance) .ToReactiveProperty(); Boost1Amount = Observable.Return(Config.Boost1.Mult.Amount).CombineLatest(CreateGearBonusObservable(Config.Boost1.Mult.BonusType, Config.Boost1.LevelUpAmount), (float sum, Func <float, float> f) => f(sum)).TakeUntilDestroy(instance) .ToReactiveProperty(); Boost2Amount = Observable.Return(Config.Boost2.Mult.Amount).CombineLatest(CreateGearBonusObservable(Config.Boost2.Mult.BonusType, Config.Boost2.LevelUpAmount), (float sum, Func <float, float> f) => f(sum)).TakeUntilDestroy(instance) .ToReactiveProperty(); }
public GearViewRunner(int gearIndex) { SceneLoader instance = SceneLoader.Instance; GearConfig config = PersistentSingleton <Economies> .Instance.Gears[gearIndex]; LocalizedName = new ReactiveProperty <string>(PersistentSingleton <LocalizationService> .Instance.Text("Gear.Name." + gearIndex)); LocalizedDesc = new ReactiveProperty <string>(PersistentSingleton <LocalizationService> .Instance.Text("Gear.Name.Desc." + gearIndex)); GearRunner gearRunner = Singleton <GearCollectionRunner> .Instance.GetOrCreateGearRunner(gearIndex); int chunkUnlockLevel = PersistentSingleton <Economies> .Instance.GearSets[gearRunner.SetIndex].ChunkUnlockLevel; LocalizedChunkLevelRequirement = new ReactiveProperty <string>(PersistentSingleton <LocalizationService> .Instance.Text("Prestige.ChunkLevelRequirement", chunkUnlockLevel)); Boost1Text = (from amount in gearRunner.Boost1Amount select(gearRunner.Level.Value <= 0) ? config.Boost1.Mult.Amount : amount into amount select BonusTypeHelper.GetAttributeText(config.Boost1.Mult.BonusType, amount)).TakeUntilDestroy(instance).ToReactiveProperty(); Boost2Text = (from amount in gearRunner.Boost2Amount select(gearRunner.Level.Value <= 0) ? config.Boost2.Mult.Amount : amount into amount select BonusTypeHelper.GetAttributeText(config.Boost2.Mult.BonusType, amount)).TakeUntilDestroy(instance).ToReactiveProperty(); Show = (from show in Singleton <GearSetCollectionRunner> .Instance.MaxSetsToShow select show > gearRunner.SetIndex).TakeUntilDestroy(instance).ToReactiveProperty(); ShowPrestige = Show.CombineLatest(gearRunner.UpgradeAfterPrestigeAvailable, (bool show, bool avail) => show && avail).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); Boost1Step = new ReactiveProperty <string>(BonusTypeHelper.GetStepText(config.Boost1.Mult.BonusType, config.Boost1.LevelUpAmount)); Boost2Step = new ReactiveProperty <string>(BonusTypeHelper.GetStepText(config.Boost2.Mult.BonusType, config.Boost2.LevelUpAmount)); BundleBoost1 = (from comb in BundleBuyAmount.CombineLatest(gearRunner.Level, (int amount, int lvl) => new { amount, lvl }) select(comb.lvl != 0) ? GetBonusAmount(config.Boost1, comb.amount, initial: false) : GetBonusAmount(config.Boost1, comb.amount, initial: true) into amount select BonusTypeHelper.GetAttributeText(config.Boost1.Mult.BonusType, amount)).TakeUntilDestroy(instance).ToReactiveProperty(); BundleBoost2 = (from comb in BundleBuyAmount.CombineLatest(gearRunner.Level, (int amount, int lvl) => new { amount, lvl }) select(comb.lvl != 0) ? GetBonusAmount(config.Boost2, comb.amount, initial: false) : GetBonusAmount(config.Boost2, comb.amount, initial: true) into amount select BonusTypeHelper.GetAttributeText(config.Boost2.Mult.BonusType, amount)).TakeUntilDestroy(instance).ToReactiveProperty(); }