Beispiel #1
0
        private void ShowMenu()
        {
            var lang          = Game.Language;
            var options       = new List <string>();
            var optionActions = new List <Action>();

            if (Game.User.Progress.GetStatistic(Statistic.LevelsCompleted) > 0)
            {
                options.Add(lang.Translate("menus.main.continue_game"));
            }
            else
            {
                options.Add(lang.Translate("menus.main.new_game"));
            }
            optionActions.Add(ContinueGame);

            if (ArcadeUtils.IsArcadeUnlocked(Game.User.Progress))
            {
                options.Add(lang.Translate("menus.main.arcade"));
                optionActions.Add(Arcade);
            }

            options.Add(lang.Translate("menus.main.mod_editor"));
            optionActions.Add(ShowGamepadWarningThenModEditor);

            options.Add(lang.Translate("menus.main.options"));
            optionActions.Add(Options);

            options.Add(lang.Translate("menus.main.quit"));
            optionActions.Add(Quit);

            var dialog = DialogBox.CreateMenuBox(
                lang.Translate("menus.main.title"),
                options.ToArray(),
                false
                );

            dialog.OnClosed += delegate(object sender, DialogBoxClosedEventArgs e)
            {
                int index = e.Result;
                if (index >= 0 && index < optionActions.Count)
                {
                    optionActions[index].Invoke();
                }
                else
                {
                    GoBack();
                }
            };
            ShowDialog(dialog);
        }
Beispiel #2
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);
                        }
                    }
                }
            }
        }