コード例 #1
0
    public void AddWordButtonPressed()
    {
        string input            = AddWordInput.GetComponent <InputField>().text.ToLower();
        string type             = AddWordDropdown.GetComponentInChildren <Text>().text.ToLower();
        bool   AddFileUpdate    = false;
        bool   DeleteFileUpdate = false;

        if (type == "noun")
        {
            if (dictionary.AddWordToDictionary(input, type))
            {
                userAddList_Noun.Add(input);
                AddFileUpdate = true;
                if (userDeleteList_Noun.Remove(input))
                {
                    DeleteFileUpdate = true;
                }
            }
        }
        else if (type == "verb")
        {
            if (dictionary.AddWordToDictionary(input, type))
            {
                userAddList_Verb.Add(input);
                AddFileUpdate = true;
                if (userDeleteList_Verb.Remove(input))
                {
                    DeleteFileUpdate = true;
                }
            }
        }
        else if (type == "adjective")
        {
            if (dictionary.AddWordToDictionary(input, type))
            {
                userAddList_Adjective.Add(input);
                AddFileUpdate = true;
                if (userDeleteList_Adjective.Remove(input))
                {
                    DeleteFileUpdate = true;
                }
            }
        }
        else if (type == "adverb")
        {
            if (dictionary.AddWordToDictionary(input, type))
            {
                userAddList_Adverb.Add(input);
                AddFileUpdate = true;
                if (userDeleteList_Adverb.Remove(input))
                {
                    DeleteFileUpdate = true;
                }
            }
        }
        else if (type == "other")
        {
            if (dictionary.AddWordToDictionary(input, type))
            {
                userAddList_Random.Add(input);
                AddFileUpdate = true;
                if (userDeleteList_Random.Remove(input))
                {
                    DeleteFileUpdate = true;
                }
            }
        }

        if (AddFileUpdate)
        {
            updateAddFile();
        }

        if (DeleteFileUpdate)
        {
            updateDeleteFile();
        }

        AddWordInput.GetComponent <InputField>().text = "";
    }