Beispiel #1
0
    /// <summary>
    /// Creates a new Word Game Object.
    /// </summary>
    /// <returns>The word object.</returns>
    /// <param name="word">The Tweet Word to create the Word Game Object from.</param>
    private GameObject createWordObject(TweetWord word)
    {
        GameObject newWordObject = Instantiate(tweetWordPrefab);

        newWordObject.transform.SetParent(tweetWordsContainer.transform);
        newWordObject.transform.localScale = new Vector3(1f, 1f, 1f);
        newWordObject.transform.position   = new Vector3(UnityEngine.Random.Range(-0.8f, 0.8f), UnityEngine.Random.Range(-0.8f, 0.8f), 0f);

        switch (word.Phrase)
        {
        case TweetWordPhrase.FILL:
            newWordObject.GetComponent <CanvasRenderer> ().SetColor(Color.blue);
            break;

        case TweetWordPhrase.VERB:
            newWordObject.GetComponent <CanvasRenderer> ().SetColor(Color.green);
            break;

        case TweetWordPhrase.SUBJECT:
            newWordObject.GetComponent <CanvasRenderer> ().SetColor(Color.red);
            break;
        }

        Text wordText = newWordObject.transform.Find("WordText").GetComponent <Text>();

        wordText.text = word.Word;

        return(newWordObject);
    }
    /// <summary>
    /// Loads the words.
    /// </summary>
    private void LoadWords()
    {
        tweetWords = new List <TweetWord> ();

        TweetWord word1 = new TweetWord(TweetWordType.NEGATIVE, TweetWordPhrase.SUBJECT, "Mexicans", 30);
        TweetWord word2 = new TweetWord(TweetWordType.POSITIVE, TweetWordPhrase.SUBJECT, "Trump", 30);

        TweetWord word3 = new TweetWord(TweetWordType.NEGATIVE, TweetWordPhrase.VERB, "they're bringen drugs.", 30);
        TweetWord word4 = new TweetWord(TweetWordType.POSITIVE, TweetWordPhrase.VERB, "very talented.", 30);

        TweetWord word5 = new TweetWord(TweetWordType.NEUTRAL, TweetWordPhrase.FILL, "So foolish!", 30);

        tweetWords.Add(word1);
        tweetWords.Add(word2);
        tweetWords.Add(word3);
        tweetWords.Add(word4);
        tweetWords.Add(word5);
    }