public void Hit(Bullet b) { if (!alreadyHit.Contains(b)) { if (!b.Player.Automate && b.Player.Powerup is PiercingShot) { SoundEffectInstance sfx = SoundManager.slice.CreateInstance(); sfx.Volume = 0.5f; sfx.Play(); } health--; velocity.X += b.Velocity.X / 3.5f; if (health > 0) { for (int i = 0; i < 6; i++) { float dir = b.Velocity.X > 0 ? -1 : 1; BloodParticle bp = new BloodParticle(b.Pos, dir); w.ParticleManager.AddParticle(bp); } } else { SoundEffectInstance sfx = SoundManager.enemyDeath.CreateInstance(); if (this is BossEnemy) { sfx.Pitch = -1f; } else { sfx.Pitch = (float)(Config.rand.NextDouble() / 3.0f) - (1 / 3.0f); } sfx.Volume = .5f; sfx.Play(); Die(b); } alreadyHit.Add(b); } }
public void Shoot() { if (reloadTimer == 0 && !onLadder && !inAir && !holdingBaby) { int direction = facingRight ? 1 : -1; Vector2 shootPoint = new Vector2(rect.X + (facingRight ? width : 0), rect.Center.Y); Bullet b = new Bullet(shootPoint, direction, this); recoilTimer = recoilTime; bullets--; World.BulletManager.Bullets.Add(b); if (testAnim.CurrentAnimation == "shoot") { testAnim.Reset(); } else { testAnim.Play("shoot"); } if (!automate) { SoundEffectInstance gunSound = SoundManager.gun.CreateInstance(); gunSound.Pitch = (float)(Config.rand.NextDouble() / 2.0f) - .5f; gunSound.Play(); } if (!automate) { if (bullets == 0) { reloadTimer = reloadTime; SoundEffectInstance reloadSound = SoundManager.reload.CreateInstance(); reloadSound.Play(); } } automateBullet = 0.25f; } }
public void Die(Bullet b) { //b.Player.Score += 100; Vector2 center = new Vector2(hitRect.Center.X, hitRect.Center.Y); for (int i = 0; i < 8; i++) { DeathParticle dp = new DeathParticle(center); w.ParticleManager.AddParticle(dp); } health = 0; }
public void RemoveBullet(Bullet b) { toRemove.Add(b); }