void CreateInitialChildren() { for (int i = 0; i < snake.snakeData.initialSize; i++) { var headCoordinates = i == 0 ? snake.boardCoordinates.center : snake.GetHead().coordinates; var childCoordinates = headCoordinates + growthDirection * i; CreateChildAt(childCoordinates); } }
void MoveInDirection(Direction direction) { var directionVector = GetMovementVectorFrom(direction); var nextHeadCoordinate = snake.GetHead().coordinates + directionVector; var coordinatesOccupier = snake.boardMapper.GetOccupier(nextHeadCoordinate); (new SnakeCollision(nextHeadCoordinate, snake.board)) .CaseHitSnake(snake.HandleHitItself) .CaseHitBlock(snake.CollectBlock) .CaseEmptySpace(MoveEmptySpace) .CaseOutOfBoard(snake.HandleOutOfBoard) .Execute(); }