private string CreateWord(Direction current, TileLAN start, int end) { var sb = new StringBuilder(); if (current == Direction.Vertical) { for (int j = end; j >= start.Row; j--) { string temp = Field[j, start.Column].CurrentLetter.text; if (String.Equals("*", temp)) { temp = "_"; } sb.Append(temp); } return(sb.ToString()); } else { for (int j = start.Column; j <= end; j++) { var temp = Field[start.Row, j].CurrentLetter.text; if (String.Equals("*", temp)) { temp = "_"; } sb.Append(temp); } return(sb.ToString()); } }
private string GetWord(TileLAN begin, TileLAN end) { if (CurrentDirection == Direction.Vertical) { var sb = new StringBuilder(); for (var j = begin.Row; j >= end.Row; j--) { if (!String.IsNullOrEmpty(Field[j, begin.Column].TempLetter)) { sb.Append(Field[j, begin.Column].TempLetter); } else if (Field[j, begin.Column].CurrentLetter.text.Equals("*")) { sb.Append('_'); } else { sb.Append(Field[j, begin.Column].CurrentLetter.text); } } return(sb.ToString()); } else { var sb = new StringBuilder(); for (var j = begin.Column; j <= end.Column; j++) { if (!String.IsNullOrEmpty(Field[begin.Row, j].TempLetter)) { sb.Append(Field[begin.Row, j].TempLetter); } else if (Field[begin.Row, j].CurrentLetter.text.Equals("*")) { sb.Append('_'); } else { sb.Append(Field[begin.Row, j].CurrentLetter.text); } } return(sb.ToString()); } }
//checks if one of the nearby tiles has letter private bool CheckTile(TileLAN checkedTile) { if (checkedTile.Row != 0 && parent.Field[checkedTile.Row - 1, checkedTile.Column].HasLetter) { return(true); } if (checkedTile.Row != parent.NumberOfRows - 1 && parent.Field[checkedTile.Row + 1, checkedTile.Column].HasLetter) { return(true); } if (checkedTile.Column != 0 && parent.Field[checkedTile.Row, checkedTile.Column - 1].HasLetter) { return(true); } if (checkedTile.Column != parent.NumberOfColumns - 1 && parent.Field[checkedTile.Row, checkedTile.Column + 1].HasLetter) { return(true); } return(false); }
private void FindWord(TileLAN currentTile, Direction current, out int startPosition, out int endPosition) { if (current == Direction.Vertical) { var j = currentTile.Row; while (j >= 0 && Field[j, currentTile.Column].HasLetter) { j--; } j++; startPosition = j; j = currentTile.Row; while (j < NumberOfRows && Field[j, currentTile.Column].HasLetter) { j++; } j--; endPosition = j; } else { var j = currentTile.Column; while (j >= 0 && Field[currentTile.Row, j].HasLetter) { j--; } j++; startPosition = j; j = currentTile.Column; while (j < NumberOfRows && Field[currentTile.Row, j].HasLetter) { j++; } j--; endPosition = j; } }
private void CreateWord(TileLAN start, out TileLAN wordStart, out TileLAN wordEnd) { if (CurrentDirection == Direction.Vertical) { var j = start.Row; while (j < 15 && Field[j, start.Column].HasLetter) { if (Field[j, start.Column].CurrentLetter.text.Equals("*")) { if (!_asterixTiles.Contains(Field[j, start.Column])) { _asterixTiles.Add(Field[j, start.Column]); } } j++; } wordStart = Field[j - 1, start.Column]; j = start.Row; while (j >= 0 && Field[j, start.Column].HasLetter) { if (Field[j, start.Column].CurrentLetter.text.Equals("*")) { if (!_asterixTiles.Contains(Field[j, start.Column])) { _asterixTiles.Add(Field[j, start.Column]); } } j--; } wordEnd = Field[j + 1, start.Column]; } else { var j = start.Column; while (j >= 0 && Field[start.Row, j].HasLetter) { if (Field[start.Row, j].CurrentLetter.text.Equals("*")) { if (!_asterixTiles.Contains(Field[start.Row, j])) { _asterixTiles.Add(Field[start.Row, j]); } } j--; } wordStart = Field[start.Row, j + 1]; j = start.Column; while (j < 15 && Field[start.Row, j].HasLetter) { if (Field[j, start.Column].CurrentLetter.text.Equals("*")) { if (!_asterixTiles.Contains(Field[start.Row, j])) { _asterixTiles.Add(Field[start.Row, j]); } } j++; } wordEnd = Field[start.Row, j - 1]; } }