Esempio n. 1
0
        public void Brick_TestCharge()
        {
            //Create a new Ball object
            Ball b = new RegularBall(PointF.Empty);

            //Set the move vector
            b.moveVector = new SizeF(1, -1.0f);

            //Create a new ChargedBrick object
            Brick br = new ChargedBrick(PointF.Empty);

            //Hit the brick
            br.OnHit(ref b);

            //Ball does not change direction
            Assert.AreEqual(new SizeF(1, -1.0f), b.moveVector);

            //Ball changes type to 'ChargedBall'
            Assert.AreEqual(typeof(ChargedBall), b.GetType());
        }
Esempio n. 2
0
        /// <summary>
        /// Fills the field with bricks
        /// </summary>
        private static void FillBricks()
        {
            for (int x = 0; x < bricks.GetLength(0); x++)
            {
                for (int y = 0; y < bricks.GetLength(1); y++)
                {
                    PointF position = new PointF(gameField.Left
                        + GameSettings.BrickOffsetWidth
                        + (GameSettings.BrickSpacingWidth + GameSettings.BrickSizeWidth) * x,
                        GameSettings.BrickOffsetHeight
                        + (GameSettings.BrickSpacingHeight + GameSettings.BrickSizeHeight) * y);
                    int r = random.Next(10);
                    if (r < 7)
                        bricks[x, y] = new RegularBrick(position); // 7/10 chance
                    else if (r == 7)
                        bricks[x, y] = new BonusBrick(position); // 1/10 chance
                    else if (r == 8)
                        bricks[x, y] = new GhostBrick(position); // 1/10 chance
                    else
                        bricks[x, y] = new ChargedBrick(position); // 1/10 chance

                }
            }
        }