/// <summary> /// Notifies the specified subject. /// </summary> /// <param name="subject">The subject.</param> public void Notify(ObservedSubject subject) { if (subject is UI) { if ((subject as UI).NumberOfLife != this.numberOfLifes) { this.numberOfLifes = (subject as UI).NumberOfLife; } } else if (subject is Bullet) { numberOfLifes -= 1; this.NotifyAllObservers(); } else if (subject is Bonus) { if ((subject as Bonus).Type != BonusType.none) { if ((subject as Bonus).Type == BonusType.invincible) { if ((subject as Bonus).BonusTime > 0) { this.invincible = true; } else { this.invincible = false; } } Game1.bonusList.Remove(subject as Bonus); currentBonus = (subject as Bonus); } } }
/// <summary> /// Notifies the specified subject. /// </summary> /// <param name="subject">The subject.</param> public void Notify(ObservedSubject subject) { if (subject is Asteroid) { Asteroid ast = subject as Asteroid; if (ast.Size == AsteroidSize.large) { UpdateScore(20); } else if (ast.Size == AsteroidSize.medium) { UpdateScore(50); } else { UpdateScore(100); } } else if (subject is EnemyShip && (subject as EnemyShip).IsAlive == false) { EnemyShip ship = subject as EnemyShip; if (ship.Type == TypeShip.bigBossShip) { UpdateScore(200); } } else if (subject is PlayerShip) { if (!(subject as PlayerShip).IsAlive) { UpdateLife(PlayerShip.GetInstance().NumberOfLifes); } else if ((subject as PlayerShip).NumberOfLifes != this.numberOfLife) { this.numberOfLife = PlayerShip.GetInstance().NumberOfLifes; } else if (subject is Bonus) { if ((subject as Bonus).Type == BonusType.invincible) { bonusMessage = "Invincible"; } } } else if (subject is Bonus) { if ((subject as Bonus).Type == BonusType.doublePoints) { if ((subject as Bonus).BonusTime > 0) { bonusMessage = "Double Points"; scoreMultiplier = 2; } else { bonusMessage = ""; scoreMultiplier = 1; } } else if ((subject as Bonus).Type == BonusType.invincible) { if ((subject as Bonus).BonusTime > 0) { bonusMessage = "Invincible"; } else { bonusMessage = ""; } } else if ((subject as Bonus).Type == BonusType.extraPoints) { if ((subject as Bonus).BonusTime > 0) { score += 1000; } } else if ((subject as Bonus).Type == BonusType.slowDown) { if ((subject as Bonus).BonusTime > 0) { bonusMessage = "SlowMotio"; } else { bonusMessage = ""; } } else if ((subject as Bonus).Type == BonusType.none) { if ((subject as Bonus).BonusTime == -1) { scoreMultiplier = 1; bonusMessage = ""; } } } }
/// <summary> /// Notifies the specified subject. /// </summary> /// <param name="subject">The subject.</param> public void Notify(ObservedSubject subject) { if (subject is UI) { if ((subject as UI).NumberOfLife != this.numberOfLifes) { this.numberOfLifes = (subject as UI).NumberOfLife; } } else if (subject is Bullet) { numberOfLifes -= 1; this.NotifyAllObservers(); } else if (subject is Bonus) { if ((subject as Bonus).Type != BonusType.none) { if ((subject as Bonus).Type == BonusType.invincible) { if ((subject as Bonus).BonusTime > 0) { this.invincible = true; } else { this.invincible = false; } } Game1.bonusList.Remove(subject as Bonus); currentBonus = (subject as Bonus); } } }
/// <summary> /// Notifies the specified subject. /// </summary> /// <param name="subject">The subject.</param> public void Notify(ObservedSubject subject) { if (subject is Asteroid) { Asteroid ast = subject as Asteroid; if (ast.Size == AsteroidSize.large) { UpdateScore(20); } else if (ast.Size == AsteroidSize.medium) { UpdateScore(50); } else { UpdateScore(100); } } else if (subject is EnemyShip && (subject as EnemyShip).IsAlive == false) { EnemyShip ship = subject as EnemyShip; if (ship.Type == TypeShip.bigBossShip) { UpdateScore(200); } } else if (subject is PlayerShip) { if (!(subject as PlayerShip).IsAlive) { UpdateLife(PlayerShip.GetInstance().NumberOfLifes); } else if ((subject as PlayerShip).NumberOfLifes != this.numberOfLife) { this.numberOfLife = PlayerShip.GetInstance().NumberOfLifes; } else if (subject is Bonus) { if ((subject as Bonus).Type == BonusType.invincible) { bonusMessage = "Invincible"; } } } else if (subject is Bonus) { if ((subject as Bonus).Type == BonusType.doublePoints) { if ((subject as Bonus).BonusTime > 0) { bonusMessage = "Double Points"; scoreMultiplier = 2; } else { bonusMessage = ""; scoreMultiplier = 1; } } else if ((subject as Bonus).Type == BonusType.invincible) { if ((subject as Bonus).BonusTime > 0) { bonusMessage = "Invincible"; } else { bonusMessage = ""; } } else if ((subject as Bonus).Type == BonusType.extraPoints) { if ((subject as Bonus).BonusTime > 0) { score += 1000; } } else if ((subject as Bonus).Type == BonusType.slowDown) { if ((subject as Bonus).BonusTime > 0) { bonusMessage = "SlowMotio"; } else { bonusMessage = ""; } } else if ((subject as Bonus).Type == BonusType.none) { if ((subject as Bonus).BonusTime == -1) { scoreMultiplier = 1; bonusMessage = ""; } } } }