Exemple #1
0
 protected override void OnOutroStarted(int robotsSaved, LevelCompleteDetails o_completeDetails)
 {
     // Unlock achievements
     m_completed = true;
     if (m_mod != null && m_mod.Source == ModSource.Editor)
     {
         Game.User.Progress.UnlockAchievement(Achievement.CreateLevel);
         Game.User.Progress.Save();
     }
 }
        protected override void OnOutroStarted(int robotsSaved, LevelCompleteDetails o_completeDetails)
        {
            int  levelsPreviouslyUnlocked      = 0;
            bool arcadePreviouslyUnlocked      = false;
            int  arcadeGamesPreviouslyUnlocked = 0;

            if (m_newLevel)
            {
                levelsPreviouslyUnlocked = ProgressUtils.CountLevelsUnlocked(m_playthrough.Campaign, m_mod, Game.User);
                if (ArcadeUtils.IsArcadeUnlocked(Game.User.Progress))
                {
                    arcadePreviouslyUnlocked      = true;
                    arcadeGamesPreviouslyUnlocked = ArcadeUtils.GetAllDisks().Count(
                        disk => ArcadeUtils.IsDiskUnlocked(disk.Disk, disk.Mod, Game.User.Progress)
                        );
                }
            }

            // Mark the level as completed and unlock achivements
            if (m_mod == null && Level.Info.PlacementsLeft > 0)
            {
                Game.User.Progress.UnlockAchievement(Achievement.Optimisation);
            }

            var obstaclesUsed = Level.Info.TotalPlacements - Level.Info.PlacementsLeft;

            Game.User.Progress.SetLevelCompleted(Level.Info.ID, obstaclesUsed);

            if (m_newLevel)
            {
                Game.User.Progress.AddPlaytime(Level.Info.ID, TimeInState);
                Game.User.Progress.AddStatistic(Statistic.RobotsRescued, robotsSaved);
                Game.User.Progress.IncrementStatistic(Statistic.LevelsCompleted);
                if (m_mod != null && m_mod.Source == ModSource.Workshop)
                {
                    Game.User.Progress.IncrementStatistic(Statistic.WorkshopLevelsCompleted);
                }
                else if (m_mod == null)
                {
                    Game.User.Progress.IncrementStatistic(Statistic.CampaignLevelsCompleted);
                    if (Game.User.Progress.GetStatistic(Statistic.CampaignLevelsCompleted) > 0)
                    {
                        Game.User.Progress.UnlockAchievement(Achievement.CompleteFirstLevel);
                    }
                    if (Game.User.Progress.GetStatistic(Statistic.CampaignLevelsCompleted) >= m_playthrough.Campaign.Levels.Count)
                    {
                        Game.User.Progress.UnlockAchievement(Achievement.CompleteAllLevels);
                    }
                }
            }
            Game.User.Progress.Save();

            // Determine what was unlocked
            int unused;

            o_completeDetails.RobotsRescued = ProgressUtils.CountRobotsRescued(m_playthrough.Campaign, m_mod, Game.User, out unused);
            if (m_newLevel)
            {
                int newLevelsUnlocked = ProgressUtils.CountLevelsUnlocked(m_playthrough.Campaign, m_mod, Game.User) - levelsPreviouslyUnlocked;
                if (newLevelsUnlocked >= 2)
                {
                    o_completeDetails.ThingsUnlocked.Add(Unlockable.Levels);
                }
                else if (newLevelsUnlocked == 1)
                {
                    o_completeDetails.ThingsUnlocked.Add(Unlockable.Level);
                }

                bool arcadeUnlocked = ArcadeUtils.IsArcadeUnlocked(Game.User.Progress);
                if (arcadeUnlocked)
                {
                    if (!arcadePreviouslyUnlocked)
                    {
                        o_completeDetails.ThingsUnlocked.Add(Unlockable.Arcade);
                    }
                    else
                    {
                        int newArcadeGamesUnlocked = ArcadeUtils.GetAllDisks().Count(
                            disk => ArcadeUtils.IsDiskUnlocked(disk.Disk, disk.Mod, Game.User.Progress)
                            );
                        if (newArcadeGamesUnlocked > arcadeGamesPreviouslyUnlocked)
                        {
                            o_completeDetails.ThingsUnlocked.Add(Unlockable.ArcadeGame);
                        }
                    }
                }
            }
        }