public override void OnHit(ref Ball b) { b.changed = true; b = new GhostBall(b); GameManager.AddScoreByFactor(); StateSaver.SetBallState(StateSaver.BallStates.Transform); }
public override void OnHit(ref Ball b) { Debug.WriteLine("Hit!!!"); b.changed = true; b = new ChargedBall(b); GameManager.AddScoreByFactor(); StateSaver.SetBallState(StateSaver.BallStates.Transform); }
public override void OnHit(ref Ball b) { GameManager.AddScoreByFactor(); }
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; }
public ChargedBall(Ball b) : base(b) { }
/// <summary> /// What to do when the ball hits the brick /// </summary> /// <param name="b"></param> public abstract void OnHit(ref Ball b);
public Player(Point pos) { this.position = pos; this.size = new SizeF(GameSettings.PaddleWidth, GameSettings.PaddleHeight); this.ball = new RegularBall(pos + new Size(10, -10)); }
public GhostBall(Ball b) : base(b) { }
public RegularBall(Ball b) : base(b) { }
public Ball(Ball b) { this.position = b.position; this.moveVector = b.moveVector; this.size = new SizeF(10.0f, 10.0f); }