Ejemplo n.º 1
0
        public void NewGame(IRenderer renderer)
        {
            playTimer.Reset();
            renderer.ClearScreen();
            DirectionControl.ResetDirection();
            score.ResetScore();

            new FieldBorder(renderer, (int)playgroundDimension.X, (int)playgroundDimension.Y);

            var snakeStartPoint = new Vector(playgroundDimension.X / 2 * Measure, playgroundDimension.Y / 2 * Measure);

            snake = new Snake(snakeStartPoint, renderer);

            apple = new Apple(ColorThemes.Apple);
            renderer.RenderObject(apple.GetShape());

            pinkApple = new PinkApple(ColorThemes.PinkApple);
            renderer.RenderObject(pinkApple.GetShape());

            collision = new Collision(snake, apple, pinkApple, playgroundDimension);

            apple.SetCollision(collision);
            apple.ReplaceApple();

            pinkApple.SetCollision(collision);
            pinkApple.HideApple();

            ResumeGame();
            guiClient.SetVisibilityOfResume(true);
        }
Ejemplo n.º 2
0
        public void UpdateFrame()
        {
            snake.Move();
            var collideWith = collision.CheckCollision();

            if (collideWith == CollisionTyp.Obstacle)
            {
                guiClient.SetVisibilityOfResume(false);
                playTimer.Pause();

                if (highscore.ReachedMinimumPoints(score.Points))
                {
                    highscore.ShowNewEntryDialog(score.Points);
                }

                guiClient.ShowGameOver();
            }
            else if (collideWith == CollisionTyp.Apple)
            {
                apple.ReplaceApple();
                score.AddPoints(10);
                snake.Grow();
            }
            else if (collideWith == CollisionTyp.PinkApple)
            {
                pinkApple.HideApple();
                playTimer.ActivateBoost();
                score.AddPoints(10 * snake.Count);
            }
        }