Ejemplo n.º 1
0
        public Playarea(PlayareaSize size, IFoodFactory factory)
        {
            this.Size    = this.GetValidFieldSize(size);
            this.factory = factory;
            Position startPosition = new Position(this.Size.NumberOfRows / 2, this.Size.NumberOfColumns / 2);

            this.snake = new Snake(startPosition);
            this.Food  = this.GetRandomFoodInUniquePosition();
            this.SetGameState();
        }
Ejemplo n.º 2
0
        private PlayareaSize GetValidFieldSize(PlayareaSize size)
        {
            int row    = size.NumberOfRows;
            int column = size.NumberOfColumns;

            if (size.NumberOfRows < 4)
            {
                row = 4;
            }

            if (size.NumberOfColumns < 4)
            {
                column = 4;
            }

            return(new PlayareaSize(row, column));
        }