public void BuyMore(SkillsEnum skill) { if (PlayerData.Instance.Gems.Value < Cost.Value) { NotEnoughGems(); BindingManager.Instance.NotEnoughGemsOverlay.SetActive(value: true); } else { Singleton <FundRunner> .Instance.RemoveGems(Cost.Value, skill.ToString(), "skills"); AddAmount(PersistentSingleton <GameSettings> .Instance.SkillPurchaseAmount); } }
public List <RewardEnum> GetUnlockedSkills() { List <RewardEnum> list = new List <RewardEnum>(); int value = PlayerData.Instance.HeroStates[0].LifetimeLevel.Value; int i; for (i = 0; i < 5; i++) { if (PersistentSingleton <Economies> .Instance.Skills.Find(delegate(SkillConfig s) { string name = s.Name; SkillsEnum skillsEnum = (SkillsEnum)i; return(name == skillsEnum.ToString()); }).LevelReq <= value) { switch (i) { case 0: list.Add(RewardEnum.AddToSkillAutoMine); break; case 3: list.Add(RewardEnum.AddToSkillGoldfinger); break; case 4: list.Add(RewardEnum.AddToSkillTNT); break; case 2: list.Add(RewardEnum.AddToSkillTapBoost); break; case 1: list.Add(RewardEnum.AddToSkillTeamBoost); break; } } } return(list); }
public void OnBuyMore() { PersistentSingleton <GameAnalytics> .Instance.PopupDecisions.Value = new PopupDecision(m_skill.ToString(), "buy"); Singleton <SkillCollectionRunner> .Instance.GetOrCreateSkillRunner(m_skill).BuyMore(m_skill); }
public SkillRunner(SkillsEnum skill) { SceneLoader instance = SceneLoader.Instance; Skill = skill; m_skillState = SkillStateFactory.GetOrCreateSkillState(skill); m_skillConfig = PersistentSingleton <Economies> .Instance.Skills.Find((SkillConfig s) => s.Name == Skill.ToString()); Cost.Value = PersistentSingleton <GameSettings> .Instance.SkillPurchaseCosts[(int)Skill]; LevelReq.Value = m_skillConfig.LevelReq; LifetimeUsed = m_skillState.LifetimeUsed; Locked = (from lvl in Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroRunner(0).LifetimeLevel select lvl < m_skillConfig.LevelReq).TakeUntilDestroy(instance).ToReactiveProperty(); Amount = m_skillState.Amount.CombineLatest(Locked, (int amount, bool locked) => (!locked) ? amount : 0).TakeUntilDestroy(instance).ToReactiveProperty(); UnlockTriggered = (from pair in Locked.Pairwise() where pair.Previous && !pair.Current select pair into _ select Skill).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); m_skillState.CooldownTimeStamp.Subscribe(delegate { if (!Locked.Value) { UpdateCooldown(); } }).AddTo(instance); CanAffordPurchase = (from gems in PlayerData.Instance.Gems select gems >= Cost.Value).TakeUntilDestroy(instance).ToReactiveProperty(); MaxDuration = (from duration in Singleton <CumulativeBonusRunner> .Instance.BonusMult[(int)(8 + Skill)] select SkillsEnumHelper.IsDuration(Skill) ? duration.ToInt() : 0 into duration select m_skillConfig.DurationSeconds + duration).TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); TickerService.MasterTicks.Subscribe(delegate(long ticks) { if (m_skillState.ElapsedTime.Value < 1728000000000L) { m_skillState.ElapsedTime.Value += ticks; UpdateCooldown(); } }).AddTo(instance); SecondsLeft = m_skillState.ElapsedTime.CombineLatest(MaxDuration, (long elapsed, int dur) => Mathf.Max(0, dur - (int)(elapsed / 10000000))).DistinctUntilChanged().TakeUntilDestroy(instance) .ToReactiveProperty(); Active = (from secs in SecondsLeft select secs > 0).TakeUntilDestroy(instance).ToReactiveProperty(); (from act in Active.Pairwise() where !act.Current && act.Previous select act).Subscribe(delegate { m_skillState.CooldownTimeStamp.Value = ServerTimeService.NowTicks(); }).AddTo(instance); (from act in Active.Pairwise() where act.Current && act.Previous select act).Subscribe(delegate { if (PersistentSingleton <GameAnalytics> .Instance != null) { PersistentSingleton <GameAnalytics> .Instance.SkillUsed.Value = Skill; } }).AddTo(instance); Cooldown = (from secs in CooldownSeconds select secs > 0).CombineLatest(Active, (bool cooldown, bool active) => cooldown && !active).TakeUntilDestroy(instance).ToReactiveProperty(); UniRx.IObservable <bool> observable = Active.CombineLatest(Cooldown, (bool active, bool cooldown) => !active && !cooldown).CombineLatest(Locked, (bool noTimer, bool locked) => noTimer && !locked); Available = observable.TakeUntilDestroy(instance).ToReactiveProperty(); OutOfStock = observable.CombineLatest(Amount, (bool poss, int amount) => poss && amount <= 0).TakeUntilDestroy(instance).ToReactiveProperty(); LocalizedName = new ReactiveProperty <string>(PersistentSingleton <LocalizationService> .Instance.Text("Skill.Name." + Skill.ToString())); LocalizedDesc = new ReactiveProperty <string>(PersistentSingleton <LocalizationService> .Instance.Text("Skill.Name.Desc." + Skill.ToString())); (from order in Singleton <PrestigeRunner> .Instance.PrestigeTriggered select order == PrestigeOrder.PrestigeStart).Subscribe(delegate { m_skillState.CooldownTimeStamp.Value = 0L; m_skillState.ElapsedTime.Value = 1728000000000L; }).AddTo(instance); (from amount in Amount.Pairwise() where amount.Current > amount.Previous select amount).Subscribe(delegate { ResetCooldown(); }).AddTo(instance); UpdateCooldown(); AdAvailable = Singleton <AdRunner> .Instance.AdReady.TakeUntilDestroy(instance).ToReadOnlyReactiveProperty(); (from ad in Singleton <AdRunner> .Instance.AdPlacementFinished where ad.ToString() == Skill.ToString() select ad).Subscribe(delegate { SkillAdFinished(); }).AddTo(instance); (from ad in Singleton <AdRunner> .Instance.AdPlacementSkipped where ad.ToString() == Skill.ToString() select ad).Subscribe(delegate { SkillAdSkipped(); }).AddTo(instance); (from ad in Singleton <AdRunner> .Instance.AdPlacementFailed where ad.ToString() == Skill.ToString() select ad).Subscribe(delegate { SkillAdSkipped(); }).AddTo(instance); }