public static void BubbleCollision(Bubble bub) { foreach (GameObjects g in Manager.gameObjs .OfType <GameObjects>()) { if (g is Wall && g.Bounds().Intersects(bub.BodyBox())) { bub.Direction = 0; bub.PositionY = bub.PreviousSpot.Y; bub.DirectionUp = 0; bub.BubFinalDest = true; } if (g is Wall && g.Bounds().Intersects(bub.BodyBox())) { } } foreach (Animated a in Manager.gameObjs .OfType <Animated>()) { if (a is Enemy && a.BodyBox().Intersects(bub.BodyBox()) && bub.IsActive) { a.Hit = true; a.PositionX = bub.PositionX; a.PositionY = bub.PositionY; } if (a is Player && a.BodyBox().Intersects(bub.BodyBox()) && bub.BubFinalDest) { BubbleHandler.RemoveBubbles(bub); SuperClass.score += 100; } } }
public override void Update(GameTime gameTime) { previousSpot = position; if (isActive) { SpriteAnimator(gameTime); if (spriteRec.X == 26) { picFrames = 2; } position.X += direction; bubDirtimer -= gameTime.ElapsedGameTime.TotalMilliseconds; if (bubDirtimer <= 0) { position.Y += directionUp; direction = 0; directionUp = -3; bubDeathTime -= gameTime.ElapsedGameTime.TotalMilliseconds; if (bubFinalDest && bubDeathTime <= 0) { bubDeathAnim -= gameTime.ElapsedGameTime.TotalMilliseconds; spriteRec.Y = 26; picFrames = 4; if (bubDeathAnim <= 0) { BubbleHandler.RemoveBubbles(this); isActive = false; Enemy.hit = false; } } } } CollisionHandler.BubbleCollision(this); }