Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override async void Initialize()
        {
            base.Initialize();

            WinWarCS.Util.Log.Write(Util.LogType.Generic, Util.LogSeverity.Status, "WinWarCS -- Version: " + Version);

            bool result = await ValidateDataWar();

            if (result == false)
            {
                await Platform.UI.ShowMessageDialog("DATA.WAR not found at expected location '" + AssetProvider.ExpectedDataDirectory +
                                                    "'. Please copy the DATA.WAR from the demo or the full version to that location.\r\nIf you have the full version, " +
                                                    "please also copy all the other .WAR files from the data directory.");

                return;
            }

            Exception loadingException = null;

            try
            {
                Entity.LoadDefaultValues(AssetProvider);
                WarFile.LoadResources(AssetProvider);
                MapTileset.LoadAllTilesets();
            } catch (Exception ex)
            {
                loadingException = ex;
            }

            soundManager = new SoundManager();
            musicManager = new MusicManager();

            if (loadingException != null)
            {
                await Platform.UI.ShowMessageDialog("An error occured during loading of DATA.WAR (" + loadingException + ").");

                return;
            }

            if (WarFile.IsDemo)
            {
                SetNextGameScreen(new MenuGameScreen(false));
            }
            else
            {
                // Play demo
                SetNextGameScreen(new IntroGameScreen(
                                      delegate(bool wasCancelled) {
                    SetNextGameScreen(new MenuGameScreen(!wasCancelled));
                }));
            }
        }