Beispiel #1
0
        protected override void Update(GameTime gameTime)
        {
            newKeyboardState = Keyboard.GetState();
            newGamepadState  = GamePad.GetState(PlayerIndex.One);
            MouseState       = Mouse.GetState();
            if ((newKeyboardState.IsKeyDown(Keys.P) && oldKeyboardState.IsKeyUp(Keys.P)) ||
                newGamepadState.IsButtonDown(Buttons.Start) && oldGamepadState.IsButtonUp(Buttons.Start))
            {
                if (GameStatus == GameState.Pause)
                {
                    MediaPlayer.Resume();
                    GameStatus = GameState.Playing;
                    pauseSoundEffect.Play();
                }
                else if (GameStatus == GameState.Playing)
                {
                    MediaPlayer.Pause();
                    GameStatus = GameState.Pause;
                    pauseSoundEffect.Play();
                }
            }

            if ((newKeyboardState.IsKeyDown(Keys.M) && oldKeyboardState.IsKeyUp(Keys.M)))
            {
                MouseControl   = !MouseControl;
                IsMouseVisible = !IsMouseVisible;
            }

            Cheat.Update(oldKeyboardState, newKeyboardState);

            oldKeyboardState = newKeyboardState;
            oldGamepadState  = newGamepadState;
            if (GameStatus == GameState.Playing)
            {
                this.GameTime = gameTime;
                if (!DisableControl)
                {
                    KeyboardController.Update();
                    GamepadController.Update();
                    MouseController.Update();
                    CameraPointer.UpdateX(Mario.LocationX);
                }
                MarioSprite.Update(gameTime);
                World.Update(gameTime);
                Collision_Detection_and_Responses.CollisionHandling.Update(World.Level, this);
                PlayerStat.Update(gameTime);
                base.Update(gameTime);
            }
        }
Beispiel #2
0
        protected override void Initialize()
        {
            mainFont = Content.Load <SpriteFont>("MainFont");

            spriteBatch = new SpriteBatch(GraphicsDevice);
            SpriteFactory.Instance.SpriteBatch = spriteBatch;
            SpriteMachine.LoadTextures(Content);

            levelHolder  = new Queue();
            viewHolder   = new Queue();
            cameraHolder = new Queue();

            level = new Level();
            level.LoadLevelContent("Underworld.xml", this);
            levelHolder.Enqueue(level);
            camera = new Camera(spriteBatch, mainFont);
            cameraHolder.Enqueue(camera);
            view = new CameraManager((Mario)level.Player, camera);
            viewHolder.Enqueue(view);
            level = new Level();
            level.LoadLevelContent("UnderworldTwo.xml", this);
            levelHolder.Enqueue(level);
            camera = new Camera(spriteBatch, mainFont);
            cameraHolder.Enqueue(camera);
            view = new CameraManager((Mario)level.Player, camera);
            viewHolder.Enqueue(view);
            level = new Level();
            level.LoadLevelContent("UnderworldThree.xml", this);
            levelHolder.Enqueue(level);
            camera = new Camera(spriteBatch, mainFont);
            cameraHolder.Enqueue(camera);
            view = new CameraManager((Mario)level.Player, camera);
            viewHolder.Enqueue(view);

            controller = new KeyboardController();
            GlobalVariables.InitializeVar();

            level = new Level();
            level.LoadLevelContent("Overworld.xml", this);
            level.SetStaticPlayer();
            levelHolder.Enqueue(level);
            camera = new Camera(spriteBatch, mainFont);
            cameraHolder.Enqueue(camera);
            view = new CameraManager((Mario)level.Player, camera);
            viewHolder.Enqueue(view);
            controller.InitWASD(this, level);
            base.Initialize();
        }
Beispiel #3
0
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);

            Texture                 = Content.Load <Texture2D>("MarioSheet");
            BackgroundMusic         = Content.Load <Song>("backgroundMusic");
            pauseSoundEffect        = Content.Load <SoundEffect>("pauseSoundEffect");
            blackHole               = Content.Load <Texture2D>("blackholeSprite");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume      = 0.6f;
            SpriteFactory.LoadAllTextures(Content);
            Block = new BlockLogic(this);
            Mario.LoadContent(Content);
            World = new WorldManager(this);
            World.Load();
            PlayerStat = new PlayerStatistic(SpriteBatch, Content);

            KeyboardController = new KeyboardController();
            KeyboardController.RegisterCommand(Keys.Left, new MarioLookLeftCommand(this));
            KeyboardController.RegisterCommand(Keys.Right, new MarioLookRightCommand(this));
            KeyboardController.RegisterCommand(Keys.Down, new MarioLookDownCommand(this));
            KeyboardController.RegisterCommand(Keys.A, new MarioLookLeftCommand(this));
            KeyboardController.RegisterCommand(Keys.D, new MarioLookRightCommand(this));
            KeyboardController.RegisterCommand(Keys.S, new MarioLookDownCommand(this));
            KeyboardController.RegisterCommand(Keys.Z, new MarioJumpCommand(this));
            KeyboardController.RegisterCommand(Keys.Q, new QuitCommand(this));
            KeyboardController.RegisterCommand(Keys.R, new ResetCommand(this));
            KeyboardController.RegisterCommand(Keys.X, new MarioRunCommand(this));

            GamepadController = new GamepadController();
            GamepadController.RegisterCommand(Buttons.LeftThumbstickLeft, new MarioLookLeftCommand(this));
            GamepadController.RegisterCommand(Buttons.LeftThumbstickRight, new MarioLookRightCommand(this));
            GamepadController.RegisterCommand(Buttons.LeftThumbstickDown, new MarioLookDownCommand(this));
            GamepadController.RegisterCommand(Buttons.X, new ResetCommand(this));
            GamepadController.RegisterCommand(Buttons.A, new MarioJumpCommand(this));
            GamepadController.RegisterCommand(Buttons.B, new MarioRunCommand(this));

            MouseController = new MouseController();
            MouseController.RegisterCommand("LeftMouseClick", new MarioRunCommand(this));
            MouseController.RegisterCommand("RightMouseClick", new MarioJumpCommand(this));
        }