public void Add(AnimatedSprite powerup) { powerupList.Add(powerup); }
public static void collisionMade(AnimatedSprite powerup) { powerup.isActive = false; }
/// <summary> /// Used to collect and assign actions to the current powerup /// </summary> /// <param name="powerup"></param> /// <param name="player"></param> public static void inputManager(AnimatedSprite powerup, ref Player player) { // Check if the powerup is of type 'RepairPowerup' if (!powerup.isActive && powerup is RepairPowerup) RepairPowerup.sequence((RepairPowerup)powerup, ref player); }
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; } } } } }