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()
        {
            graphics.ApplyChanges();

            titleScreen = new TitleScreen();
            levelScreen = new LevelScreen();
            endScreen = new EndScreen();
            if (LEVEL_DESIGN_MODE)
                currentScreen = levelScreen;
            else
                currentScreen = titleScreen; // Choose starting screen;

            titleScreen.Initialize();
            levelScreen.Initialize();
            endScreen.Initialize();

            base.Initialize();
        }
Ejemplo n.º 2
0
        /*
        public static FontFile Load(Stream stream)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(FontFile));
            FontFile file = (FontFile)deserializer.Deserialize(stream);
            return file;
        }
        */
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            int musicReference = 0;// currentScreen.musicType();
            switch (currentScreen.Type)
            {
                case "TitleScreen":
                    currentScreen = titleScreen;
                    currentScreen.Type = "TitleScreen";
                    musicReference = currentScreen.musicSelection;
                    break;
                case "LevelScreen":
                    if (!LEVEL_INITIALIZED)
                    {
                        levelScreen.InitializeLevel();
                        LEVEL_INITIALIZED = true;
                    }
                    currentScreen = levelScreen;
                    currentScreen.Type = "LevelScreen";
                    musicReference = currentScreen.musicSelection;
                    break;
                case "EndScreen":
                    currentScreen = endScreen;
                    currentScreen.Type = "EndScreen";
                    musicReference = currentScreen.musicSelection;
                    break;
                case "Exit":
                    Exit();
                    break;
            }

            Console.WriteLine("Music type is: " + musicReference);
            switch (musicReference)
            {
                case 0:
                     victoryMusic.Stop();
                    failureMusic.Stop();
                    mainMusic.Play();
                    //mainMusic.Resume();

                    break;
                case 1:

                    mainMusic.Stop();
                    victoryMusic.Stop();
                    failureMusic.Play();
                    break;

                case 2:
                    mainMusic.Stop();
                    failureMusic.Stop();
                    victoryMusic.Play();
                    break;

                default:
                    break;
            }

            currentScreen.Update(gameTime);

            base.Update(gameTime);
        }