/// <summary> /// Megabomb explosion ! Damage all context.Enemies on screen /// </summary> /// <param name="shot"></param> protected void BombExplosion(Shot shot, GameTime gameTime) { context.InputManager.SetVibrations(((Player)shot.Weapon.Owner).Index, new Vector2(1.0f, 1.0f)); for (int i = 0; i < context.Enemies.Count; i++) { if (context.Enemies[i].IsOnScreen) { context.Enemies[i].TodoOnBombing((int)((float)shot.Weapon.Damage * context.DamageMulti)); } } //Megabomb destroy enemy context.Shots for (int i = 0; i < context.Shots.Count; i++) { if (context.Shots[i].EnemyFire) { if (context.Shots[i].Destructable) { context.Shots[i].Hp = -1; } KillShot(context.Player1.Index, context.Shots[i], !context.Shots[i].Destructable, gameTime); } } }
/// <summary> /// Collision between player context.Shots and badguys context.Shots /// </summary> /// <param name="gameTime"></param> /// <param name="x"></param> protected void CollisionShots(GameTime gameTime, Shot playerShot) { for (int i = 0; i < context.Shots.Count; i++) { if ((context.Shots[i].EnemyFire == false) || ((context.Shots[i].Destructable == false) && (context.Options.Difficulty != Difficulty.Easy)) || (context.Options.Difficulty == Difficulty.Hard)) { continue; } if (playerShot.Hitbox.Collide(context.Shots[i].Hitbox)) { //Damage shot context.Shots[i].IsHit = true; context.Shots[i].Hp -= (int)((float)playerShot.Weapon.Damage * context.DamageMulti); if (context.Options.Difficulty != Difficulty.Easy) { KillShot(context.Player1.Index, playerShot, true, gameTime); } KillShot(context.Player1.Index, context.Shots[i], false, gameTime); } } }
/// <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); } } }