Ejemplo n.º 1
0
 public override void OnHit(ref Ball b)
 {
     Debug.WriteLine("Hit!!!");
     b.changed = true;
     b = new ChargedBall(b);
     GameManager.AddScoreByFactor();
     StateSaver.SetBallState(StateSaver.BallStates.Transform);
 }
Ejemplo n.º 2
0
        public void Ball_TestChargeOnBrickHit()
        {
            PointF origin = new PointF(80, 220);
            ChargedBall b = new ChargedBall(origin);
            b.moveVector = new SizeF(0, -1.0f);
            b.Update();

            //Check if it goes through bricks.
            Assert.AreEqual(new SizeF(0, -1.0f), b.moveVector);

            b = new ChargedBall(new PointF(160, 220));
            b.moveVector = new SizeF(0, -1.0f);
            b.chargeLevel = 1;
            b.Update();
            b.Update();
            Assert.AreEqual(new SizeF(0, 1.0f), b.moveVector);

            //Check if it has changed back to regular after losing its last charge
            Assert.AreEqual(typeof(RegularBall), GameManager.player.ball.GetType());
        }
Ejemplo n.º 3
0
        public void Ball_TestTransitionProperties()
        {
            Ball b = new RegularBall(new PointF());
            b.moveVector.Width += 10.0f;
            Ball b2 = new ChargedBall(b);

            //Check if the move vector is taken over by the new ball correctly.
            Assert.AreEqual(b.moveVector, b2.moveVector);
        }
Ejemplo n.º 4
0
        public void Ball_TestTransitionType()
        {
            Ball b = new RegularBall(new PointF());
            Ball b2 = new ChargedBall(b);

            //Check if the type is not taken over by the new ball.
            Assert.AreNotEqual(typeof(RegularBall), b2.GetType());
        }
Ejemplo n.º 5
0
        public void Ball_TestRechargeOnWallHit()
        {
            RectangleF gf = GameManager.gameField;
            PointF pos = new PointF(gf.Left, gf.Top / 2);
            SizeF move = new SizeF(-1.0f, 0f);
            ChargedBall b = new ChargedBall(pos);
            b.chargeLevel = 1;
            b.moveVector = move;
            b.Update();
            b.Update();

            //Check if the ball regains it's charges after hitting a wall.
            Assert.AreEqual(3, b.chargeLevel);
        }