Exemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            soundEffect = Content.Load <Song>(@"audio\backgroundMusic");

            // Start the soundtrack audio
            if (!musicOn)
            {
                MediaPlayer.IsRepeating = true;
                MediaPlayer.Play(soundEffect);
                musicOn = true;
            }

            font = Content.Load <SpriteFont>("font/Hud");

            level = new Level(this);
            string startLevel = Xml.StartLevel;

            if (startLevel == null)
            {
                startLevel = "novice.xml";
            }
            level.Load(startLevel);

            menuBackground = Content.Load <Texture2D>("texture/Background.MenuBackground");
        }
Exemplo n.º 2
0
        /// <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)
        {
            // Allows the game to exit
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (!wasEscKeydown)
                {
                    wasEscKeydown = true;
                    gotoMenu      = !gotoMenu;
                }
            }
            else
            {
                wasEscKeydown = false;
            }

            if (!gotoMenu)
            {
                level.Update(gameTime);
                current_levelFileName = level.LevelFileName;

                if (level.Player.IsLeaving)
                {
                    ChangeLevel();

                    playerBornPointId = null;
                    playerBornPointId = Level.Player.BornPointId;
                }

                if (!level.Player.IsAlive)
                {
                    dieTime += gameTime.ElapsedGameTime.Milliseconds;
                    if (dieTime > level.Player.DieTime)
                    {
                        diePosition = new Vector2(level.Player.Position.X,
                                                  level.Player.Position.Y);
                        level = new Level(this);
                        level.Load(current_levelFileName);
                        dieTime = 0;
                    }
                }
            }
            else
            {
                MenuUpdate();
            }

            base.Update(gameTime);
        }
Exemplo n.º 3
0
        private void ChangeLevel()
        {
            string commingLevel = Level.Player.ComingLevel;

            if (commingLevel == "null")
            {
                return;
            }

            if (commingLevel == "TotalLevel.xml")
            {
                Xml.StartLevel = "TotalLevel.xml";
            }

            bindingPoint = null;

            level = new Level(this);
            level.Load(commingLevel);

            level.Player.IsLeaving = false;
        }
Exemplo n.º 4
0
        public void MenuUpdate()
        {
            // select options
            KeyboardState keystate = Keyboard.GetState();

            if (keystate.IsKeyDown(Keys.Down))
            {
                if (!wasDownKeydown)
                {
                    currentSelection++;
                    if (Level.LevelFileName.IndexOf("-") < 0 && currentSelection == 2)
                    {
                        currentSelection++;
                    }
                    if (currentSelection > maxItemsCount)
                    {
                        currentSelection = 1;
                    }
                }
                wasDownKeydown = true;
            }
            else
            {
                wasDownKeydown = false;
            }

            if (keystate.IsKeyDown(Keys.Up))
            {
                if (!wasUpKeydown)
                {
                    currentSelection--;
                    if (Level.LevelFileName.IndexOf("-") < 0 && currentSelection == 2)
                    {
                        currentSelection--;
                    }
                    if (currentSelection < 1)
                    {
                        currentSelection = maxItemsCount;
                    }
                }
                wasUpKeydown = true;
            }
            else
            {
                wasUpKeydown = false;
            }

            // execute the selectioon
            if (currentSelection == 1 && keystate.IsKeyDown(Keys.Enter))
            {
                gotoMenu = false;
            }
            else if (currentSelection == 2 && keystate.IsKeyDown(Keys.Enter))
            {
                if (Level.LevelFileName.IndexOf("-") > 0)
                {
                    bindingPoint = null;
                    gotoMenu     = false;
                    String general_level = Level.LevelFileName.Substring(0, 6);
                    general_level += ".xml";
                    level          = new Level(this);
                    level.Load(general_level);
                }
            }
            else if (currentSelection == 3 && keystate.IsKeyDown(Keys.Enter))
            {
                bindingPoint = null;
                Level.TreasureMgr.ResetLevel();
                gotoMenu = false;
                LoadContent();
            }
            else if (currentSelection == 4 && keystate.IsKeyDown(Keys.Enter))
            {
                if (musicOn)
                {
                    MediaPlayer.Pause();
                    musicOn = false;
                }
                else
                {
                    MediaPlayer.IsRepeating = true;
                    MediaPlayer.Play(soundEffect);
                    musicOn = true;
                }
                gotoMenu = false;
            }
            else if (currentSelection == 5 && keystate.IsKeyDown(Keys.Enter))
            {
                this.Exit();
            }
        }
Exemplo n.º 5
0
        private void ChangeLevel()
        {
            string commingLevel = Level.Player.ComingLevel;

            if (commingLevel == "null")
            {
                return;
            }

            if (commingLevel == "TotalLevel.xml")
            {
                Xml.StartLevel = "TotalLevel.xml";
            }

            bindingPoint = null;

            level = new Level(this);
            level.Load(commingLevel);

            level.Player.IsLeaving = false;
        }
Exemplo n.º 6
0
        /// <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)
        {
            // Allows the game to exit
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (!wasEscKeydown)
                {
                    wasEscKeydown = true;
                    gotoMenu = !gotoMenu;
                }
            }
            else
            {
                wasEscKeydown = false;
            }

            if (!gotoMenu)
            {
                level.Update(gameTime);
                current_levelFileName = level.LevelFileName;

                if (level.Player.IsLeaving)
                {
                    ChangeLevel();

                        playerBornPointId = null;
                        playerBornPointId = Level.Player.BornPointId;

                }

                if (!level.Player.IsAlive)
                {
                    dieTime += gameTime.ElapsedGameTime.Milliseconds;
                    if (dieTime > level.Player.DieTime)
                    {
                        diePosition = new Vector2(level.Player.Position.X,
                            level.Player.Position.Y);
                        level = new Level(this);
                        level.Load(current_levelFileName);
                        dieTime = 0;
                    }
                }
            }
            else
            {
                MenuUpdate();
            }

            base.Update(gameTime);
        }
Exemplo 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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            soundEffect = Content.Load<Song>(@"audio\backgroundMusic");

            // Start the soundtrack audio
            if (!musicOn)
            {
                MediaPlayer.IsRepeating = true;
                MediaPlayer.Play(soundEffect);
                musicOn = true;
            }

            font = Content.Load<SpriteFont>("font/Hud");

            level = new Level(this);
            string startLevel = Xml.StartLevel;
            if (startLevel == null)
            {
                startLevel = "novice.xml";
            }
            level.Load(startLevel);

            menuBackground = Content.Load<Texture2D>("texture/Background.MenuBackground");
        }
Exemplo n.º 8
0
        public void MenuUpdate()
        {
            // select options
            KeyboardState keystate = Keyboard.GetState();
            if (keystate.IsKeyDown(Keys.Down))
            {
                if (!wasDownKeydown)
                {
                    currentSelection++;
                    if (Level.LevelFileName.IndexOf("-") < 0 && currentSelection == 2)
                    {
                        currentSelection++;
                    }
                    if (currentSelection > maxItemsCount)
                    {
                        currentSelection = 1;
                    }
                }
                wasDownKeydown = true;
            }
            else
            {
                wasDownKeydown = false;
            }

            if (keystate.IsKeyDown(Keys.Up))
            {
                if (!wasUpKeydown)
                {
                    currentSelection--;
                    if (Level.LevelFileName.IndexOf("-") < 0 && currentSelection == 2)
                    {
                        currentSelection--;
                    }
                    if (currentSelection < 1)
                    {
                        currentSelection = maxItemsCount;
                    }
                }
                wasUpKeydown = true;
            }
            else
            {
                wasUpKeydown = false;
            }

            // execute the selectioon
            if (currentSelection == 1 && keystate.IsKeyDown(Keys.Enter))
            {
                gotoMenu = false;
            }
            else if (currentSelection == 2 && keystate.IsKeyDown(Keys.Enter))
            {
                if (Level.LevelFileName.IndexOf("-") > 0)
                {
                    bindingPoint = null;
                    gotoMenu = false;
                    String general_level = Level.LevelFileName.Substring(0, 6);
                    general_level += ".xml";
                    level = new Level(this);
                    level.Load(general_level);
                }
            }
            else if (currentSelection == 3 && keystate.IsKeyDown(Keys.Enter))
            {
                bindingPoint = null;
                Level.TreasureMgr.ResetLevel();
                gotoMenu = false;
                LoadContent();
            }
            else if (currentSelection == 4 && keystate.IsKeyDown(Keys.Enter))
            {
                if (musicOn)
                {
                    MediaPlayer.Pause();
                    musicOn = false;
                }
                else
                {
                    MediaPlayer.IsRepeating = true;
                    MediaPlayer.Play(soundEffect);
                    musicOn = true;
                }
                gotoMenu = false;
            }
            else if (currentSelection == 5 && keystate.IsKeyDown(Keys.Enter))
            {
                this.Exit();
            }
        }