internal void Update() { team1display.Update(); team2display.Update(); }
public void Update() { if (started && !paused) { bool collided = false; foreach (INonReactiveCollideable collideable in nonReactiveCollideables) { if (ball.GetBoundingBox().Intersects(collideable.GetBoundingBox())) { ball.CollideWith(collideable); if (collideable is Wall wall) { if (wall.side == Side.BOTTOM || wall.side == Side.TOP) { soundManager.PlayPointWonSound(wall.side == Side.TOP); scoreDisplay.UpdateScore(wall.side == Side.TOP); Reset(false); Start(); return; } else { soundManager.PlayBallWallSound(); } } else if (collideable is Paddle) { soundManager.PlayBallPaddleSound(); } collided = true; } if (collideable == computerPaddle) { computerPaddle.ReceiveIntendedPosition(ball.GetBoundingBox().X + ball.GetBoundingBox().Width / 2); } else if (collideable == playerPaddle) { playerPaddle.ReceiveIntendedPosition(lastMouseXPos); } collideable.Update(); } if (collided && ballCollidedLastFrame) { ball.Reset(); } ballCollidedLastFrame = collided; ball.Update(); scoreDisplay.Update(); } else if (starting) { startTimer--; if (startTimer == 60 || startTimer == 120 || startTimer == 0) { soundManager.PlayCountdownSound(); } if (startTimer == 0) { started = true; starting = false; } } }