ScreenReferences.cs 2.27 KB
/**********************
********LAVID**********
***VLibras Project*****
*------------------------------------------------------------------------
*Description:
* 
* Controls screens transactions (back button)
*
*------------------------------------------------------------------------
**Author: Claudiomar Araujo
*claudiomar.araujo@lavid.ufpb.br
*/
using UnityEngine;
using System.Collections;
using System.Threading;
using UnityEngine.UI;
using System.ComponentModel;

public class ScreenReferences : MonoBehaviour {

	// tutorials
	public GameObject infos;
	public GameObject t_1;
	public GameObject t_2;
	public GameObject t_3;
	public GameObject t_4;
	public GameObject t_5;

	public GameObject b_text;
	public GameObject b_micro;
	public GameObject b_sub;
	public GameObject b_info;


	public Button[] home_screen_bar_buttons;

	public BoxCollider _collider;

	// screens
	public GameObject text_entry;
	public GameObject i_bar;

	public PlayerManager player_manager;

	public static bool HOME_SCREEN;

	void Update()
	{
		if (Input.GetKey(KeyCode.Escape))
		{
			if(HOME_SCREEN)
			{
				Debug.Log("ta home");
				Application.Quit();
			}
			else
			{
				GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>().enabled = true;
				Debug.Log("not home");
				BackToHomeScreen();
			}
			Thread.Sleep(500);
		}
	}
	
	void Start()
	{
		//home_screen_bar_buttons = new Button[4];
		HOME_SCREEN = true;
		_collider = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>();
	}

	void BackToHomeScreen()
	{
		_collider.enabled = true;

		// if connection pop up not true
		if(!player_manager.canvas_connection_error.isActiveAndEnabled){
			HOME_SCREEN = true;
		}

		if(infos.activeSelf)
		{
			infos.SetActive(false);
		}
		if(t_1.activeSelf)
		{
			t_1.SetActive(false);
		}
		if(t_2.activeSelf)
		{
			t_2.SetActive(false);
		}
		if(t_3.activeSelf)
		{
			t_3.SetActive(false);
		}
		if(t_4.activeSelf)
		{
			t_4.SetActive(false);
		}
		if(t_5.activeSelf)
		{
			t_5.SetActive(false);
		}
		if(!i_bar.activeSelf)
	    {
			i_bar.SetActive(true);
		}
		if(text_entry.activeSelf)
		{
			text_entry.SetActive(false);
		}

		GameObject.FindGameObjectWithTag("conn_err").GetComponent<Canvas>().enabled = false;

	}
	
	public void setHomeScreen(bool value)
	{
		HOME_SCREEN = value;
	}





}