Пример #1
0
 public CollisionManager(PlayerShip playerShip, ShotManager shotManager, EnemyManager enemyManager, ExplosionManager explosionManager, AsteroidManager asteroidManager)
 {
     this.playerShip       = playerShip;
     this.shotManager      = shotManager;
     this.enemyManager     = enemyManager;
     this.explosionManager = explosionManager;
     this.asteroidManager  = asteroidManager;
 }
Пример #2
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, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            titleScreen = new Sprite(Content.Load <Texture2D>("title"), Vector2.Zero, graphics.GraphicsDevice.Viewport.Bounds, 2, 2, 8);
            //background = new Sprite(Content.Load<Texture2D>("spacebackground"), Vector2.Zero, graphics.GraphicsDevice.Viewport.Bounds);
            statField.LoadContent(Content);

            pauseScreen    = new Sprite(Content.Load <Texture2D>("paused"), Vector2.Zero, graphics.GraphicsDevice.Viewport.Bounds);
            gameOverScreen = new Sprite(Content.Load <Texture2D>("gameOver"), Vector2.Zero, graphics.GraphicsDevice.Viewport.Bounds);

            soundManager = new SoundManager(Content);

            var shipTexture     = Content.Load <Texture2D>("playership");
            var yPositionOfShip = graphics.GraphicsDevice.Viewport.Height - shipTexture.Height - 10;
            var xPositionOfShip = (graphics.GraphicsDevice.Viewport.Width / 2) - (shipTexture.Width / 2);
            var playerBound     = new Rectangle(0, graphics.GraphicsDevice.Viewport.Height - 200,
                                                graphics.GraphicsDevice.Viewport.Width, 200);

            shotManager = new ShotManager(Content.Load <Texture2D>("playershipshot"), Content.Load <Texture2D>("enemyshot"), graphics.GraphicsDevice.Viewport.Bounds, soundManager);

            playerShip = new PlayerShip(shipTexture, new Vector2(xPositionOfShip, yPositionOfShip), playerBound, shotManager);

            enemyManager = new EnemyManager(Content.Load <Texture2D>("alien"), graphics.GraphicsDevice.Viewport.Bounds, shotManager);

            explosionManager = new ExplosionManager(Content.Load <Texture2D>("explosion1"), graphics.GraphicsDevice.Viewport.Bounds, soundManager);

            asteroidManager = new AsteroidManager(Content.Load <Texture2D>("rocks_rotated_small"), graphics.GraphicsDevice.Viewport.Bounds);

            collisionManager = new CollisionManager(playerShip, shotManager, enemyManager, explosionManager, asteroidManager);

            gameFont      = Content.Load <SpriteFont>("GameFont");
            statusManager = new StatusManager(gameFont, graphics.GraphicsDevice.Viewport.Bounds, enemyManager, shipTexture)
            {
                Lives = 3,
                Score = 0
            };

            soundManager.PlayBackgroundMusic();
        }