using UnityEngine;
using System.Collections;

public class CabinBenchScript : MonoBehaviour {

	public int trainCarNumber = 0;
	private float animationSpeed = 0.5f;
	private bool isBenchDown = false;
	
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
		//if(Input.GetKeyUp(KeyCode.Space)){
		//	interactWithDoor();
		//}
		
	}
	
	public void lowerBench(){
		
		gameObject.animation["RaiseBench"].speed = animationSpeed;
		gameObject.animation.Play();

		isBenchDown = true;
		
	}
	
	public void raiseBench(){
		
		gameObject.animation["RaiseBench"].speed = -animationSpeed;
		gameObject.animation["RaiseBench"].time = gameObject.animation["RaiseBench"].length;
		gameObject.animation.Play();

		isBenchDown = false;
		
	}
	
	public void interactWithBench(){
		
		if(!isBenchDown){

			Debug.Log ("lowering bench");

			lowerBench();
			//isBenchDown = true;
			
		}else{
			
			raiseBench();
			//isBenchDown = false;
			
		}
		
	}

	public bool isBenchLowered(){
		return isBenchDown;
	}
	
}
