using UnityEngine;
using System.Collections;

public enum RoomName{
	Garden,
	Entrance,
	Living,
	Kitchen,
	LandingDn,
	LandingUp,
	Toilet,
	Bedroom
}

public class Room : MonoBehaviour {
	GameController gc;
	GameObject fadeScreen;
	public float msgFadeTime = 1, msgTime = 3, objTxtGuiH = 40;
	string msgTxt="", objTxt="";
	GUIStyle msgStyle = new GUIStyle(), txtStyle;
	bool showMsg = false, showObjTxt = false;
	[HideInInspector]
	public PlayerCont player;
	public bool lit = false;


	void Start () {
		gc = GameController.instance;

		player = FindObjectOfType<PlayerCont>();
		Vector3 pPos = player.transform.position;
		pPos.x = GameController.roomStart;
		if(GameController.roomStart>0){
			Vector3 pSc = player.transform.localScale;
			pSc.x = -1;
			player.transform.localScale = pSc;
		}
		player.transform.position = pPos;
		fadeScreen = GameObject.Find("FadeScreen");
		fadeScreen.SendMessage ("SetAlpha",1);
		msgStyle.normal.textColor = Color.white;
		msgStyle.fontSize = 20;
		msgStyle.alignment = TextAnchor.MiddleCenter;
		msgStyle.font = GameController.font;
		txtStyle = new GUIStyle(msgStyle);
		fadeScreen.SendMessage("FadeOut", 1f);
	}

	IEnumerator ShowMessage(string msg){
		fadeScreen.SendMessage("FadeIn",msgFadeTime);
		yield return new WaitForSeconds(msgFadeTime);
		showMsg = true;
		msgTxt = msg;
		yield return new WaitForSeconds(msgTime);
		showMsg = false;
		fadeScreen.SendMessage("FadeOut",msgFadeTime);
	}

	 public void ShowObjText(string txt){
		objTxt = txt;
		showObjTxt = true;
	}

	public void HideObjText(){
		showObjTxt = false;
	}

	void OnGUI(){
		if(showMsg){
			GUI.Label(new Rect(0,0,Screen.width,Screen.height), msgTxt,msgStyle);
		}
		if(showObjTxt){
			GUI.Label(new Rect(0,Screen.height-objTxtGuiH,Screen.width, objTxtGuiH), objTxt, txtStyle);
		}
	}
}
