示例#1
0
        protected override void OnOutroComplete()
        {
            // Determine where to go next
            if (m_newLevel && Game.User.Progress.IsLevelCompleted(Level.Info.ID))
            {
                m_playthrough.JustCompletedLevel = m_playthrough.Level;
            }
            else
            {
                m_playthrough.JustCompletedLevel = -1;
            }

            if ((m_newLevel || m_playthrough.Level == m_playthrough.Campaign.Levels.Count - 1) &&
                ProgressUtils.IsCampaignCompleted(m_playthrough.Campaign, m_mod, Game.User))
            {
                m_playthrough.CampaignCompleted = true;
            }
            else if (m_newLevel)
            {
                // Find the next unlocked uncompleted level
                for (int i = m_playthrough.Level + 1; i < m_playthrough.Campaign.Levels.Count; ++i)
                {
                    if (!ProgressUtils.IsLevelCompleted(m_playthrough.Campaign, m_mod, i, Game.User) &&
                        ProgressUtils.IsLevelUnlocked(m_playthrough.Campaign, m_mod, i, Game.User))
                    {
                        m_playthrough.Level = i;
                        break;
                    }
                }
            }

            // Go there
            var outroPath = Level.Info.OutroPath;

            if (outroPath != null)
            {
                // Go to outro
                WipeToState(new CutsceneState(Game, m_mod, outroPath, CutsceneContext.LevelOutro, m_playthrough));
            }
            else if (m_playthrough.CampaignCompleted)
            {
                // Go to Game Over
                WipeToState(new GameOverState(Game, m_mod, m_playthrough));
            }
            else
            {
                // Go to level select
                BackToMenu(m_playthrough.Level);
            }
        }
示例#2
0
 private bool IsLevelUnlocked(Campaign campaign, Mod mod, int levelIndex, int ignoreLevel = -1)
 {
     return(m_editor || ProgressUtils.IsLevelUnlocked(campaign, mod, levelIndex, Game.User, ignoreLevel));
 }
示例#3
0
        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);
                        }
                    }
                }
            }
        }