Example #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Set up HUD
            hud.LoadFont(Content);
            hud.setWorld(TheLevelNumberVariableWithADescriptiveNameThatIsWithTheOtherVariables);
            hud.setTotalLevel(LevelFile.Length);

            //Load first level
            List <String[]> map = LevelLoader.Instance.loadLevel(this.LevelChanger());

            //Load all factory resources
            SoundEffectFactory.Instance.LoadAllSoundEffects(Content);
            MarioFactory.Instance.LoadAllTextures(Content);
            ItemFactory.Instance.LoadAllTextures(Content);
            HiddenLevelItemFactory.Instance.LoadAllTextures(Content);
            ObjectFactory.Instance.LoadAllTextures(Content);
            EnemyFactory.Instance.LoadAllTextures(Content);
            ProjectileFactory.Instance.LoadAllTextures(Content);
            LevelFactory.Instance.LoadAllTextures(Content);
            ZombieFactory.Instance.LoadAllTextures(Content);
            NightmareEnemyFactory.Instance.LoadAllTextures(Content);

            //Setup music
            marioTheme              = Content.Load <Song>("smbMarioGameTheme");
            nightmareTheme          = Content.Load <Song>("nightmareHalloweenTheme");
            nightmareGameOver       = Content.Load <Song>("nightmareSawThemeGameOver");
            nightmareThemeIsStarted = false;

            //Prep first menu
            MediaPlayer.IsRepeating = true;
            menuItems = LevelFactory.Instance.GetMenuItems();
            bg        = new Scrolling(Content, new Rectangle(0, 0, 800, 512));

            Character = new Mario(marioStartPosition, this);
            castle    = LevelFactory.Instance.CreateCastle(BackgroundCreator.LoadCastle());

            //Background elements//
            background = Content.Load <Texture2D>("background");
        }
Example #2
0
        public MarioCastleCollisionResponse(IMario m, Castle c, Game1 g)
        {
            bool collision = false;

            if ((m.Position.X > c.Position.X + 78) && (m.Position.X < c.Position.X + 82))
            {
                collision = true;
            }
            if (collision)
            {
                m.Movement.FlagLand(); // set the y speed to 0
                if (m.CurrentState is SmallMarioRightWalkingState)
                {
                    m.CurrentState = MarioFactory.Instance.CreateSmallRightStandingState(m);
                }
                else if (m.CurrentState is BigRightWalkingState)
                {
                    m.CurrentState = MarioFactory.Instance.CreateBigRightStandingState(m);
                }
                else if (m.CurrentState is FireMarioRightWalkingState)
                {
                    m.CurrentState = MarioFactory.Instance.CreateFireRightStandingState(m);
                }
            }
            else
            {
                if (m.ReachFlag && (m.CurrentState is SmallMarioRightWalkingState || m.CurrentState is BigRightWalkingState || m.CurrentState is FireMarioRightWalkingState))
                {
                    m.Movement.MoveRight();
                }
            }
            if (collision && (m.Position.X >= c.Position.X + c.Texture.Width / 3))
            {
                g.IncrementLevel();
                g.LevelClear();
            }
        }