Ejemplo n.º 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 void Initialize()
        {
            // TODO: Add your initialization logic here

            try
            {
                CurrentStage  = AODSaver.LoadData <int>(GameConsts.GameSaveDirectory + @"\" + "Cs.aod");
                EnabledStages = AODSaver.LoadData <List <int> >(GameConsts.GameSaveDirectory + @"\" + "Es.aod");
            }
            catch
            {
                CurrentStage  = 0;
                EnabledStages = new List <int>(10);
                EnabledStages.Add(1);
#if DEBUG
                EnabledStages.Add(2);
                EnabledStages.Add(3);
                EnabledStages.Add(4);
                EnabledStages.Add(5);
                EnabledStages.Add(6);
#endif
                EnabledStages.Add(11);
            }

            if (Directory.Exists(GameConsts.SettingsDirectory) == false)
            {
                Directory.CreateDirectory(GameConsts.SettingsDirectory);
            }
            if (Directory.Exists(GameConsts.GameSaveDirectory) == false)
            {
                Directory.CreateDirectory(GameConsts.GameSaveDirectory);
            }


            mainMenu                  = new AODMainMenuScene(this);
            mainMenu.StartGame       += new StartGameHandler(this.StartGame);
            mainMenu.SettingsChanged += new EventHandler(this.SettingsChanged);
            Components.Add(mainMenu);
            //添加GameComponent
            gameScene = new GameScene(this);
            gameScene.ExitToMainMenu += new EventHandler(gameScene_ExitToMainMenu);
            Components.Add(gameScene);
            gameScene.Enabled = false;
            bloom             = new BloomComponent(this);
            Components.Add(bloom);
            bloom.Enabled = false;
            bloom.Visible = false;
            fpsShower     = new FpsShower(this);
            Components.Add(fpsShower);


            base.Initialize();
        }
Ejemplo n.º 2
0
 void CurrentStage_Event_EnableStage(int i)
 {
     ((Game1)Game).CurrentStage = i;
     if (!((Game1)Game).EnabledStages.Contains(i))
     {
         ((Game1)Game).EnabledStages.Add(i);
         ((Game1)Game).textManager.AddText(new AODGameLibrary.Texts.AODText(Game, "New chapter available", 5f, Color.Gold, new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2), AODGameLibrary.Texts.FadeOutState.Normal, AODGameLibrary.Helpers.RandomHelper.RandomDirection2() * 20, true));
     }
     //try
     //{
     AODSaver.SaveData(((Game1)Game).EnabledStages, GameConsts.GameSaveDirectory + @"\" + "Es.aod");
     AODSaver.SaveData(((Game1)Game).CurrentStage, GameConsts.GameSaveDirectory + @"\" + "Cs.aod");
     //}
 }
Ejemplo n.º 3
0
        protected override void OnExiting(object sender, EventArgs args)
        {
            if (Directory.Exists(GameConsts.SettingsDirectory) == false)
            {
                Directory.CreateDirectory(GameConsts.SettingsDirectory);
            }
            if (Directory.Exists(GameConsts.GameSaveDirectory) == false)
            {
                Directory.CreateDirectory(GameConsts.GameSaveDirectory);
            }

            AODSaver.SaveData(settings, GameConsts.SettingsFile);
            base.OnExiting(sender, args);
        }
Ejemplo n.º 4
0
 void gameScene_ExitToMainMenu(object sender, EventArgs e)
 {
     MediaPlayer.Volume = MV;
     MediaPlayer.Play(titleSong2);
     MediaPlayer.IsRepeating = true;
     gameScene.Enabled       = false;
     gameScene.Visible       = false;
     bloom.Enabled           = false;
     bloom.Visible           = false;
     mainMenu.Reset();
     mainMenu.Enabled = true;
     mainMenu.Visible = true;
     AODSaver.SaveData(EnabledStages, GameConsts.GameSaveDirectory + @"\" + "Es.aod");
     AODSaver.SaveData(CurrentStage, GameConsts.GameSaveDirectory + @"\" + "Cs.aod");
 }
Ejemplo n.º 5
0
 public GameScene(Game game)
     : base(game)
 {
     // TODO: Construct any child components here
     blank        = Game.Content.Load <Texture2D>(@"blank");
     pauseTexture = Game.Content.Load <Texture2D>(@"Textures\PauseMenu");
     hyr          = Game.Content.Load <Texture2D>(@"Textures\hyr");
     Reset();
     ExitToMainMenu += new EventHandler(GameScene_ExitToMainMenu);
     try
     {
         PlayerSaver = AODSaver.LoadData <AODGameLibrary2.SavedUnit>(GameConsts.GameSaveDirectory + @"\" + "Player.aod");
         ((Game1)Game).textManager.AddText(new AODGameLibrary.Texts.AODText(Game, "战机信息已读取", 5f, Color.Gold, new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2), AODGameLibrary.Texts.FadeOutState.Normal, AODGameLibrary.Helpers.RandomHelper.RandomDirection2() * 20, true));
     }
     catch
     {
     }
 }
Ejemplo n.º 6
0
        void CurrentStage_Event_SavePlayer(object sender, EventArgs e)
        {
            PlayerSaver.SaveUnit(gameWorld.CurrentStage.Player, true);
            if (Directory.Exists(GameConsts.GameSaveDirectory) == false)
            {
                Directory.CreateDirectory(GameConsts.GameSaveDirectory);
            }
            //try
            //{
            AODSaver.SaveData(PlayerSaver, GameConsts.GameSaveDirectory + @"\" + "Player.aod");
            ((Game1)Game).textManager.AddText(new AODGameLibrary.Texts.AODText(Game, "Player data saved", 5f, Color.Gold, new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2), AODGameLibrary.Texts.FadeOutState.Normal, AODGameLibrary.Helpers.RandomHelper.RandomDirection2() * 20, true));

            //}
            //catch
            //{
            //    //((Game1)Game).textManager.AddText(new AODGameLibrary.Texts.AODText(Game, "战机信息保存失败", 5f, Color.Red, new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2), AODGameLibrary.Texts.FadeOutState.Normal, GameHelpers.GameHelper.RandomDirection2() * 20, true));

            //}
            //占楼待编辑
        }
Ejemplo n.º 7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //添加服务
            Services.AddService(typeof(SpriteBatch), spriteBatch);
            msyh = Content.Load <SpriteFont>("msyh");
            Services.AddService(typeof(SpriteFont), msyh);
            Services.AddService(typeof(GraphicsDeviceManager), graphicsDeviceManager);
            try
            {
                settings = AODSaver.LoadData <Settings>(GameConsts.SettingsFile).Clone();

                // settings = Content.Load<Settings>("DefaultSettings").Clone();
            }
            catch
            {
                settings = Content.Load <Settings>("DefaultSettings").Clone();
            }
            ApplySettingChanges();
            Services.AddService(typeof(Settings), settings);


            Content.Load <Texture2D>(@"logo");
            Content.Load <Song>(@"Audio\Marcello_Morgese_-_Space_Travel");
            Content.Load <Song>(@"Audio\Antti_Martikainen_-_Through_Enemy_Lines");
            titleSong = Content.Load <Song>(@"Audio\TitanSlayer_-_Dawning_of_Darkness");
            Content.Load <Song>(@"Audio\Kai_Engel_-_Beneath_The_Stronghold");
            Content.Load <Song>(@"Audio\Marcello_Morgese_-_Sounds_Of_The_Night");
            Content.Load <Song>(@"Audio\Marcello_Morgese_-_Space_Travel");
            titleSong2 = Content.Load <Song>(@"Audio\Moreno_Visintin_-_Mdnel-Inn");
            Content.Load <SoundEffect>(@"Audio\Blast4");

            // 先读取部分档案,避免游戏中读取导致速度减慢
            MediaPlayer.Volume = MV;
            MediaPlayer.Play(titleSong);

            MediaPlayer.IsRepeating = true;

            textManager = new TextManager();
            Services.AddService(typeof(TextManager), textManager);
        }