public Player(Shooting shooting, int gameVerticalSize, int gameHorizontalSize, int spaceshipWidth, int spaceshipHeight) { if (gameVerticalSize <= 0) { throw new ArgumentException("Argument {0} must be positive value!", nameof(gameVerticalSize)); } if (gameHorizontalSize <= 0) { throw new ArgumentException("Argument {0} must be positive value!", nameof(gameHorizontalSize)); } if (spaceshipWidth <= 0) { throw new ArgumentException("Argument {0} must be positive value!", nameof(spaceshipWidth)); } if (spaceshipHeight <= 0) { throw new ArgumentException("Argument {0} must be positive value!", nameof(spaceshipHeight)); } _shooting = shooting ?? throw new ArgumentNullException(nameof(shooting)); PositionX = gameVerticalSize / 2; _gameVerticalSize = gameVerticalSize; _spaceshipHeight = spaceshipHeight; _gameHorizontalSize = gameHorizontalSize; _spaceshipWidth = spaceshipWidth; }
/// <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); // TODO: use this.Content to load your game content here _backgroundTexture = Content.Load <Texture2D>(@"Textures\space-tiled-background-256x256"); _playerTexture = Content.Load <Texture2D>(@"Textures\SpaceShipSmall"); _bulletTexture = Content.Load <Texture2D>(@"Textures\Bullet"); _enemyTexture = Content.Load <Texture2D>(@"Textures\enemy"); _bulletFactory = new BulletFactory(_bulletTexture.Width, _bulletTexture.Height, _graphics.PreferredBackBufferHeight); _shooting = new Shooting(_bulletFactory); _player = new Player(_shooting, _graphics.PreferredBackBufferWidth - _playerTexture.Width, _graphics.PreferredBackBufferHeight, _playerTexture.Width, _playerTexture.Height); _enemy = new Enemy(_graphics.PreferredBackBufferHeight, _graphics.PreferredBackBufferWidth, _enemyTexture.Width, _enemyTexture.Height); _laserSound = Content.Load <SoundEffect>(@"SoundEffects\laser"); }