/// <summary> /// Destroy shot /// </summary> /// <param name="i">Shot index in shot array</param> protected void KillShot(PlayerIndex playerIndex, Shot shot, bool force, GameTime gameTime) { bool delete = false; bool easy = context.Options.Difficulty == Difficulty.Easy; Player player = context.GetPlayer(playerIndex); if (shot.EnemyFire == false) { if (shot.Weapon.GetType() == typeof(Megabomb)) { BombExplosion(shot, gameTime); } delete = true; } else { delete = (((shot.Destructable == true) && (shot.Hp <= 0)) || (shot.Destructable == false)); } if (delete || force || easy) { shot.TodoOnDeath(); if (force == false) { context.ParticleManager.MakeCircularExplosion(shot.Location, 10f, 10); int score = 0; if (easy == false) { score = (int)((float)shot.Points * context.ScoreMulti); } if (!( (context.Cheatcodes.IsInvincible) || (context.Cheatcodes.HasMaxPower) || (context.Cheatcodes.IsGiantMode))) { player.Score += score; } //Draw score if (context.Saver.OptionsData.ShowScore) { if (score > 0) { FlyingScores fs = new FlyingScores(shot.Location, "+" + score); flyScores.Add(fs); } } } if (!shotsToDelete.Contains(shot)) { shotsToDelete.Add(shot); } } }
/// <summary> /// Destroy enemy /// </summary> public bool KillEnemy(PlayerIndex playerIndex, BadGuy e, bool force, bool explosion, GameTime gameTime) { Player player = context.GetPlayer(playerIndex); if ((e.HP <= 0) || force) { //Score if (!force) { e.TodoOnDeath(); int score = (int)((float)e.Points * context.ScoreMulti); if (!( (context.Cheatcodes.IsInvincible) || (context.Cheatcodes.HasMaxPower) || (context.Cheatcodes.IsGiantMode))) { player.Score += score; } //Draw score if (context.Saver.OptionsData.ShowScore) { FlyingScores fs = new FlyingScores(e.Location, "+" + score); flyScores.Add(fs); } //Drop bonus if (e.BonusToDrop != null) { e.BonusToDrop.Location = Vectors.ConvertPointToVector2(e.DstRect.Center); context.Bonuses.Add(e.BonusToDrop); } enemieskilled++; } //Explosion if (explosion) { //context.ParticleManager.MakeExplosionWithoutQuake(Vectors.ConvertPointToVector2(e.DstRect.Center)); } if (e.Removable) { if (!enemiesToDelete.Contains(e)) { enemiesToDelete.Add(e); } } return true; } return false; }
/// <summary> /// Destroy bonus /// </summary> /// <param name="i">Bonus index in context.Bonuses array</param> /// <param name="get">Player get the bonus or it vanishes</param> protected void KillBonus(Bonus b, bool get, PlayerIndex playerIndex) { if (!(playerIndex == PlayerIndex.Four)) { Player player = context.GetPlayer(playerIndex); if (get) { int score = 200; //1000 pts per bonus if (b.Type == BonusTypes.Weapon) { if (b.WeaponToDrop.GetType() == player.Weapon.GetType()) { player.Weapon.UpgradeWeapon(); if (player.Weapon.UpgradeLevel == player.Weapon.MaxLevel) { //Get more points with full level score = 2000; } } else if (b.WeaponToDrop.GetType() == typeof(Megabomb)) { player.Bomb.UpgradeWeapon(); } else { int oldUpLevel = player.Weapon.UpgradeLevel; player.Weapon = b.WeaponToDrop; for (int i = 0; i < oldUpLevel; i++) { player.Weapon.UpgradeWeapon(); } //Level up bonus if player take a SMG bonus if (b.WeaponToDrop.GetType() == typeof(MachineGun)) { player.Weapon.UpgradeWeapon(); } context.Hud.ChangeWeaponIcon(player.Index, player.Weapon.GetType()); } } else { if (b.Type == BonusTypes.Life) { player.Lives++; } } score = (int)((float)score * context.ScoreMulti); //Display score if (context.Options.ShowScore) { FlyingScores fScore = new FlyingScores(b.Location, "+" + score.ToString()); this.flyScores.Add(fScore); } player.Score += score; } } context.Bonuses.Remove(b); }