Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);


            // Load texture for the SpriteSheet.
            mixedSprites = Content.Load <Texture2D>(@"Images/SpriteSheet");
            // Load texture for the Menu SpriteSheet.
            menuSprites = Content.Load <Texture2D>(@"Images/MenuSprites");
            // Load background texture.
            background = Content.Load <Texture2D>(@"Images/Background");
            // Load tutorial texture.
            tutorialTexture = Content.Load <Texture2D>(@"Images/Tutorial");

            // Create the different menus with their respective classes.
            mainMenu = new MainMenu(menuSprites);
            credits  = new Credits(menuSprites, Font);
            tutorial = new Tutorial(menuSprites, tutorialTexture);
            paused   = new Paused(menuSprites);
            gameOver = new GameOver(menuSprites);

            // Set screeBounds to the game windows size.
            Rectangle screenBounds = new Rectangle(0, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height);

            // Load firing sound.
            firingSound = Content.Load <SoundEffect>(@"Sounds/firing");
            // Load infected sound.
            infectedSound = Content.Load <SoundEffect>(@"Sounds/roar");
            // Load background music
            music = Content.Load <SoundEffect>(@"Sounds/sb_soulsearcher");
            // Create an instance of the music and loop it.
            musicInstance          = music.CreateInstance();
            musicInstance.IsLooped = true;
            // Load rain sound
            rainSound = Content.Load <SoundEffect>(@"Sounds/rain");
            // Create an instance of the rain and loop it.
            rainSoundInstance          = rainSound.CreateInstance();
            rainSoundInstance.IsLooped = true;
            // Load ambient firing sounds.
            ambientFiringSound = Content.Load <SoundEffect>(@"Sounds/ambient_firing");
            // Create an instance of ambient firing, loop it and lower its volume a bit.
            ambientFiringSoundInstance          = ambientFiringSound.CreateInstance();
            ambientFiringSoundInstance.IsLooped = true;
            ambientFiringSoundInstance.Volume   = 0.5f;

            // Create the player.
            playerSprite = new PlayerManager(mixedSprites, 1, 87, 141, screenBounds, firingSound);

            // Create the ally.
            ally = new Ally(mixedSprites, new Rectangle(0, 194, 380, 168), new Rectangle(381, 194, 81, 108));

            // Load font the font.
            Font = Content.Load <SpriteFont>(@"Fonts\pressstart");

            // Create the rain.
            rain = new Rain(
                Window.ClientBounds.Width,
                Window.ClientBounds.Height,
                200,
                new Vector2(0, 500f),
                mixedSprites,
                new Rectangle(64, 490, 6, 24));

            // Create the enemy manager.
            enemyManager = new EnemyManager(mixedSprites, new Rectangle(0, 363, 93, 126), 8, playerSprite, screenBounds, infectedSound);
            // Create the enemies' explosion manager.
            enemyExplosionManager = new ExplosionManager(
                mixedSprites,
                new Rectangle(0, 363, 93, 126),
                new Rectangle(372, 363, 93, 126),
                1,
                1,
                new Rectangle(28, 516, 6, 6),
                20,
                30,
                24,
                48);
            // Create the player's explosion manager.
            playerExplosionManager = new ExplosionManager(
                mixedSprites,
                new Rectangle(0, 0, 87, 141),
                new Rectangle(349, 0, 87, 141),
                1,
                1,
                new Rectangle(28, 523, 6, 6),
                20,
                30,
                24,
                48);

            // Create the collision manager.
            collisionsManager = new CollisionsManager(playerSprite, playerExplosionManager, ally, enemyExplosionManager, enemyManager);
            // Create the score manager.
            scoreManager = new ScoreManager();
            // Create the input manager.
            inputManager = new InputManager(mixedSprites, new Rectangle(381, 303, 48, 48));

            // Set the window title.
            this.Window.Title = "PROJECT LAST RAIN";
        }
Ejemplo n.º 2
0
 // Constructor
 public CollisionsManager(PlayerManager playerSprite, ExplosionManager playerExplosionManager, Ally ally, ExplosionManager enemyExplosionManager, EnemyManager enemyManager)
 {
     // Update the internal variables to the ones supplied by constructor.
     this.playerManager          = playerSprite;
     this.playerExplosionManager = playerExplosionManager;
     this.enemyExplosionManager  = enemyExplosionManager;
     this.enemyManager           = enemyManager;
     this.ally = ally;
 }