public override void Notify() { this.pAlien = (Alien)this.pSubject.pObjA; Player pPlayer = GameStateManager.GetGame().GetPlayer(playerName); // Add points pPlayer.AddPoints(pAlien.GetPoints()); // Update Points display Font pPlayer1ScoreFont = FontManager.Find(pointsFont); Debug.Assert(pPlayer1ScoreFont != null); pPlayer1ScoreFont.UpdateMessage(pPlayer.GetPoints().ToString("D4")); }
/// <summary> /// Checks for collisions between all currently active entitites /// </summary> private void CheckCollisions() { foreach (Enemy enemy in enemySpawner.Enemies) { // Check for collision with Bullets foreach (Shot shot in Player.Shots) { if (IsColliding(shot, enemy)) { enemy.shouldRemove = true; shot.shouldRemove = true; Player.AddPoints(5); } } // Check for collisions with the Player if (IsColliding(enemy, Player) && !enemy.isDisabled && !Player.InvincibleBoosterActive) { enemy.shouldRemove = true; Player.RemoveHeart(); if (Player.AvailableHearts == 0) { Game.CurrentGameState = GameState.GameOver; } } // Check for collision between enemies foreach (Enemy otherEnemy in enemySpawner.Enemies) { if (IsColliding(enemy, otherEnemy)) { enemy.HandleEnemyCollision(otherEnemy); otherEnemy.HandleEnemyCollision(enemy); } } } foreach (Booster booster in boosterSpawner.Boosters) { if (IsColliding(booster, Player)) { Player.ConsumeBooster(booster); booster.shouldRemove = true; } } }