示例#1
0
    public static void loadEmojis()
    {
        JSONObject mappingsText = null;
        if (json != null) {
            mappingsText = json["mappings"];
        }
        else {
            loadFile ();
            loadEmojis();
        }

        for (int i=0; i < mappingsText.Count; i++) {
            Emoji emoji = new Emoji();
            JSONObject wordText = mappingsText[i];

            string word = wordText["word"].ToString().Trim('"');
            string filename = wordText["emoji"].ToString().Trim('"');

            emoji.setWord(word);
            emoji.setFilename(filename);
            emojis.Add (emoji);
        }
    }
示例#2
0
    public static void loadWords()
    {
        JSONObject wordsText = null;
        if (json != null) {
            wordsText = json["words"];
        }
        else {
            loadFile ();
            loadWords();
        }

        for (int i=0; i < wordsText.Count; i++) {
            Word word = new Word ();

            JSONObject wordText = wordsText[i];
            string complete = wordText["complete"].ToString().Trim('"');
            word.setComplete(complete);

            JSONObject emojisText = wordText["emojis"];

            List<Emoji> emojis = new List<Emoji>();

            for (int e=0; e < emojisText.Count; e++) {
                Emoji emoji = new Emoji();

                JSONObject etext = emojisText[e];
                string wordAText = etext["word"].ToString().Trim('"');
                if (wordAText == "") {
                    break;
                }
                string color = etext["color"].ToString().Trim('"');
                string filename = findEmojiForWord(wordAText);

                emoji.setColor(color);
                emoji.setWord(wordAText);
                emoji.setFilename(filename);

                if (unlockAll) {
                    addToUnlocked(filename);
                }

                emojis.Add(emoji);
            }
            word.setEmojis(emojis);

            words.Add (word);
        }

        //int count = wordsText.Count;
        //for (int l=0; l < count; l++) {
        //	if (unlockAll) {
        //		emojis.Add (emojis[l]);
        //	}
        //}
        //printOutUnused();
    }
示例#3
0
    Emoji pickRandomEmoji()
    {
        Emoji e = new Emoji();
        string myRandomEmoji = "";
        string emojiList = "";
        // pick a word

        bool okay = false;

        while (!okay) {
            okay = true;
            int rand = UnityEngine.Random.Range (0, LoadSave.emojis.Count - 1);
            myRandomEmoji = LoadSave.emojis [rand].getWord ();
            emojiList = LoadSave.emojis [rand].getFilename ();

            // make sure it is not a duplicate of something already picked or random word

            // make sure it's not the two cards we need
            if (wordValues.Count > 1 && (wordValues [0].getFilename () == emojiList || wordValues [1].getFilename () == emojiList)) {
                //Debug.Log ("try again, it's a card you need");
                okay = false;
                //e = pickRandomEmoji ();
            }
            // make sure it's not already on the board (found this doesn't work)
            for (int i=0; i < someValues.Count; i++) {
                //Debug.Log (someValues[i].getFilename() + " " + emojiList);
                if (someValues[i].getFilename() == emojiList) {
                    // repeat, try again
                    //Debug.Log ("try again, already on board");
                    //e = pickRandomEmoji ();
                    okay = false;
                }
            }

        }
        e.setWord (myRandomEmoji);
        e.setFilename (emojiList);

        return e;
    }