public void Initialize() { //Clear global arrays in case we restart the game Defines.playersGestures.Clear(); Defines.playerFusionTriggered.Clear(); Defines.clientBounds = ScreenManager.Game.Window.ClientBounds; //Set up the frames counter ScreenManager.Game.Components.Add(new FPSComponent(ScreenManager.Game)); // Initialize an instance of the high score screen //Set up the sprite managers enemySpriteManager = new SpriteManager(ScreenManager.Game); //Set up the players //TODO: Only signed in players should be added. playerManager = new PlayerManager(ScreenManager.Game); // Set up powerup manager powerupManager = new PowerupManager(ScreenManager.Game); // Set up the charge Bar chargeBar = new ChargeBar(ScreenManager.Game); //Set up the particle system manager. Defines.particleManager = new ParticleManager(ScreenManager.Game); }
/// <summary> /// Initialize the game, after the ScreenManager is set, but not every time /// the graphics are reloaded. /// </summary> public void Initialize() { Defines.playersGestures.Clear(); Defines.playerFusionTriggered.Clear(); Defines.clientBounds = ScreenManager.Game.Window.ClientBounds; //Set up the frames counter ScreenManager.Game.Components.Add(new FPSComponent(ScreenManager.Game)); //Set up the bloom post-process effect bloomComponent = new BloomComponent(ScreenManager.Game); //bloomComponent.Visible = false; ScreenManager.Game.Components.Add(bloomComponent); // Initialize an instance of the high score screen hss = new HighScoreScreen(ScreenManager.Game); //Set up the console writer. //consoleComponent = new ConsoleComponent(clientBounds); //Set up the sprite managers //playerSpriteManager = new SpriteManagerComponent(this); enemySpriteManager = new SpriteManager(ScreenManager.Game); //Set up the players //TODO: Only signed in players should be added. playerManager = new PlayerManager(ScreenManager.Game); // Check whether if two controllers are currently active (Comment to default to two-player mode) // TODO: Add additional check for if the game is currently running or not //if (!GamePad.GetState(PlayerIndex.Two).IsConnected) // twoPlayerMode = false; // Set up powerup manager powerupManager = new PowerupManager(ScreenManager.Game); // Set up the charge Bar chargeBar = new ChargeBar(ScreenManager.Game); // Set up repair powerup // repairPowerup = new RepairPowerup(ScreenManager.Game); //Set up the particle system manager. Defines.particleManager = new ParticleManager(ScreenManager.Game); gameOver = false; }
private void checkCollision(Player currentPlayer) { //Check for collisions for (int j = 0; j < currentPlayer.shipManager.shipList.Count; j++) { //Cache current player Gryffon _currentShip = currentPlayer.shipManager.shipList[j]; // When ships can become damaged, uncomment line below // if (Collision.PlayerWithPowerup(_currentShip, repairPowerup) && _currentShip.health == (int)Gryffon.HealthStateValues.DAMAGED) //if (Collision.PlayerWithPowerup(_currentShip, repairPowerup)) // RepairPowerup.sequence(); int _playerNumBullets = _currentShip.bulletList.Count; for (int i = 0; i < _playerNumBullets; i++) { //Cache bullet PlayerBullet _currentBullet = _currentShip.bulletList[i]; if (_currentBullet.isActive) { for (int k = 0; k < NUM_ENEMIES; k++) { //Cache enemy Pawn _currentPawn = (Pawn)enemySpriteManager.spriteList[k]; if (_currentPawn.isAlive && Collision.PlayerBulletWithEnemy(_currentBullet, _currentPawn)) { _currentPawn.DecreaseHealth(_currentBullet.damage); _currentBullet.isActive = false; currentPlayer.score += _currentPawn.pointValue; //Pawn is no longer able to take damage _currentPawn.isAlive = false; // Add some charge to the charge bar ChargeBar.addCharge(); break; } } } } } }
protected override void Initialize() { Defines.clientBounds = this.Window.ClientBounds; //Set up the frames counter this.Components.Add(new FPSComponent(this)); //Set up the bloom post-process effect bloomComponent = new BloomComponent(this); bloomComponent.Visible = false; this.Components.Add(bloomComponent); //Set up the console writer. //consoleComponent = new ConsoleComponent(clientBounds); //Set up the sprite managers //playerSpriteManager = new SpriteManagerComponent(this); enemySpriteManager = new SpriteManager(this); //Set up the players //TODO: Only signed in players should be added. playerManager = new PlayerManager(this); // Check whether if two controllers are currently active (Comment to default to two-player mode) // TODO: Add additional check for if the game is currently running or not //if (!GamePad.GetState(PlayerIndex.Two).IsConnected) // twoPlayerMode = false; // Set up the charge Bar chargeBar = new ChargeBar(this); // Set up repair powerup repairPowerup = new RepairPowerup(this); //Set up the particle system manager. particleManager = new ParticleManager(this); base.Initialize(); }
private void checkCollision(Player currentPlayer) { //Check for collisions for (int j = 0; j < currentPlayer.shipManager.shipList.Count; j++) { //Cache current player Gryffon _currentShip = currentPlayer.shipManager.shipList[j]; for (int i = 0; i < powerupManager.powerupList.Count; i++) { // cache powerup AnimatedSprite _powerup = powerupManager.powerupList[i]; if (Collision.PlayerWithPowerup(_currentShip, _powerup)) { PowerupManager.collisionMade(_powerup); } PowerupManager.inputManager(_powerup, ref currentPlayer); } int _playerNumBullets = _currentShip.bulletList.Count; for (int i = 0; i < _playerNumBullets; i++) { //Cache bullet PlayerBullet _currentBullet = _currentShip.bulletList[i]; if (_currentBullet.isActive) { for (int k = 0; k < NUM_ENEMIES; k++) { //Cache enemy Pawn _currentPawn = (Pawn)enemySpriteManager.spriteList[k]; if (_currentPawn.isAlive && Collision.PlayerBulletWithEnemy(_currentBullet, _currentPawn)) { _currentPawn.DecreaseHealth(_currentBullet.damage); _currentBullet.isActive = false; currentPlayer.score += _currentPawn.pointValue; //Pawn is no longer able to take damage _currentPawn.isAlive = false; // Add some charge to the charge bar ChargeBar.addCharge(); break; } } } } } //Check for collisions between particles and enemies List <ParticleSystem> pSystems = Defines.particleManager.GetCollidableParticleSystems(); for (int i = 0; i < pSystems.Count; i++) { for (int k = 0; k < NUM_ENEMIES; k++) { //Cache enemy Pawn _currentPawn = (Pawn)enemySpriteManager.spriteList[k]; //Collision between enemy and particle system if (Collision.EnemyWithParticleSystem(pSystems[i], _currentPawn)) { _currentPawn.DecreaseHealth(pSystems[i].damage); currentPlayer.score += _currentPawn.pointValue; //Pawn is no longer able to take damage _currentPawn.isAlive = false; // Add some charge to the charge bar ChargeBar.addCharge(); } //Collision between enemy bullets and particle system for (int b = 0; b < _currentPawn.bullets.Count; b++) { EnemyBullet _curBullet = _currentPawn.bullets[b]; if (Collision.EnemyWithParticleSystem(pSystems[i], _curBullet)) { _curBullet.isActive = false; } } } } }