Beispiel #1
0
    private void addNounBox(int y, Text text, bool init)
    {
        // this centers the text object
        if (!init)
        {
            Text lastText = (Text)nounArray[nounArray.Count - 1];
            text.rectTransform.position = new Vector3(-text.rectTransform.sizeDelta.y + Screen.width, lastText.rectTransform.position.y - lastText.rectTransform.sizeDelta.y);
        }
        else
        {
            text.rectTransform.position = new Vector3(-text.rectTransform.sizeDelta.y + Screen.width, y);
        }
        //text.rectTransform.anchoredPosition = new Vector2(Screen.width / 2, 0);
        // Adding to array so we can keep track of it
        InsultBox ib = text.GetComponent("InsultBox") as InsultBox;

        ib.type = WordType.NOUN;
        nounArray.Add(text);
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        // Setting the speed for each text obj in the array
        foreach (Text txtObj in nounArray)
        {
            InsultBox ib = txtObj.GetComponent("InsultBox") as InsultBox;
            ib.speed = this.speed;
        }

        foreach (Text txtObj in adjectiveArray)
        {
            InsultBox ib = txtObj.GetComponent("InsultBox") as InsultBox;
            ib.speed = this.speed;
        }

        if (rolling)
        {
            // When rolling set the speed and reset the bools.
            speed  = 1000;
            done   = false;
            talked = false;
        }
        else if (speed <= 20)
        {
            // Stop the rolling
            speed = 0;
            done  = true;
        }
        else
        {
            // Slowly lowers the speed
            speed *= 0.99f;
        }

        if (done && !talked)
        {
            talk();
        }

        //Debug.Log (speed);
    }
Beispiel #3
0
    private void addAdjectiveBox(int y, Text text, bool init)
    {
        // this centers the text object
        if (!init)
        {
            Text lastText = (Text)adjectiveArray[adjectiveArray.Count - 1];
            //Debug.Log("Last rect at " + lastText.rectTransform.position.y);
            text.rectTransform.position = new Vector3(text.rectTransform.sizeDelta.y, lastText.rectTransform.position.y + lastText.rectTransform.sizeDelta.y);
        }
        else
        {
            text.rectTransform.position = new Vector3(text.rectTransform.sizeDelta.y, y);
        }
        //text.rectTransform.anchorMax = new Vector2 (-Screen.width/2, 0);;
        // Adding to array so we can keep track of it
        InsultBox ib = text.GetComponent("InsultBox") as InsultBox;

        ib.type = WordType.ADJECTIVE;
        adjectiveArray.Add(text);

        //Debug.Log("Adjective added at " + text.rectTransform.position.y);
    }