Ejemplo n.º 1
0
    public HeroNotificaitonRunner()
    {
        Singleton <PropertyManager> .Instance.AddRootContext(this);

        HeroCostRunner orCreateHeroCostRunner = Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroCostRunner(0);

        SceneLoader instance = SceneLoader.Instance;

        HeroUpgradeAvailable = orCreateHeroCostRunner.UpgradeAvailable;
        UniRx.IObservable <bool> observable = Observable.Return <bool>(value: false);
        foreach (HeroCostRunner item in Singleton <HeroTeamRunner> .Instance.Costs())
        {
            observable = observable.CombineLatest(item.UpgradeAvailable, (bool combined, bool available) => combined || available);
        }
        CompanionUpgradeAvailable = observable.TakeUntilDestroy(instance).ToReactiveProperty();
    }
Ejemplo n.º 2
0
    public GearSetRunner(int setIndex)
    {
        SceneLoader instance = SceneLoader.Instance;

        GearRunners = (from gear in Singleton <GearCollectionRunner> .Instance.Gears()
                       where gear.SetIndex == setIndex
                       select gear).ToList();
        UniRx.IObservable <int> observable = Observable.Return(int.MaxValue);
        foreach (GearRunner gearRunner in GearRunners)
        {
            observable = observable.CombineLatest(gearRunner.Level, Mathf.Min);
        }
        UniRx.IObservable <int> observable2 = Observable.Return(0);
        foreach (GearRunner gearRunner2 in GearRunners)
        {
            observable2 = observable2.CombineLatest(gearRunner2.Level, Mathf.Max);
        }
        MaxAllLevel = observable.TakeUntilDestroy(instance).ToReactiveProperty();
        MaxAnyLevel = observable2.TakeUntilDestroy(instance).ToReactiveProperty();
        GearSet gearSet = PersistentSingleton <Economies> .Instance.GearSets[setIndex];

        SetBoostText = new ReactiveProperty <string>(BonusTypeHelper.GetAttributeText(gearSet.Bonus.BonusType, gearSet.Bonus.Amount));
    }
Ejemplo n.º 3
0
    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);
    }