/// <summary> /// ����ײ����ã����ש�����Ƿ���������� /// ����У����߽��ᱻ������Ϸ�е�list powerup /// </summary> /// <param name="brick">��Ҫ����ש��</param> private void CheckBrickForPowerUps(Brick brick) { if (brick.powerBall) //�������������Ч { int radius = 7; //�����ɵ���İ뾶������� ballList.Add(new Ball(Brushes.White, radius, brick.Centre.X, brick.Centre.Y, false)); //��������ש����������ɵ� } //�������Ҫ������������Ч string powerUpLabel = null; Brush powerUpBrush = null; if (brick.powerShrink) { powerUpLabel = "����"; powerUpBrush = Brushes.LightBlue; } if (brick.powerStretch) { powerUpLabel = "�쳤"; powerUpBrush = Brushes.LightGreen; } if (brick.powerMulti) { powerUpLabel = "������"; powerUpBrush = Brushes.Pink; } if (brick.powerBullet) { powerUpLabel = "�ӵ�"; powerUpBrush = Brushes.Red; } if (powerUpLabel != null) { PowerUp powerup = new PowerUp(powerUpLabel, powerUpBrush, brick.Centre.X, brick.Centre.Y); powerUpList.Add(powerup); } //ֻ��ש������������ߵ�����²����������� }
/// <summary> /// Called after a collision. Checks the brick to see if it had any powerups inside it /// If it does, the powerups are added to the list of powerups in play /// </summary> /// <param name="brick">The brick to check for powerups</param> private void CheckBrickForPowerUps(Brick brick) { if (brick.powerBall) //extra ball instantly takes effect { Random randy = new Random(); int radius = randy.Next(3, 8); //new ball has a random radius ballList.Add(new Ball(Brushes.Black, radius, brick.Centre.X, brick.Centre.Y, false)); //new ball is created centred at the centre of the old brick } //these powerups have to be caught by the paddle string powerUpLabel = null; Brush powerUpBrush = null; if (brick.powerShrink) { powerUpLabel = "Shrink"; powerUpBrush = Brushes.LightBlue; } if (brick.powerStretch) { powerUpLabel = "Stretch"; powerUpBrush = Brushes.LightGreen; } if (brick.powerMulti) { powerUpLabel = "Multi"; powerUpBrush = Brushes.Pink; } if (powerUpLabel != null) { PowerUp powerup = new PowerUp(powerUpLabel, powerUpBrush, brick.Centre.X, brick.Centre.Y); powerUpList.Add(powerup); } //only add the powerup if a powerup is found in the brick }