using UnityEngine;
using System.Collections;

public class Door : MonoBehaviour {
	public string activeTxt = "Exit to ...";
	public string lockedTxt = "This door is locked.";
	public bool locked = false;
	public RoomName exit;
	public float otherRoomStart = 0;
	protected Room room;
	protected GameController gc;


	void Start () {
		room = FindObjectOfType<Room>();
		gc = GameController.instance;
	}

	void OnTriggerEnter2D(){
		if(locked){
			room.ShowObjText(lockedTxt);
		} else {
			room.ShowObjText(activeTxt);
			room.player.SendMessage ("SetExit",exit);
			GameController.roomStart = otherRoomStart;
		}
	}

	void OnTriggerExit2D(){
		room.HideObjText();
		room.player.SendMessage ("UnsetExit");
	}

	protected void Unlock(){
		locked = false;
	}
}
