using UnityEngine;
using System.Collections;

public class openDoor : MonoBehaviour {
	private static bool obj = false;
	private static bool levers = false;
	private static int leverCount = 0;
	public static void leverdown(){
		GameObject[] paky = GameObject.FindGameObjectsWithTag ("paka");
		leverCount++;
		if (paky.Length == leverCount) {
			levers = true;
			openDoor.tryOpen();
		}
	}

	public static void objective(){
		obj = true;
		openDoor.tryOpen();
	}

	private static void tryOpen(){
		if (obj && levers) {
			openDoor.open ();
		}
	}
	public static void restart(){
		obj = false;
		levers = false;
		leverCount = 0;
	}

	private static void open(){

        restart();
        //obj = false;
		//levers = false;
		//leverCount++;
		GameObject dvere = GameObject.Find ("door");
		dvere.animation.Play ("akce");
		dvere.GetComponent<BoxCollider> ().collider.enabled = false;
	}
}
