Example #1
0
        public static XmlDocument LoadDocument(string filename, bool useFallback = true)
        {
            XmlDocument doc = new XmlDocument();

            if (File.Exists(filename))
            {
                StreamReader  sr = new StreamReader(filename);
                XmlTextReader xr = new XmlTextReader(sr);
                doc.Load(xr);
                sr.Dispose();
                xr.Close();
                return(doc);
            }
            if (filename.Contains("SavedData"))
            {
                throw new Exception("Failed to load saved data");
            }
            return(LevelSaver.PrepareNewLevelDocument("This level was created because the file was missing. ", filename));
        }
Example #2
0
        public void OverwriteLevel(bool Choice)
        {
            this.IsFinished = true;
            if (Choice)
            {
                CustomLevelButton oldData = null;
                foreach (CustomLevelButton customLevelButton in LevelButton.lvButtonList)
                {
                    if (customLevelButton != Level.CurrentLevelButton &&                  // Don't compare the button with itself
                        customLevelButton.Name == Level.CurrentLevelButton.Name)                            // If the level name already exists
                    {
                        oldData = customLevelButton;
                        break;
                    }
                }
                LevelButton.lvButtonList.Remove(oldData);

                LevelSaver.SaveMap();
            }
        }
Example #3
0
 private static bool Save()
 {
     if (TextInput.TextInputList[0].Text.Length == 0)
     {
         MessageBox.StatusMessage = new MessageBox("Level must have a name!", new Microsoft.Xna.Framework.Vector2(217, 190), 120);
         return(false);
     }
     foreach (CustomLevelButton customLevelButton in LevelButton.lvButtonList)
     {
         if (customLevelButton != Level.CurrentLevelButton &&              // Don't compare the button with itself
             customLevelButton.Name == TextInput.TextInputList[0].Text)                        // If the level name already exists
         {
             MainMethod.popupBox = new PopupBox(new string[] {
                 "This filename already exists",
                 "This will overwrite the existing level",
                 "Really overwrite the old data?"
             }, PopupType.OVERWRITE_LEVEL);
             return(false);
         }
     }
     return(LevelSaver.SaveMap());
 }
Example #4
0
        protected override void Update(GameTime gameTime)
        {
            if (this.isAppStarting)
            {
                MainMenu.Activate();
                this.isAppStarting = false;
            }
            else
            {
                SteamIntegration.Update();
            }
            if (ScreenManager.GameClosing)
            {
                SteamAPI.Shutdown();
                base.Exit();
            }
            if (base.IsActive && !SteamIntegration.instance.IsPublishing)
            {
                MainMenu.Update();
                LevelSaver.Update();

                if (popupBox == null)
                {
                    InGame.Update();
                    Editor.Update();
                }
                else if (popupBox.IsFinished)
                {
                    popupBox = null;
                }
                InputManager.CheckInput();
            }
            else if (ScreenManager.Ingame)
            {
                PauseMenu.Pause();
            }
            if (LevelLoader.LevelComplete)
            {
                if (!ScreenManager.Custom)
                {
                    SaveFile.CompleteLevel();
                }
                if (Level.Current == Level.maxLevels)
                {
                    if (ScreenManager.Custom)
                    {
                        Level.Current = 0;
                        LevelLoader.NextLevel();
                    }
                    else
                    {
                        SteamIntegration.Achievements.GameComplete();
                        LevelLoader.LevelComplete = false;
                        ScreenManager.GameCompleteOn();
                    }
                }
                else
                {
                    LevelLoader.NextLevel();
                }
            }

            if (DebugMode)
            {
                debug.Update(gameTime);
            }

            TimeSinceLastUpdate = ((float)base.TargetElapsedTime.TotalMilliseconds) / 1000f;
            base.Update(gameTime);
        }