Esempio n. 1
0
 public MarioEntity(Vector2 location, EventSoundEffects sounds)
 {
     Sounds          = sounds;
     WonGame         = false;
     Factory         = new MarioFactory();
     PowerState      = new MarioStandardState(this);
     ActionState     = new Idling(this);
     Facing          = true;
     Sprite          = Factory.MarioSprite(PowerState, ActionState, Facing, location);
     SpritePosition  = location;
     SpriteVelocity  = new Vector2(0, 0);
     EntityCollision = new MarioCollision(this);
     Live            = 3;
 }
Esempio n. 2
0
        public void ResetContent()
        {
            spriteBatch = new SpriteBatch(game.GraphicsDevice);
            sprites = new List<ISprite>();
            movSprites = new List<Sprite>();
            ssprites = new List<Sprite>();
            victoryScreen = new VictoryScreen(game);
            gameOverScreen = new GameOverScreen(game);

            mario = new Mario(game, this);
            // Create a camera instance and limit its moving range
            _camera = new Camera(game.GraphicsDevice.Viewport);

            // Create 9 layers with parallax ranging from 0% to 100% (only horizontal)
            _layers = new Layer[9];
            hud = new HUD(game, mario);
            parser = new Parser(game);
            if (Map == 1)
            {
                parser.Parse(mario, sprites, movSprites, ssprites, _layers, _camera, "map.xml");

            }
            else if (Map == 2)
            {
                parser.Parse(mario, sprites, movSprites, ssprites, _layers, _camera, "map2.xml");
            }
            else if (Map == 3)
            {
                parser.Parse(mario, sprites, movSprites, ssprites, _layers, _camera, "map3.xml");
            }

            isPaused = false;
            isMuted = false;
            victory = false;
            defeat = false;
            SoundEffect effect = game.Content.Load<SoundEffect>("OriginalThemeSong");
            instance = effect.CreateInstance();
            instance.IsLooped = true;
            instance.Play();

            quad = new Quadtree(0, new CollisionBox(0, 0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height));
            secquad = new Quadtree(0, new CollisionBox(0, 0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height));

            collision = new MarioCollision(mario, this);
            sec_collision = new OtherCollision(mario, this, secquad);
            ////////////////////////////

            //this.Mute();
            ////////////////////////////////

            screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;

            Font1 = game.Content.Load<SpriteFont>("MarioPoints");
            keyboardCont = new KeyboardController(game, mario);
            gamePadCont = new GamePadController(game, mario);
            // TODO: use this.Content to load your game content here
        }
Esempio n. 3
0
        public void ChooseContent()
        {
            sprites = new List<ISprite>();
            movSprites = new List<Sprite>();
            ssprites = new List<Sprite>();
            // Create a camera instance and limit its moving range
            _camera = new Camera(game.GraphicsDevice.Viewport) { Limits = new Rectangle(0, 0, 4000, 600) };

            // Create 9 layers with parallax ranging from 0% to 100% (only horizontal)
            _layers = new Layer[9];
            hud = new HUD(game, mario);
            parser = new Parser(game);
            if (Map == 1)
            {
                parser.Parse(mario, sprites, movSprites, ssprites, _layers, _camera, "map.xml");

            }
            else if (Map == 2)
            {
                parser.Parse(mario, sprites, movSprites, ssprites, _layers, _camera, "map2.xml");
            }
            else if (Map == 3)
            {
                parser.Parse(mario, sprites, movSprites, ssprites, _layers, _camera, "map3.xml");
            }
            quad = new Quadtree(0, new CollisionBox(0, 0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height));
            secquad = new Quadtree(0, new CollisionBox(0, 0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height));

            collision = new MarioCollision(mario, this);
            sec_collision = new OtherCollision(mario, this, secquad);
        }
Esempio n. 4
0
        public void Update(float elapsed, GraphicsDeviceManager graphics, MarioCollision collision)
        {
            if (currentState == dead)
            {
                if (buffer < 1000)
                {
                    buffer += elapsed;
                }
                else
                {
                    buffer = 0;
                    if (lives > 0)
                    {
                        Vector2 latestCheck = game.scene.FindLatestCheckpoint();
                        int life = lives;
                        game.ResetCommand();//Why isn't the theme music playing?
                        game.scene.mario.MarioVec = latestCheck;
                        game.scene.mario.Lives = life;
                    }
                    else
                    {
                        game.scene.Mute();
                        sounds.PlayGameOver();
                        game.GameoverCommand();
                    }
                }

            }
            else
            {
                gravity = scene.Gravity;
                this.elapsed = elapsed;
                if (time > 1000)
                {
                    invincible = false;
                }
                if (invincible == true)
                {
                    time += elapsed;
                }

                marioVel += marioAccel * collision.CollisionTime / 5;
                marioVel = Vector2.Clamp(marioVel, new Vector2(-20, -40), new Vector2(20, 40));
                marioVec += marioVel * collision.CollisionTime / 5;

            }

                actionStateFactor = currentState.Factor();
                powerupStateFactor = powerupState.Factor();
                currentSprite = (MarioSprite)MarioFactory.MakeProduct(powerupStateFactor + actionStateFactor);
                currentSprite.CollisionBox.Physics(new Vector2(marioVec.X, marioVec.Y - CollisionBox.Height), marioVel, marioAccel);
                currentSprite.Update(elapsed, direction);
                currentState.Update(graphics, elapsed);

                //if (!isGrounded && currentState != jump)
                //{
                //    this.ToFall();
                //}
                Console.WriteLine(MarioVel);
                //////////////////////////////////////
                CheckBorders();
        }