Esempio n. 1
0
 public OtherCollision(Mario mario, Scene scene, Quadtree quadtree)
 {
     this.scene = scene;
     this.mario = mario;
     this.sprites = scene.SSprites;
     this.movsprites = scene.MovSprites;
     this.quad = quadtree;
     this.sounds = new SoundMachine(scene.Game);
     this.nearObjects = new List<Sprite>();
 }
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
        /*
         * Splits the node into 4 subnodes
         */
        private void Split()
        {
            int subWidth = (int)(bounds.Width / 2);
            int subHeight = (int)(bounds.Height / 2);
            int x = (int)bounds.X;
            int y = (int)bounds.Y;

            nodes[0] = new Quadtree(level + 1, new CollisionBox(x + subWidth, y, subWidth, subHeight));
            nodes[1] = new Quadtree(level + 1, new CollisionBox(x, y, subWidth, subHeight));
            nodes[2] = new Quadtree(level + 1, new CollisionBox(x, y + subHeight, subWidth, subHeight));
            nodes[3] = new Quadtree(level + 1, new CollisionBox(x + subWidth, y + subHeight, subWidth, subHeight));
        }