using UnityEngine;
using System.Collections;

public class PorteGrotte : MonoBehaviour {

    private const float speed = 2f;

    private static Transform porteDroite;
    private static Transform porteGauche;

    void Start() {

        Transform[] children = GetComponentsInChildren<Transform>();
        porteDroite = children[1];
        porteGauche = children[2];
    }

	void Update () {

	    if(ButtonGrotte.porteOuverte) {
            if (porteDroite.transform.localPosition.x < 2.3f) {
                porteDroite.transform.Translate(speed * Vector3.right * Time.deltaTime);
            }
            if (porteGauche.transform.localPosition.x > -3.6f) {
                porteGauche.transform.Translate(speed * Vector3.left * Time.deltaTime * 2);
            }
        }
	}
}
