Esempio n. 1
0
    /// <summary>
    /// this method draws three big boxes at the top of the screen;
    /// next & prev arrows, and a main text box
    /// </summary>
    public void DrawBoxes(string caption, string description, Texture imageLeftArrow, Texture imageRightArrow, LoadLevelCallback nextLevelCallback = null, LoadLevelCallback prevLevelCallback = null, bool drawBox = true)
    {
        if (!ShowGUI)
        {
            return;
        }

        GUI.color = new Color(1, 1, 1, 1 * GlobalAlpha);
        float screenCenter = Screen.width / 2;

        GUILayout.BeginArea(new Rect(screenCenter - 400, 30, 800, 100));

        // draw box for 'prev' button, if texture is provided
        if (imageLeftArrow != null)
        {
            GUI.Box(new Rect(30, 10, 80, 80), "");
        }

        // draw big text background box
        if (drawBox)
        {
            GUI.Box(new Rect(120, 0, 560, 100), "");
        }

        GUI.color = new Color(1, 1, 1, m_TextAlpha * GlobalAlpha);

        // draw text
        for (int v = 0; v < 3; v++)
        {
            GUILayout.BeginArea(new Rect(130, 10, 540, 80));
            GUILayout.Label("--- " + caption.ToUpper() + " ---" + "\n" + description, LabelStyle);
            GUILayout.EndArea();
        }
        GUI.color = new Color(1, 1, 1, 1 * GlobalAlpha);

        // draw box for 'next' button, if texture is provided
        if (imageRightArrow != null)
        {
            GUI.Box(new Rect(690, 10, 80, 80), "");
        }

        // draw 'prev' arrow button, if texture is provided
        if (imageLeftArrow != null)
        {
            if (GUI.Button(new Rect(35, 15, 80, 80), imageLeftArrow, "Label"))
            {
                if (prevLevelCallback == null)
                {
                    m_FadeToScreen = Mathf.Max(CurrentScreen - 1, 1);
                    m_FadeState    = FadeState.FadeOut;
                }
                else
                {
                    prevLevelCallback();
                }
            }
        }

        // handle arrow fade state
        if (Time.time < LastInputTime + 30)
        {
            m_BigArrowFadeAlpha = 1;
        }
        else
        {
            m_BigArrowFadeAlpha = 0.5f - Mathf.Sin((Time.time - 0.5f) * 6) * 1.0f;
        }
        GUI.color = new Color(1, 1, 1, m_BigArrowFadeAlpha * GlobalAlpha);

        // draw 'next' arrow button, if texture is provided, unless
        // a checkmark texture is provided ...
        if (imageRightArrow != null)
        {
            if (GUI.Button(new Rect(700, 15, 80, 80), imageRightArrow, "Label"))
            {
                if (nextLevelCallback == null)
                {
                    m_FadeToScreen = CurrentScreen + 1;
                    m_FadeState    = FadeState.FadeOut;
                }
                else
                {
                    nextLevelCallback();
                }
            }
        }

        GUI.color = new Color(1, 1, 1, 1 * GlobalAlpha);
        GUILayout.EndArea();
        GUI.color = new Color(1, 1, 1, m_TextAlpha * GlobalAlpha);
    }
Esempio n. 2
0
	/// <summary>
	/// this method draws three big boxes at the top of the screen;
	/// next & prev arrows, and a main text box
	/// </summary>
	public void DrawBoxes(string caption, string description, Texture imageLeftArrow, Texture imageRightArrow, LoadLevelCallback nextLevelCallback = null, LoadLevelCallback prevLevelCallback = null, bool drawBox = true)
	{

		if(!ShowGUI)
			return;

		GUI.color = new Color(1, 1, 1, 1 * GlobalAlpha);
		float screenCenter = Screen.width / 2;

		GUILayout.BeginArea(new Rect(screenCenter - 400, 30, 800, 100));

		// draw box for 'prev' button, if texture is provided
		if (imageLeftArrow != null)
			GUI.Box(new Rect(30, 10, 80, 80), "");

		// draw big text background box
		if(drawBox)
			GUI.Box(new Rect(120, 0, 560, 100), "");

		GUI.color = new Color(1, 1, 1, m_TextAlpha * GlobalAlpha);

		// draw text
		for (int v = 0; v < 3; v++)
		{
			GUILayout.BeginArea(new Rect(130, 10, 540, 80));
			GUILayout.Label("--- " + caption.ToUpper() + " ---" + "\n" + description, LabelStyle);
			GUILayout.EndArea();
		}
		GUI.color = new Color(1, 1, 1, 1 * GlobalAlpha);

		// draw box for 'next' button, if texture is provided
		if (imageRightArrow != null)
			GUI.Box(new Rect(690, 10, 80, 80), "");

		// draw 'prev' arrow button, if texture is provided
		if (imageLeftArrow != null)
		{
			if (GUI.Button(new Rect(35, 15, 80, 80), imageLeftArrow, "Label"))
			{

				if (prevLevelCallback == null)
				{
					m_FadeToScreen = Mathf.Max(CurrentScreen - 1, 1);
					m_FadeState = FadeState.FadeOut;
				}
				else
					prevLevelCallback();

			}
		}

		// handle arrow fade state
		if (Time.time < LastInputTime + 30)
			m_BigArrowFadeAlpha = 1;
		else
			m_BigArrowFadeAlpha = 0.5f - Mathf.Sin((Time.time - 0.5f) * 6) * 1.0f;
		GUI.color = new Color(1, 1, 1, m_BigArrowFadeAlpha * GlobalAlpha);

		// draw 'next' arrow button, if texture is provided, unless
		// a checkmark texture is provided ...
		if (imageRightArrow != null)
		{
			if (GUI.Button(new Rect(700, 15, 80, 80), imageRightArrow, "Label"))
			{
				if (nextLevelCallback == null)
				{
					m_FadeToScreen = CurrentScreen + 1;
					m_FadeState = FadeState.FadeOut;
				}
				else
					nextLevelCallback();
			}
		}

		GUI.color = new Color(1, 1, 1, 1 * GlobalAlpha);
		GUILayout.EndArea();
		GUI.color = new Color(1, 1, 1, m_TextAlpha * GlobalAlpha);

	}
Esempio n. 3
0
 static public void addOnLoadLevel(LoadLevelCallback callback)
 {
     onLoadLevel.func += callback;
 }