/// <summary> /// Method converts splitted string to highest field value and field values /// </summary> /// <param name="highestValue"></param> /// <param name="gameBoardModel"></param> public void ImportGameBoardModelFromString(string highestValue, string gameBoardModel) { this.highestValue = (FieldValue)Math.Pow(2, TranslateData.TranslateCharToNumber(highestValue[0])); int fieldValue = 0; EmptyFieldsPosition emptyFieldsPositions = EmptyFieldsPosition.Instance; emptyFieldsPositions.ClearListOfEmptyFields(); for (int z = 0; z < numberOfLayers; z++) { for (int x = 0; x < boardSize; x++) { for (int y = 0; y < boardSize; y++) { fieldValue = (int)Math.Pow(2, TranslateData.TranslateCharToNumber( gameBoardModel[z * boardSize * boardSize + x * boardSize + y])); if (fieldValue > 1) { this.fields[z][x, y] = (FieldValue)fieldValue; } else { this.fields[z][x, y] = FieldValue.empty; emptyFieldsPositions.AddEmptyFieldToList(z, x, y); } } } } }
/// <summary> /// Method clears list of empty fields /// </summary> private void ClearListOfPositionsOfEmptyField() { EmptyFieldsPosition freeFields = EmptyFieldsPosition.Instance; freeFields.ClearListOfEmptyFields(); }