Exemplo n.º 1
0
        /// <summary>
        /// Opens a file dialog to load a custom map (loads current map).
        /// </summary>
        /// <param name="editing">If true, this will call the load method on the static map instead of the current map.</param>
        /// <exception cref="IOException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="InvalidOperationException"></exception>
        public static void LoadCustomCampaign(bool editing)
        {
            string mapName;

            if (editing)
            {
                mapName = "map-static.xml";
            }
            else
            {
                mapName = "map.xml";
            }

            FileDialog dialog = new FileDialog(FileDialog.DialogOptions.Open, $"XAML File | {mapName}");

            GameBase.CurrentMapLocation = Path.GetDirectoryName(dialog.GetPath()) + "\\map.xml";
            GameBase.StaticMapLocation  = Path.GetDirectoryName(dialog.GetPath()) + "\\map-static.xml";

            try
            {
                if (editing)
                {
                    GameBase.StaticGame = LoadMap(GameBase.StaticMapLocation);
                    GameBase.StaticGame.Load(GameBase.StaticGame);
                }
                else
                {
                    GameBase.CurrentGame = LoadMap(GameBase.CurrentMapLocation);
                    GameBase.CurrentGame.Load(GameBase.CurrentGame);
                }
            }
            catch (InvalidOperationException)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IOException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public static void CreateCustomCampaign()
        {
            FileDialog dialog = new FileDialog(FileDialog.DialogOptions.Save, "XAML File|.xml", "map-static");

            GameBase.NewCustomCampaign(dialog.GetPath());
        }