Ejemplo n.º 1
0
    bool PutTextOnTracks(string input)
    {
        bool worked = false;

        Transform[] children = GetComponentsInDirectChildren(LineGroups.transform);
        //int pick = Random.Range(0, children.Length);
        //Debug.Log("picked line set # " + pick+" from a choice of "+children.Length+" sets");
        GameObject LineSet = children[currentLineSet].gameObject;

        Debug.Log("line set: ");
        Debug.Log(LineSet.name);
        Transform[] Lines = GetComponentsInDirectChildren(LineSet.transform);

        int pick = PickAvailableTrack(Lines.Length);

        if (pick != -1)
        {
            GameObject chosenLine = Lines[pick].gameObject;

            Debug.Log("chosen line: ");
            Debug.Log(pick);
            Debug.Log(chosenLine.name);
            GameObject phrase = Instantiate(templatePhrase);
            activePhrases.Add(phrase);
            worked = true;
            phraseHandler ph = phrase.GetComponent <phraseHandler>();
            ph.SetupPhrase(chosenLine, outputbox, input, pick);
        }


        return(worked);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Time.time > nextTrigger)
        {
            if (queue.Count > 0)
            {
                bool worked = PutTextOnTracks(queue[0]);

                if (worked)
                {
                    queue.RemoveAt(0);
                }

                nextTrigger = Time.time + InputInterval;
            }
            else if (fullSourcePhrases.Count > 0)
            {
                // format string to color code elements? euh
                //
                //
                // hmmm gotta pass a list of string indeces that correspond
                // to colored characters i guess?
                //
                // the charHandler script on each char object has a public
                // method called updatecolor(material). Pass a material as
                // argument to set color..........................
                string output = fullSourcePhrases[0];
                bool   worked = PutTextOnTracks(output);
                if (worked)
                {
                    List <string> words = sourceWordsInPhrase[0];

                    for (int j = 0; j < activePhrases.Count; j++)
                    {
                        phraseHandler phrasehandler = activePhrases[j].GetComponent <phraseHandler>();
                        string        txt           = phrasehandler.text;

                        for (int i = 0; i < words.Count; i++)
                        {
                            int wordIndex = txt.IndexOf(words[i]);

                            if (wordIndex != -1)
                            {
                                //Material mat = sourceWordsInPhraseMat;
                                phrasehandler.updateChars(wordIndex, words[i].Length);
                            }
                        }
                    }


                    fullSourcePhrases.RemoveAt(0);
                    sourceWordsInPhrase.RemoveAt(0);
                }

                nextTrigger = Time.time + InputInterval;
            }

            // if it's time for a new trigger but there's nothing available
            else if (activePhrases.Count < 2 && !waitingForEcho)
            {
                OscMessage message = new OscMessage();

                message.address = "/randomRecordingRequest";
                message.values.Add("giveme");
                osc.Send(message);

                waitingForEcho = true;
            }
        }
    }