Inheritance: Game.DrawObject
示例#1
0
 public override void OnHit(ref Ball b)
 {
     b.changed = true;
     b = new GhostBall(b);
     GameManager.AddScoreByFactor();
     StateSaver.SetBallState(StateSaver.BallStates.Transform);
 }
示例#2
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);
 }
示例#3
0
 public override void OnHit(ref Ball b)
 {
     GameManager.AddScoreByFactor();
 }
示例#4
0
        private SizeF calculateSpeed(ref Ball b, RectangleF playerBox)
        {
            //Calculate the move vector when bouncing on the pad (player)
            float speed = b.moveVector.Size();
            float speedFactor = 1.05f;
            if (speed * speedFactor > playerBox.Height)
            {
                speed = playerBox.Height;
            }
            else
            {
                speed *= 1.05f;
            }

            float ballMiddle = b.boundingBox.Left + b.boundingBox.Width / 2;
            float ballOnPadPosition = (ballMiddle - (playerBox.Left - b.boundingBox.Width / 2)) / (playerBox.Width + b.boundingBox.Width);

            //convert between radians and degrees
            double angle = (Math.PI / 180) * (120 - 60 * ballOnPadPosition);
            float x = (float)Math.Cos(angle);
            float y = -(float)Math.Sin(angle);
            SizeF expected = new SizeF(x * speed, y * speed);

            return expected;
        }
示例#5
0
 public ChargedBall(Ball b)
     : base(b)
 {
 }
示例#6
0
 /// <summary>
 /// What to do when the ball hits the brick
 /// </summary>
 /// <param name="b"></param>
 public abstract void OnHit(ref Ball b);
示例#7
0
 public Player(Point pos)
 {
     this.position = pos;
     this.size = new SizeF(GameSettings.PaddleWidth, GameSettings.PaddleHeight);
     this.ball = new RegularBall(pos + new Size(10, -10));
 }
示例#8
0
 public GhostBall(Ball b)
     : base(b)
 {
 }
示例#9
0
 public RegularBall(Ball b)
     : base(b)
 {
 }
示例#10
0
 public Ball(Ball b)
 {
     this.position = b.position;
     this.moveVector = b.moveVector;
     this.size = new SizeF(10.0f, 10.0f);
 }