Пример #1
0
 public static void RemoveSong(GameSongs obj)
 {
     try
     {
         if (Songs.ContainsKey(obj))
         {
             Songs.Remove(obj);
         }
     }
     catch (Exception exception)
     {
         ErrorLog.Add(exception);
     }
 }
Пример #2
0
 public static void AddSong(GameSongs obj)
 {
     try
     {
         if (Songs == null)
         {
             Songs = new Dictionary <GameSongs, Song>();
         }
         if (!Songs.ContainsKey(obj))
         {
             Songs.Add(obj, ContentMgr.Load <Song>("Songs/" + Enum.GetName(typeof(GameSongs), obj)));
         }
     }
     catch (Exception exception)
     {
         ErrorLog.Add(exception);
     }
 }
 public void PlaySong(GameSongs aSong)
 {
     if (MediaPlayer.GameHasControl)
         MediaPlayer.Play(gameSongs[aSong]);
     MediaPlayer.IsRepeating = true;
 }
Пример #4
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()
        {
            // set up the display window
            graphics.PreferredBackBufferWidth = 500;
            graphics.PreferredBackBufferHeight = 500;
            graphics.ApplyChanges();

            // update the ViewportHeight and ViewportWidth constants so the screens know
            // how to draw themselves
            GameConstants.ViewportHeight = graphics.GraphicsDevice.Viewport.Height;
            GameConstants.ViewportWidth = graphics.GraphicsDevice.Viewport.Width;

            // display title in the window
            Window.Title = "Alien Attack";

            // setup the state of the game
            currentGameState = GameConstants.GameState.Title;
            currentKeyboardState = Keyboard.GetState();
            prevKeyBoardState = currentKeyboardState;

            // set up the screens
            titleScreen = new TitleScreen();
            instructionScreen = new InstructionScreen();
            highScoreScreen = new HighScoreScreen();
            creditsScreen = new CreditsScreen();
            introScreen = new IntroScreen();
            readyScreen = new GetReadyScreen();
            gameOverScreen = new GameOverScreen();

            // set up the game objects
            gameCamera = new Camera();
            player = new Player();
            enemies = new Enemies();
            map = new Map();
            miniMap = new MiniMap();
            skybox = new Skybox();

            // set up the ingame displays
            score = new Score();
            highScore = new HighScore();

            // set up the soundtrack
            gameSongs = new GameSongs();

            base.Initialize();
        }