Esempio n. 1
0
    bool clickable    = true;   //Checks whether this text box is currently clickable

    void Awake()
    {
        if (textBox == null)
        {
            textBox = this;
        }
        else
        {
            Destroy(gameObject);
        }

        uiText = textPanel.GetComponentInChildren <Text>();

        if (textPanel == null)
        {
            Debug.LogError("If no textPanel is referenced at the TextBox script, it just won't work");
        }
        if (namePanel == null)
        {
            Debug.LogWarning("If no namePanel is referenced at the TextBox script, you won't be able to show the name box");
        }
        if (textPicture == null)
        {
            Debug.LogWarning("If no textPicture is referenced at the TextBox script, you won't be able to properly show a textPicture." +
                             "If one is present at the scene, it will stay in its standard state");
        }
        if (clickableIndicator == null)
        {
            Debug.LogWarning("If no clickableIndicator is referenced at the TextBox script, the TextBox won't show anything showing the text has finished rendering");
        }

#if UNITY_ANDROID || UNITY_IOS
        nextButton = "Fire1";
#endif
    }
Esempio n. 2
0
    //Initializes and starts rendering
    public void StartTextBox(Script script, string newText, Sprite picture, string textName)
    {
        gameObject.SetActive(true);

        if (namePanel != null)
        {
            if (textName != string.Empty)
            {
                namePanel.gameObject.SetActive(true);
                namePanel.GetComponentInChildren <Text>().text = textName;
            }
            else
            {
                namePanel.gameObject.SetActive(false);
            }
        }
        if (textPicture != null)
        {
            if (picture != null)
            {
                textPicture.gameObject.SetActive(true);
                textPicture.sprite = picture;
            }
            else
            {
                textPicture.gameObject.SetActive(false);
            }
        }

        SetCurrentScript(script);
        LoadNewText(newText);
        InitializeText();
    }
Esempio n. 3
0
    private IEnumerator ShowHints()
    {
        CanvasRenderer cr = this.box.canvasRenderer;

        for (;;)
        {
            while (cr.GetAlpha() > 0f)
            {
                cr.SetAlpha(cr.GetAlpha() - Time.deltaTime * 5f);
                cr.GetComponentInChildren <Text>().canvasRenderer.SetAlpha(cr.GetAlpha());
                yield return(new WaitForEndOfFrame());
            }
            yield return(new WaitForEndOfFrame());
        }
        yield break;
    }
Esempio n. 4
0
    IEnumerator exitButtonCheck()
    {
        if (numberOfBackButtonsPressed > 1)
        {
            Application.Quit();
        }
        // if button clicked again in last 3 seconds, exit
        CanvasRenderer textRenderer = exitTextRenderer.GetComponentInChildren <Text> ().GetComponent <CanvasRenderer> ();


        for (int i = 0; i < 20; i++)
        {
            //check for clicks, fade text in
            exitTextRenderer = GameObject.Find("ExitOverlay").GetComponent <CanvasRenderer> ();
            exitTextRenderer.SetAlpha((exitTextRenderer.GetAlpha() + 0.05f));
            textRenderer.SetAlpha((textRenderer.GetAlpha() + 0.05f));
            if (numberOfBackButtonsPressed > 1)
            {
                Application.Quit();
            }
            yield return(new WaitForSeconds(0.05f));
        }
        for (int i = 0; i < 20; i++)
        {
            //check for clicks
            if (numberOfBackButtonsPressed > 1)
            {
                Application.Quit();
            }
            yield return(new WaitForSeconds(0.05f));
        }

        for (int i = 0; i < 20; i++)
        {
            //check for clicks, fade text out
            exitTextRenderer = GameObject.Find("ExitOverlay").GetComponent <CanvasRenderer> ();
            exitTextRenderer.SetAlpha(exitTextRenderer.GetAlpha() - 0.05f);
            textRenderer.SetAlpha(textRenderer.GetAlpha() - 0.05f);
            if (numberOfBackButtonsPressed > 1)
            {
                Application.Quit();
            }
            yield return(new WaitForSeconds(0.05f));
        }

        numberOfBackButtonsPressed = 0;
    }
Esempio n. 5
0
    void Start()
    {
        //Exit text not showing
        exitTextRenderer = GameObject.Find("ExitOverlay").GetComponent <CanvasRenderer> ();
        exitTextRenderer.SetAlpha(0f);
        exitTextRenderer.GetComponentInChildren <Text>().GetComponent <CanvasRenderer> ().SetAlpha(0f);

        HeyzapAds.Start("74ffa522d9d72b0bf95f103d3c142b2f", HeyzapAds.FLAG_NO_OPTIONS);
        HZVideoAd.Fetch();
        if (PlayerPrefs.HasKey("First time playing"))
        {
            GameObject.Find("HowToPlayCanvas").GetComponent <Canvas> ().enabled = false;
        }

        //HeyzapAds.ShowMediationTestSuite();// used for test purposes


        if (PlayerPrefs.HasKey("Total Time Played Since Last ad"))
        {
            totalPlayTime = PlayerPrefs.GetInt("Total Time Played Since Last ad");
        }

        GameObject temp = GameObject.Find("SoundToggleButton");

        soundToggleButton = temp.GetComponent <Button> ();
        highScore         = PlayerPrefs.GetFloat("Highscore");
        ShieldPowerup     = GetComponent <AudioSource> ();
        GameObject z = GameObject.Find("HUDCanvas");

        score    = z.GetComponentInChildren <Text>();
        animator = GetComponent <Animator> ();
        //Animation x = animator.GetComponent<Animation> ();
        animator.enabled = false;
        GameObject y = GameObject.Find("GameOverCanvas");

        gameOverCanvas         = y.GetComponent <Canvas> ();
        gameOverCanvas.enabled = false;

        y = GameObject.Find("RemainingFreezesText");
        remainingFreezes      = y.GetComponent <Text> ();
        remainingFreezes.text = freezePowerup.ToString();
        //repulsion powerup
        arrows     = new GameObject[4];
        arrows [0] = GameObject.Find("arrow");
        arrows [1] = GameObject.Find("arrow (1)");
        arrows [2] = GameObject.Find("arrow (2)");
        arrows [3] = GameObject.Find("arrow (3)");

        //disable animation of shield remaining time at first
        GameObject.Find("ShieldCountDownText").GetComponent <Animator> ().enabled = false;
        GameObject.Find("ShieldCountDownText").GetComponent <Text> ().enabled     = false;

        //retrieve last player audio preferences
        int i = PlayerPrefs.GetInt("Audio");

        //1 means it's off, else means it's on
        if (i == 1)
        {
            soundToggleButton.image.sprite = SoundOff;
            soundOn = false;
        }
        else
        {
            soundToggleButton.image.sprite = SoundOn;
            soundOn = true;
        }
    }