public void CollisionHandling(GameObject sender, CollisionEventArgs e) { if (CollidedObjects.Contains(sender)) return; else CollidedObjects.Add(sender); // If collision occured with a player bullet... if (e.collisionLayer == 2) { sender.Destroy(); // Flash the thing here. if (Vulnerable) { // Flash the thing here. Health--; } } // Collided with player; kill! if (e.collisionLayer == 3) { PlayerShip thisShip = (PlayerShip)e.otherObject; thisShip.ObjectCollidedWith(this, new CollisionEventArgs(this, 1)); } }
public IEnumerator<float> BombExplosion(GameObject go) { yield return 2f; AudioManager.PlaySoundEffect(GameScene.Shot7Sound, .9f, 0f); BulletEmitter explosion = new BulletEmitter(this, go.Center, true); explosion.FireBulletExplosion(20, 110f, Color.Lerp(Color.White, Color.Orange, .7f)); explosion.FireBulletExplosion(30, 130f, Color.Lerp(Color.White, Color.Orange, .7f), BulletType.CircleSmall); go.Destroy(); }
public void CollisionHandling(GameObject sender, CollisionEventArgs e) { if (CollidedObjects.Contains(sender)) return; else CollidedObjects.Add(sender); // If collision occured with a player bullet... if (e.collisionLayer == 2) { sender.Destroy(); // Flash the thing here. Health--; if (Health <= 0) Explode(); } }
public void CollisionHandling(GameObject sender, CollisionEventArgs e) { if (CollidedObjects.Contains(sender)) { return; } else CollidedObjects.Add(sender); // If collision occured with a player bullet... if (e.collisionLayer == 2) { sender.Destroy(); // Flash the thing here. Health--; CheckForDeath(); } else if (e.collisionLayer == 3) { Health -= 2; CheckForDeath(); } }
public IEnumerator<float> BossExplosion(GameObject go) { // First, cancel all scripts, then do this. float x; float y; Random rand = new Random(); for (int i = 0; i < 30; i++) { x = go.Center.X + (float)(((rand.NextDouble() * 2f) - 1f) * 75); y = go.Center.Y + (float)(((rand.NextDouble() * 2f) - 1f) * 75); AudioManager.PlaySoundEffect(GameScene.Explosion4Sound, .4f); PlayAnimation(new Animation(GameScene.ExplosionTexture, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 48, 40f, new Vector2(x - 24, y - 25), false)); yield return .1f; } if (!(go is FinalBoss)) { AudioManager.PlaySoundEffect(GameScene.Explosion4Sound, 1f); AudioManager.PlaySoundEffect(GameScene.Explosion1Sound, .6f); fader.LerpColor(Color.White, .3f); yield return .3f; go.Destroy(); } }