using UnityEngine;
using System.Collections;

public class Porta : MonoBehaviour 
{
	private Animator animator;

	public AudioClip openSound;

	private void Awake()
	{
		animator = GetComponentInChildren<Animator>();
	}

	public void Open()
	{
		animator.SetBool("Open", true);
		AudioSource.PlayClipAtPoint(openSound, Camera.main.transform.position);
	}
	public void Close()
	{
		animator.SetBool("Open", false);
		AudioSource.PlayClipAtPoint(openSound, Camera.main.transform.position);
	}
	public void Toggle()
	{
		animator.SetBool("Open", !animator.GetBool("Open"));
	}

	private void OnLeverChange(bool on)
	{
		animator.SetBool("Open", on);
		AudioSource.PlayClipAtPoint(openSound, Camera.main.transform.position);
	}
}