public Snake(Point point) { Head = new SnakeHead(point, Direction.None); Body = new List <SnakePart>(); Body.Add(Head); IsAlive = true; }
// Returns a copy of recieved field public Field GetFieldCopy(Point currentPoint) { Field fieldCopy; switch (this[currentPoint]) { case Wall w: fieldCopy = new Wall(currentPoint); break; case Food f: fieldCopy = new Food(currentPoint); break; case SnakeHead h: Direction currentDirection = h.Direction; fieldCopy = new SnakeHead(currentPoint, currentDirection); break; case SnakeBodyPart b: fieldCopy = new SnakeBodyPart(currentPoint); break; case Empty e: fieldCopy = new Empty(currentPoint); break; default: throw new Exception("Unable to find type"); } return(fieldCopy); }