Update() 공개 메소드

Updates the score with the current values of scoreKeeper.
public Update ( ) : void
리턴 void
예제 #1
0
 internal void Update()
 {
     team1display.Update();
     team2display.Update();
 }
예제 #2
0
        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;
                }
            }
        }