public void DestroyInExplosion(Grid grid, List <Ball> balls, List <Brick> bricks, List <Brick> destroyedBricks) { switch (_typeID) { case BrickType.Normal: GameControl.AddPoints(25); destroyedBricks.Add(this); break; case BrickType.Reinforced: GameControl.AddPoints(35); destroyedBricks.Add(this); break; case BrickType.Ball: GameControl.AddPoints(15); destroyedBricks.Add(this); double newBallAngle = new Random().Next(0, (int)(2 * Math.PI * 100)) / 100; double newBallX = Margin.Left + Width / 2 - 8; double newBallY = Margin.Top + Height / 2 - 8; balls.Add(new Ball(grid, 3, newBallAngle, newBallX, newBallY)); break; case BrickType.TNT: GameControl.AddPoints(5); destroyedBricks.Add(this); Explosion explosion = new Explosion(grid, balls, bricks, this, destroyedBricks); break; } }
public void Collisions(Grid grid, List <Ball> balls, List <Brick> bricks, List <Brick> destroyedBricks) { Rect collisionsArea = new Rect(Margin.Left, Margin.Top, Width, Height); foreach (Ball ball in balls) { Rect ballArea = new Rect(ball.Margin.Left, ball.Margin.Top, ball.Width, ball.Height); if (collisionsArea.IntersectsWith(ballArea)) { double ballAngle = ball.Angle; ball.Bounce(collisionsArea); switch (_typeID) { case BrickType.Normal: GameControl.AddPoints(25); GameControl.PlaySound(GameControl.Sound.BreakBrick); destroyedBricks.Add(this); return; case BrickType.Reinforced: GameControl.AddPoints(10); GameControl.PlaySound(GameControl.Sound.BreakReinforcement); _typeID = BrickType.Normal; Source = new BitmapImage(GetPath(_typeID, _colorID)); break; case BrickType.Indestructible: GameControl.PlaySound(GameControl.Sound.BouncingBall); break; case BrickType.Ball: GameControl.AddPoints(15); GameControl.PlaySound(GameControl.Sound.ExtraBall); destroyedBricks.Add(this); balls.Add(new Ball(grid, ball.Speed, ballAngle, Margin.Left + Width / 2 - 8, Margin.Top + Height / 2 - 8)); return; case BrickType.TNT: GameControl.AddPoints(5); GameControl.PlaySound(GameControl.Sound.Explosion); destroyedBricks.Add(this); Explosion explosion = new Explosion(grid, balls, bricks, this, destroyedBricks); return; } } } }
public void UseBonus(ref Grid grid, ref Platform platform, ref List <Ball> balls) { if (_id == BonusName.Random) { _id = (BonusName)_rand.Next(1, _maxBonusID + 1); } switch (_id) { case BonusName.DoubleBall: GameControl.PlaySound(GameControl.Sound.ExtraBall); int ballsCount = balls.Count; for (int i = 0; i < ballsCount; i++) { balls.Add(new Ball(balls[i])); } break; case BonusName.BallSizeUp: foreach (Ball ball in balls) { ball.SizeUp(); } break; case BonusName.BallSizeDown: foreach (Ball ball in balls) { ball.SizeDown(); } break; case BonusName.BallSpeedDown: foreach (Ball ball in balls) { ball.Speed--; } break; case BonusName.BallSpeedUp: foreach (Ball ball in balls) { ball.Speed++; } break; case BonusName.PlatformSizeUp: platform.SizeUp(); break; case BonusName.PlatformSizeDown: platform.SizeDown(); break; case BonusName.PlatformSpeedUp: platform.Speed++; break; case BonusName.PlatformSpeedDown: platform.Speed--; break; case BonusName.ExtraLife: GameControl.AddLife(); break; case BonusName.ExtraPoints: GameControl.AddPoints(1000); GameControl.PlaySound(GameControl.Sound.ExtraPoints); break; case BonusName.Skull: foreach (Ball ball in balls) { grid.Children.Remove(ball); } balls.Clear(); break; } grid.Children.Remove(this); }