public RoundManager(Vector2 textPosition, Player player1, Player player2, GameContent content, SpriteBatch sb, FlyingObjectManager flyingObjMgr) { _textPosition = textPosition; _player1 = player1; _player2 = player2; _font = content.GameFont; _spriteBatch = sb; _flyingObjMgr = flyingObjMgr; }
public Player(Vector2 scorePosition, int playerNumber, GameContent content, Point gunCasePos, int viewWidth, int viewHeight, SpriteBatch sb, FlyingObjectManager flyingObjMgr, AudioManager audioManager) { _scoreTextPosition = scorePosition; _playerName = "Player " + playerNumber.ToString(); _playerNumber = playerNumber; _font = content.GameFont; _spriteBatch = sb; _gun = CreateGun(content, gunCasePos, viewWidth, viewHeight, flyingObjMgr, audioManager); _bridgeTex = content.Bridge; _bridgeRect = new Rectangle((int)_scoreTextPosition.X + 140, (int)_scoreTextPosition.Y, 40, 20); }
protected override void Initialize() { _spriteBatch = new SpriteBatch(GraphicsDevice); _isPaused = false; _gameContent = new GameContent(Content, GraphicsDevice); _audioManager = new AudioManager(_gameContent); int ht = _graphics.GraphicsDevice.Viewport.Height; int wt = _graphics.GraphicsDevice.Viewport.Width; float heightRatio = HEIGHT / (float)ht; float widthRatio = WIDTH / (float)wt; _backgroundRect = new Rectangle(0, 0, wt, ht); TargetBuildHelper targetHelper = new TargetBuildHelper(_gameContent, wt, ht, _spriteBatch); _flyingObjManager = new FlyingObjectManager(targetHelper, _spriteBatch, _gameContent.Particle, wt, ht, _audioManager); int gunCaseX = (int)(350 * widthRatio); int gunCaseY = (int)(600 * heightRatio); //black line is at 630 _gunCaseLeftRect = new Rectangle(gunCaseX, gunCaseY, 60, 30); _gunCaseRightRect = new Rectangle(wt - gunCaseX - 60, gunCaseY, 60, 30); _player1 = new Player(new Vector2(10, ht - 50), 1, _gameContent, new Point(gunCaseX, gunCaseY), wt, ht, _spriteBatch, _flyingObjManager, _audioManager); _player2 = new Player(new Vector2(wt - 190, ht - 50), 2, _gameContent, new Point(wt - gunCaseX - 60, gunCaseY), wt, ht, _spriteBatch, _flyingObjManager, _audioManager); _roundManager = new RoundManager(new Vector2(wt / 2 - 100, ht - 50), _player1, _player2, _gameContent, _spriteBatch, _flyingObjManager); _player1Animation = new AnimationManager(_player1, _gameContent, _spriteBatch, _roundManager, _audioManager); _player2Animation = new AnimationManager(_player2, _gameContent, _spriteBatch, _roundManager, _audioManager); _centeredPromptRect = new Rectangle(340, 200, 600, 300); _winMessage = new Rectangle(520, 570, _gameContent.Player1Won.Width, _gameContent.Player1Won.Height); _roundMessage = new Rectangle(520, 570, _gameContent.RoundStarting.Width, _gameContent.RoundStarting.Height); _audioManager.StartBackground(); base.Initialize(); }
private Gun CreateGun(GameContent content, Point gunCasePos, int viewWidth, int viewHeight, FlyingObjectManager flyingObjMgr, AudioManager audioManager) { if (_playerNumber == 1) { return new Gun(gunCasePos.X, gunCasePos.Y, content, Keys.A, Keys.D, Keys.S, this, viewWidth, viewHeight, _spriteBatch, flyingObjMgr, audioManager); } else { return new Gun(gunCasePos.X, gunCasePos.Y, content, Keys.NumPad4, Keys.NumPad6, Keys.NumPad5, this, viewWidth, viewHeight, _spriteBatch, flyingObjMgr, audioManager); } }