/// <summary> /// Creates a new <see cref="WordgridGrid"/> based on an exisiting <paramref name="grid"/> but with a new position /// </summary> /// <param name="grid">The existing grid that is the base for the new <see cref="WordgridGrid"/></param> /// <param name="startX">The new start position on the X-Axis</param> /// <param name="startY">The new start position on the Y-Axis</param> /// <remarks>The <paramref name="startX"/> and <paramref name="startY"/> positions must be reachable from the exisiting <paramref name="grid"/>, because the new <see cref="Path"/> is computed based on the existing <see cref="Path"/> of the given <paramref name="grid"/>. It is not checked if this requirement is met!</remarks> public WordgridGrid(WordgridGrid grid, int startX, int startY) { X = startX; Y = startY; WordMatrix = new WordgridCell[4, 4]; for (var i = 0; i < 4; i++) { for (var j = 0; j < 4; j++) { var cell = grid.WordMatrix[i, j]; WordMatrix[i, j] = new WordgridCell(cell); } } Path = grid.Path + GetCurrentChar(); GetCurrentCell().Visited = true; }
public WordgridGrid(string wordMatrix, int startX, int startY) { X = startX; Y = startY; WordMatrix = new WordgridCell[4, 4]; for (var i = 0; i < 4; i++) { for (var j = 0; j < 4; j++) { WordMatrix[i, j] = new WordgridCell(wordMatrix.Substring(i * 4 + j, 1)); } } Path = GetCurrentChar(); GetCurrentCell().Visited = true; }