Example #1
0
    public QWERTYTextGenerator(KeyboardQWERTY keyboard, QWERTYOptions options, int minLength = 5, int maxLength = 9)
    {
        Keyboard = keyboard;
        Options  = options;

        _minLength = minLength;
        _maxLength = maxLength;

        AssignCharactersArray();
    }
Example #2
0
    private ITextGenerator GetQWERTYTextGenerator(GameSettings gameSettings)
    {
        currentDictionaryJson = gameSettings.GameLanguage == GameLanguage.En ?
                                assetsReferences.qwertyKeyboardJsonEn : assetsReferences.qwertyKeyboardJsonRu;

        var keyboard = JsonSerializationManager.ReadFromAsset <KeyboardQWERTY>(currentDictionaryJson.text);

        if (keyboard == null)
        {
            Debug.LogError("Cannot find dictionary for qwerty text generation!");
            return(null);
        }

        var options = new QWERTYOptions(gameSettings.HandType, gameSettings.SectionTypes);

        return(new QWERTYTextGenerator(keyboard, options, gameSettings.MinWordLength, gameSettings.MaxWordLength));
    }
Example #3
0
    public void AssignCharactersArray(KeyboardQWERTY keyboard, QWERTYOptions options)
    {
        List <char> characters = new List <char>();

        if (options.HandType == QWERTYHandType.Both)
        {
            AssignHand(keyboard.LeftHand, options, characters);
            AssignHand(keyboard.RightHand, options, characters);
        }
        else if (options.HandType == QWERTYHandType.Left)
        {
            AssignHand(keyboard.LeftHand, options, characters);
        }
        else if (options.HandType == QWERTYHandType.Right)
        {
            AssignHand(keyboard.RightHand, options, characters);
        }

        _charactersArray = characters.ToArray();
    }
Example #4
0
    private static void AssignHand(KeyboardSections hand, QWERTYOptions options, List <char> characters)
    {
        if (options.SectionType.HasFlag(QWERTYSectionType.Up))
        {
            characters.AddRange(hand.Up);
        }

        if (options.SectionType.HasFlag(QWERTYSectionType.Middle))
        {
            characters.AddRange(hand.Middle);
        }

        if (options.SectionType.HasFlag(QWERTYSectionType.Down))
        {
            characters.AddRange(hand.Down);
        }

        if (options.SectionType.HasFlag(QWERTYSectionType.Numbers))
        {
            characters.AddRange(hand.Numbers);
        }
    }