Exemplo n.º 1
0
 public CarPrototype(string symbol, IPositionalRenderer renderer, Directions direction, Coordinates position)
 {
     this.Symbol    = symbol;
     this.renderer  = renderer;
     this.Position  = position;
     this.Direction = direction;
 }
Exemplo n.º 2
0
        internal void Drawing(IPositionalRenderer renderer)
        {
            Coordinates drawLine = new Coordinates(Position.X, Position.Y);

            for (int i = 0; i < Console.BufferHeight; i++)
            {
                renderer.WriteAtPosition(new Coordinates(Constants.Playfieldsize, drawLine.Y++), '|');
            }
        }
Exemplo n.º 3
0
 public SnakeEngine(IPositionalRenderer renderer, IReader reader, IFoodGenerator foodGenerator)
 {
     this.reader        = reader;
     this.renderer      = renderer;
     this.foodGenerator = foodGenerator;
     currentFood        = foodGenerator.GenerateFood(renderer);
     this.snake         = SnakeFactory.CreateSnake(renderer);
     this.snake.Body.Reverse();
 }
Exemplo n.º 4
0
        public static Snake CreateSnake(IPositionalRenderer renderer)
        {
            var snake = new Snake();

            snake.Head = CreateSnakeHead(renderer);
            snake.Body = CreateSnakeBody(renderer, snake.Head);

            return(snake);
        }
Exemplo n.º 5
0
        private static List <BaseDot> CreateSnakeBody(IPositionalRenderer renderer)
        {
            var body = new List <BaseDot>();

            for (int i = 0; i < GlobalConstants.InitialSize; i++)
            {
                var position = new Coordinate(head.Position.X - i - 1, head.Position.Y);
                var bodyDot  = new BaseDot(renderer, GlobalConstants.Symbol, position);
                body.Add(bodyDot);
            }
            return(body);
        }
Exemplo n.º 6
0
 public Food GenerateFood(IPositionalRenderer renderer)
 {
     this.Food = new Food(renderer, GlobalConstants.FoodSymbol, Coordinate.GetRandomPosition(GlobalConstants.ConsoleWidth, GlobalConstants.ConsoleHeight));
     this.RenderFood();
     return(this.Food);
 }
Exemplo n.º 7
0
 internal DrawPlayfield(IPositionalRenderer renderer, Coordinates position)
 {
     this.Position = position;
 }
Exemplo n.º 8
0
 internal CarsEngine(IPositionalRenderer renderer)
 {
     this.renderer = renderer;
     this.myCar    = new Car(Constants.Symbol, renderer, new Directions(), Constants.StartingPosition);
 }
Exemplo n.º 9
0
 public BaseDot(IPositionalRenderer renderer, string symbol, Coordinate position)
 {
     this.renderer = renderer;
     this.Symbol   = symbol;
     this.Position = position;
 }
Exemplo n.º 10
0
 public Car(string symbol, IPositionalRenderer renderer, Coordinates position, ConsoleColor color = ConsoleColor.DarkMagenta)
     : base(symbol, renderer, position)
 {
 }
Exemplo n.º 11
0
 public Car(string symbol, IPositionalRenderer renderer, Directions direction, Coordinates position, ConsoleColor color = ConsoleColor.Blue)
     : base(symbol, renderer, direction, position)
 {
     this.Color = color;
 }
Exemplo n.º 12
0
 public Food(IPositionalRenderer renderer, string symbol, Coordinate position)
     : base(renderer, symbol, position)
 {
 }
Exemplo n.º 13
0
 public void EatFood(IPositionalRenderer renderer)
 {
     this.Body.Add(new BaseDot(renderer, GlobalConstants.Symbol, new Coordinate(Body[^ 1].Position)));
Exemplo n.º 14
0
 public SnakeEngine(IPositionalRenderer renderer)
 {
     this.renderer = renderer;
 }
Exemplo n.º 15
0
 public Dot(IPositionalRenderer renderer, IDirection direction, string symbol, Coordinate position)
     : base(renderer, symbol, position)
 {
     this.direction = direction;
 }
Exemplo n.º 16
0
 private static Dot(IPositionalRenderer renderer)
 {
     return(new Dot(renderer, new Direction(GlobalConstants, ConsoleWidth,
                                            GlobalConstants, ConsoleHeight), GlobalConstants.HeadSymbol, GlobalConstants.Center));
 }