public static List <PlayerGoalConfig> ParsePlayerGoals(string file, bool tutorial) { List <string[]> list = TSVParser.Parse(file).Skip(1).ToList(); List <PlayerGoalConfig> list2 = new List <PlayerGoalConfig>(); for (int i = 0; i < list.Count; i++) { string[] array = list[i]; PlayerGoalConfig playerGoalConfig = new PlayerGoalConfig(); playerGoalConfig.ID = array.asString(0, array.toError <string>()); playerGoalConfig.Index = i; playerGoalConfig.AppleID = array.asString(1, array.toError <string>()); playerGoalConfig.GoogleID = array.asString(2, array.toError <string>()); playerGoalConfig.Task = array.asEnum(3, array.toError <PlayerGoalTask>()); playerGoalConfig.Parameter = ParseTaskParameter(array, 4, playerGoalConfig.Task); playerGoalConfig.HeroLevelReq = array.asInt(5, array.toError <int>()); for (int j = 0; j < 5; j++) { playerGoalConfig.StarReq[j] = array.asBigDouble(6 + j, array.toError <BigDouble>()); } playerGoalConfig.IsTutorialGoal = tutorial; list2.Add(playerGoalConfig); } return(list2); }
private void ReportAchievement(PlayerGoalConfig cfg) { if (!string.IsNullOrEmpty(cfg.GoogleID)) { PersistentSingleton <AchievementsService> .Instance.ReportProgress(cfg.GoogleID, 100f); } }
public PlayerGoalRunner(PlayerGoalConfig config) { SceneLoader instance = SceneLoader.Instance; UIIngameNotifications IngameNotifications = BindingManager.Instance.IngameNotifications; GoalConfig = config; GoalState = PlayerGoalStateFactory.GetOrCreatePlayerGoalState(config.ID); GoalAction = PlayerGoalActionFactory.Create(GoalConfig, GoalState); GoalName = new ReactiveProperty <string>(PersistentSingleton <LocalizationService> .Instance.Text("PlayerGoal.Title." + config.ID)); ClaimedStars = GoalState.ClaimedStars; GoalAction.CompletedStars.Subscribe(delegate(int val) { GoalState.CompletedStars.Value = val; }).AddTo(instance); if (GoalConfig.IsTutorialGoal) { Unlocked = (from step in PlayerData.Instance.TutorialStep select step >= GoalConfig.Index).TakeUntilDestroy(instance).ToReactiveProperty(); } else { Unlocked = (from lvl in Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroRunner(0).LifetimeLevel select lvl >= GoalConfig.HeroLevelReq).TakeUntilDestroy(instance).ToReactiveProperty(); } ClaimAvailable = GoalState.CompletedStars.CombineLatest(GoalState.ClaimedStars, (int comp, int claim) => comp > claim).CombineLatest(Unlocked, (bool claimAvailable, bool unlocked) => claimAvailable && unlocked).TakeUntilDestroy(instance) .ToReactiveProperty(); GoalState.CompletedStars.Skip(1).Subscribe(delegate { IngameNotifications.InstantiatePlayerGoalNotification(this); }).AddTo(instance); CompletedStars = GoalAction.CompletedStars.TakeUntilDestroy(instance).ToReactiveProperty(); CompletedStars.Skip(1).Subscribe(delegate { if (PersistentSingleton <GameAnalytics> .Instance != null) { PersistentSingleton <GameAnalytics> .Instance.GoalCompleted.Value = this; } }).AddTo(instance); FullyCompleted = (from max in GoalAction.ProgressMax select max < BigDouble.ZERO).TakeUntilDestroy(instance).ToReactiveProperty(); (from full in FullyCompleted where full select full).Take(1).Subscribe(delegate { ReportAchievement(GoalConfig); }).AddTo(instance); Progress = GoalAction.Progress.TakeUntilDestroy(instance).ToReactiveProperty(); ProgressText = GoalAction.ProgressCurrent.CombineLatest(GoalAction.ProgressMax, (BigDouble cur, BigDouble max) => BigString.ToString(cur) + "/" + BigString.ToString(max)).TakeUntilDestroy(instance).ToReactiveProperty(); GemReward = (from stars in GoalState.ClaimedStars select Mathf.Min(stars, PersistentSingleton <Economies> .Instance.PlayerGoalRewards.Count - 1) into stars select PersistentSingleton <Economies> .Instance.PlayerGoalRewards[stars].GemReward).TakeUntilDestroy(instance).ToReactiveProperty(); }
private PlayerGoalRunner GetOrCreatePlayerGoalRunner(string id) { PlayerGoalRunner playerGoalRunner = TutorialGoalRunners.ToList().Find((PlayerGoalRunner pgr) => pgr.GoalConfig.ID == id); if (playerGoalRunner == null) { PlayerGoalConfig config = PersistentSingleton <Economies> .Instance.TutorialGoals.Find((PlayerGoalConfig cfg) => cfg.ID == id); playerGoalRunner = new PlayerGoalRunner(config); TutorialGoalRunners.Add(playerGoalRunner); } return(playerGoalRunner); }
public static PlayerGoalAction Create(PlayerGoalConfig config, PlayerGoalState state) { switch (config.Task) { case PlayerGoalTask.None: return(null); case PlayerGoalTask.Never: return(new PlayerGoalActionNever()); case PlayerGoalTask.Skip: return(new PlayerGoalActionSkip()); case PlayerGoalTask.Triggered: return(new PlayerGoalActionTriggered(state.CompletedStars, state.ClaimedStars, config.StarReq)); default: { UniRx.IObservable <BigDouble> rxProperty = ReferenceTaskTarget(config.Task, config.Parameter); return(new PlayerGoalActionBigDouble(rxProperty, state.ClaimedStars, config.StarReq)); } } }