This class represents a level in the game
Beispiel #1
0
        public LevelInfo(XElement levelInfo, ContentManager content, IControlScheme controls, GraphicsDeviceManager graphics)
        {
            foreach (var element in levelInfo.Elements())
            {
                if (element.Name == XmlKeys.LevelName)
                    Level = new Level(WorldSelect.LevelDirectory + element.Value + ".xml",
                        controls, graphics.GraphicsDevice.Viewport);
                if (element.Name == XmlKeys.Timerstar)
                    TimerStar = Level.TimerStar = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Collectionstar)
                    CollectStar = Level.CollectionStar = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Deathstar)
                    DeathStar = Level.DeathStar = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Goaltime)
                    _mGoalTime = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Goalcollectable)
                    _mGoalCollectable = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Unlocked)
                    Unlocked = element.Value == XmlKeys.True;
            }
            _mContent = content;
            _mGraphics = graphics;
            _mControls = controls;
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="levelInfo"></param>
        /// <param name="controls"></param>
        /// <param name="graphics"></param>
        public LevelChoice(XElement levelInfo, IControlScheme controls, ContentManager content, GraphicsDevice graphics)
        {
            foreach(var element in levelInfo.Elements())
            {
                if (element.Name == XmlKeys.LevelName)
                {
                    Level = new Level(LevelSelect.LevelDirectory + element.Value + ".xml", controls, graphics.Viewport);

            #if XBOX360
                    mThumbnail = content.Load<Texture2D>("Levels\\Thumbnail\\" + element.Value.ToString());
            #else
                    FileStream filestream;
                    try
                    {
                        filestream = new FileStream(LevelSelect.LevelThumbsDirectory + element.Value + ".png", FileMode.Open);
                    }
                    catch (IOException e)
                    {
                        var err = e.ToString();
                        filestream = new FileStream(LevelSelect.LevelThumbsDirectory + "..\\..\\..\\Content\\Images\\Error.png", FileMode.Open);
                    }
                    Thumbnail = Texture2D.FromStream(graphics, filestream);
                    filestream.Close();
            #endif
                }
                if (element.Name == XmlKeys.Unlocked)
                    Unlocked = element.Value == XmlKeys.True;

                if (element.Name == XmlKeys.Timerstar)
                    TimerStar = Level.TimerStar = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Collectionstar)
                    CollectionStar = Level.CollectionStar = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Deathstar)
                    DeathStar = Level.DeathStar = Convert.ToInt32(element.Value);
            }
        }
Beispiel #3
0
        /// <summary>
        ///     LoadContent will be called once per game and is the place to load
        ///     all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // current viewport
            var screenscaleX = Graphics.GraphicsDevice.Viewport.Width / 1280.0f;
            var screenscaleY = Graphics.GraphicsDevice.Viewport.Height / 720.0f;

            // Create the scale transform for Draw.
            // Do not scale the sprite depth (Z=1).
            _mScale = Matrix.CreateScale(screenscaleX, screenscaleY, 1);

            _mTitle.Load(Content, Graphics.GraphicsDevice);

            _mMainMenu.Load(Content);
            _mMainMenuLevel = Level.MainMenuLevel("Content\\Levels\\MainMenu.xml", _mControls, Graphics.GraphicsDevice.Viewport, _mMainMenu.GetInnerRegion());

            _mMainMenuLevel.Load(Content);
            _mCredits.Load(Content);
            _mOptions.Load(Content);

            _mPause.Load(Content);
            GameSound.Load(Content);
            _mCurrentLevel = new Level(_mLevelLocation, _mControls, GraphicsDevice.Viewport);
            _mCurrentLevel.Load(Content);

            _mWorldSelect.Load(Content);
            _mScoring.Load(Content, Graphics.GraphicsDevice, _mWorldSelect);
            _mAfterScore.Load(Content, GraphicsDevice);
            _mPreScore.Load(Content, GraphicsDevice, _mWorldSelect);
            _mResetConfirm.Load(Content);
            _mController.Load(Content);
            _mSoundOptions.Load(Content);
            _mStartLevelSplash.Load(Content, GraphicsDevice);
            _mPurchaseScreenSplash.Load(Content, GraphicsDevice);
            _mWorldPurchaseScreenSplash.Load(Content, GraphicsDevice);

            _mSpriteBatch = new SpriteBatch(GraphicsDevice);

            Content.Load<SpriteFont>("Fonts/Kootenay");

            _mQuartz = Content.Load<SpriteFont>("Fonts/QuartzLarge");
            _mHudTrans = Content.Load<Texture2D>("Images/HUD/HUDTrans");

            _mLives = new Texture2D[6];
            _mLives[5] = Content.Load<Texture2D>("Images/Player/Laugh2");
            _mLives[4] = Content.Load<Texture2D>("Images/Player/Laugh");
            _mLives[3] = Content.Load<Texture2D>("Images/Player/Smile");
            _mLives[2] = Content.Load<Texture2D>("Images/Player/Surprise");
            _mLives[1] = Content.Load<Texture2D>("Images/Player/Worry");
            _mLives[0] = Content.Load<Texture2D>("Images/Player/Dead2");
        }
Beispiel #4
0
        public void Update(GameTime gameTime, ref GameStates gameState, ref Level level)
        {
            /* If the user hits up */
            if (_mControls.IsUpPressed(false))
            {
                /* If we are not on the first element already */
                if (_mCurrent > 0)
                {
                    GameSound.MenuSoundRollover.Play(GameSound.Volume, 0.0f, 0.0f);
                    /* Decrement current and change the images */
                    _mCurrent--;
                    for (var i = 0; i < NumOptions; i++)
                        _mItems[i] = _mUnselItems[i];
                    _mItems[_mCurrent] = _mSelItems[_mCurrent];
                }
            }
            /* If the user hits the down button */
            if (_mControls.IsDownPressed(false))
            {
                /* If we are on the last element in the menu */
                if (_mCurrent < NumOptions - 1)
                {
                    GameSound.MenuSoundRollover.Play(GameSound.Volume, 0.0f, 0.0f);
                    /* Increment current and update graphics */
                    _mCurrent++;
                    for (var i = 0; i < NumOptions; i++)
                        _mItems[i] = _mUnselItems[i];
                    _mItems[_mCurrent] = _mSelItems[_mCurrent];
                }
            }
            /* If the user selects a menu item */
            if (_mControls.IsAPressed(false) || _mControls.IsStartPressed(false))
            {
                GameSound.MenuSoundSelect.Play(GameSound.Volume, 0.0f, 0.0f);
                /* Continue */
                if (_mCurrent == 0)
                {
                    gameState = GameStates.NewLevelSelection;
                    level.Reset();
                    _mCurrent = 1;

                    for (var i = 0; i < NumOptions; i++)
                        _mItems[i] = _mUnselItems[i];
                    _mItems[_mCurrent] = _mSelItems[_mCurrent];
                }
                /* Back */
                else if (_mCurrent == 1)
                {
                    gameState = GameStates.Options;

                }
            }
            if (_mControls.IsBPressed(false) || _mControls.IsBackPressed(false))
                gameState = GameStates.Options;
        }
Beispiel #5
0
 public static Level MainMenuLevel(string filepath, IControlScheme controls, Viewport viewport, Rectangle region)
 {
     var main = new Level(filepath, controls, viewport);
     main.IsMainMenu = true;
     main._shouldAnimate = false;
     main.Size = new Vector2(region.Width * 4 / 3, region.Height * 4 / 3);
     main.StartingPoint = new Vector2(region.Width * 11 / 18, region.Height / 4);
     return main;
 }
Beispiel #6
0
        /// <summary>
        /// Handle any changes while on the level selection menu
        /// </summary>
        /// <param name="gameTime">Current time within the game</param>
        /// <param name="gameState">Current gamestate of the game</param>
        /// <param name="currentLevel">Current level of the game</param>
        public void Update(GameTime gameTime, ref GameStates gameState, ref Level currentLevel)
        {
            //Handle loading after loading screen has been drawn
            if (_mLoading == Loading)
            {
                _mLoading = None;
                if (currentLevel != null) currentLevel.Dispose();
                currentLevel = _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].Level;
                currentLevel.Load(_mContent);

                currentLevel.IdealTime = _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetGoal(LevelInfo.StarTypes.Time);
                currentLevel.CollectableCount = _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetGoal(LevelInfo.StarTypes.Collection);

                currentLevel.TimerStar = _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetStar(LevelInfo.StarTypes.Time);
                currentLevel.CollectionStar = _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetStar(LevelInfo.StarTypes.Collection);
                currentLevel.DeathStar = _mLevels[_mCurrentWorld * 6 + _mCurrentIndex].GetStar(LevelInfo.StarTypes.Death);

                gameState = GameStates.StartLevelSplash;
            }

            HandleAKey(ref gameState, ref currentLevel);
            HandleBKey(ref gameState);
            HandleDirectionKey();

            UpdateStarCount();
        }
Beispiel #7
0
        /// <summary>
        /// Handles when the A key is pressed
        /// </summary>
        private void HandleAKey(ref GameStates gameState, ref Level currentLevel)
        {
            if (_mControls.IsAPressed(false) || _mControls.IsStartPressed(false))
            {
                if (_mShowCongrats)
                { _mShowCongrats = false; return; }

                if (GameSound.Volume != 0)
                    GameSound.MenuSoundSelect.Play();

                if (_mLevels[_mCurrentWorld * 6 + _mCurrentIndex].Unlocked)
                    _mLoading = StartLoad;
            #if XBOX360
                else if (TrialMode)
                {
                    gameState = GameStates.WorldPurchaseScreen;
                }
            #endif

                //Handle level select
            }
        }
Beispiel #8
0
 /// <summary>
 /// Handle what happens when the player presses A for all options
 /// </summary>
 /// <param name="gameState">State of the game - Reference so that it can be changed for the main game class to handle</param>
 /// <param name="currentLevel">Current level in the main game - Reference so that this can be changed for the main game class to handle</param>
 private void HandleAPressed(ref GameStates gameState, ref Level currentLevel)
 {
     if (_mCurrentIndex == Back)
     {
         gameState = GameStates.MainMenu;
         _mCurrentPage = 0;
         _mCurrentIndex = 1;
     }
     else if (_mCurrentIndex == Previous)
     {
         if (--_mCurrentPage < 0) _mCurrentPage = 0;
     }
     else if (_mCurrentIndex == Next)
     {
         if (++_mCurrentPage == _mPageCount) _mCurrentPage = _mPageCount - 1;
     }
     else if(_mLevels[_mCurrentIndex - 1 + 12 * _mCurrentPage].Unlocked)
     {
         currentLevel = _mLevels[_mCurrentIndex - 1 + 12 * _mCurrentPage].Level;
         currentLevel.Load(_mContent);
         gameState = GameStates.InGame;
     }
 }
Beispiel #9
0
        /// <summary>
        /// Handle any changes while on the level selection menu
        /// </summary>
        /// <param name="gameTime">Current time within the game</param>
        /// <param name="gameState">Current gamestate of the game</param>
        /// <param name="currentLevel">Current level of the game</param>
        public void Update(GameTime gameTime, ref GameStates gameState, ref Level currentLevel)
        {
            HandleDirectionKeys();

            if(_mControls.IsAPressed(false)||_mControls.IsStartPressed(false))
                HandleAPressed(ref gameState,ref currentLevel);

            if (_mControls.IsBackPressed(false) || _mControls.IsBPressed(false))
            {
                gameState = GameStates.MainMenu;
                _mCurrentPage = 0;
                _mCurrentIndex = 1;
            }
        }