/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here var menu = new MainMenu(this); this.Components.Add(menu); var pitch = new Pitch(this); this.Components.Add(pitch); GameMode = AirHockey.GameMode.Menu; PlayerTouchBinder binder = new PlayerTouchBinder(); _player1 = new Player(this, PlayerNumber.Player1, binder); _player2 = new Player(this, PlayerNumber.Player2, binder); _puck = new Puck(this); var collideables = new Collection<ICollidable>(); collideables.Add(_player1); collideables.Add(_player2); collideables.Add(_puck); _collisionManager = new CollisionManager(this, collideables); this.Components.Add(_player1); this.Components.Add(_player2); this.Components.Add(_puck); _player1ScorePosition = new Vector2(GraphicsDevice.Viewport.Width / 2 - 10, 0); _player2ScorePosition = new Vector2(GraphicsDevice.Viewport.Width / 2 + 10, 0); _messageP1Position = new Vector2(GraphicsDevice.Viewport.Width / 2 - 100, GraphicsDevice.Viewport.Height / 2); _messageP2Position = new Vector2(GraphicsDevice.Viewport.Width / 2 + 100, GraphicsDevice.Viewport.Height / 2); InitialiseToNewGameState(); base.Initialize(); }
public Player(Game game, PlayerNumber playerNumber, PlayerTouchBinder touchBinder) : base(game) { _playerNumber = playerNumber; _touchBinder = touchBinder; }