Beispiel #1
0
        private CoordinateInfo[] CreateNextCoordinatesInfoForSimpleCrossword(Point previousCoordPassword, Word wordToPlace, char passwordLetter)
        {
            var coordinatesInfo            = new List <CoordinateInfo>();
            var currentCoordPassword       = new Point();
            var currentLetterCountPassword = 0;

            for (var i = 0; i < wordToPlace.Value.Length; i++)
            {
                var letter = wordToPlace.Value[i];

                if (passwordLetter.Equals(letter))
                {
                    currentCoordPassword       = new Point(previousCoordPassword.X + 1, i);
                    currentLetterCountPassword = i;
                    break;
                }
            }

            var fakeCounter      = 0;
            var passLetterWasSet = false;
            var startY           = previousCoordPassword.Y - currentCoordPassword.Y;

            for (var i = startY; i < wordToPlace.Value.Length + startY; i++)
            {
                var letter           = wordToPlace.Value[fakeCounter];
                var isPasswordLetter = false;

                if (!passLetterWasSet && fakeCounter == currentLetterCountPassword)
                {
                    isPasswordLetter = true;
                    passLetterWasSet = true;
                }

                var coordInfo = new CoordinateInfo(new Point(previousCoordPassword.X + 1, i), letter, isPasswordLetter);

                coordinatesInfo.Add(coordInfo);

                fakeCounter++;
            }

            return(coordinatesInfo.ToArray());
        }
Beispiel #2
0
        private CoordinateInfo[] CreateCoordinatesInfoForSimpleCrossword(List <CrosswordElement> elements, Word wordToPlace, char passwordLetter)
        {
            CoordinateInfo previousCoordPassword = null;

            if (elements.Count > 0)
            {
                previousCoordPassword = elements[elements.Count - 1].CoordinatesInfo
                                        .Select(c => c)
                                        .Where(c => c.IsPasswordLetter)
                                        .FirstOrDefault();
            }

            if (previousCoordPassword == null)
            {
                return(CreateFirstCoordinatesInfoForSimpleCrossword(wordToPlace, passwordLetter));
            }
            else
            {
                return(CreateNextCoordinatesInfoForSimpleCrossword(previousCoordPassword.Coordinates, wordToPlace, passwordLetter));
            }
        }
Beispiel #3
0
        private CoordinateInfo[] CreateFirstCoordinatesInfoForSimpleCrossword(Word wordToPlace, char passwordLetter)
        {
            var coordinatesInfo  = new List <CoordinateInfo>();
            var passLetterWasSet = false;

            for (var i = 0; i < wordToPlace.Value.Length; i++)
            {
                var letter           = wordToPlace.Value[i];
                var isPasswordLetter = false;

                if (!passLetterWasSet && passwordLetter.Equals(letter))
                {
                    isPasswordLetter = true;
                    passLetterWasSet = true;
                }

                var coordInfo = new CoordinateInfo(new Point(0, i), letter, isPasswordLetter);

                coordinatesInfo.Add(coordInfo);
            }

            return(coordinatesInfo.ToArray());
        }