예제 #1
0
    // Checks a given string for spelling errors.
    // Returns a Dictionary in the form {index : word}
    public static Godot.Collections.Dictionary <int, string> CheckString(string input)
    {
        var outputDict = new Godot.Collections.Dictionary <int, string>();

        // For each character
        var currentWord = "";

        for (var i = 0; i < input.Length; i++)
        {
            var currentChar = input[i];

            // If at a space character or final character, current word is complete.
            var isLastCharacter = i >= input.Length - 1;

            if ((!char.IsLetterOrDigit(currentChar) && currentChar != '-' && currentChar != '\'') || isLastCharacter)
            {
                if (isLastCharacter && char.IsLetterOrDigit(currentChar))
                {
                    currentWord += currentChar;
                }

                Hunspell.Spell(currentWord);

                // If word has incorrect spelling, add index and word to dictionary.
                if (!IsWordCorrect(currentWord))
                {
                    outputDict.Add(i, currentWord);
                }


                // Clear and move onto next word
                currentWord = "";

                continue;
            }

            currentWord += currentChar;
        }

        return(outputDict);
    }
        private void AddTileMapObjectNodeReference(Vector2 tile)
        {
            var uniqueTileId = pathfindingTileMap.GetIdForTile(tile);

            tileMapObjects.Add(uniqueTileId, new TileMapObjectNodeReference());
        }