Exemplo n.º 1
0
        //====== ctors

        public GameLogic(Size terrainSize, GameTime gameTime) : base(gameTime)
        {
            terrain            = new Terrain(terrainSize);
            snakeBody          = new SnakeBody(new Point(terrain.Size.Width / 2, terrain.Size.Height / 2));
            speed              = new SnakeSpeed();
            applesGenerator    = new AppleGenerator(terrain, gameTime);
            applesConsumer     = new AppleConsumer(terrain, snakeBody, gameTime);
            terrainUpdater     = new TerrainUpdater(terrain, snakeBody, gameTime);
            gameOverConditions = new GameOverConditions(snakeBody, terrain, applesGenerator, gameTime);
            score              = new Score();
            moveQueue          = new SnakeMoveQueue();

            updater = new GameObjectsUpdater();
            SetupGameObjectsUpdater();

            applesConsumer.Consumed += AppleConsumer_AppleConsumed;
        }
        //====== ctors

        public SnakePositionUpdater(ISnakeMovementController movementController, SnakeMoveQueue moveQueue, GameTime gameTime) : base(gameTime)
        {
            this.movementController = Verify.NotNull(movementController, nameof(movementController));
            this.moveQueue          = Verify.NotNull(moveQueue, nameof(moveQueue));
        }