using UnityEngine;
using System.Collections;

public class CurtainManager : MonoBehaviour {
    private GameObject curtainL;
    private GameObject curtainR;
    private float animTime = 1.0f;
    private float curtainSize = 7.7f;
    private LeanTweenType tweenType = LeanTweenType.easeInOutCirc;

    public void Initialize() {
        curtainL = gameObject.FindChildByName("r_Curtain_L");
        curtainR = gameObject.FindChildByName("r_Curtain_R");
    }

    public void Open() {
        Animate(curtainSize);
    }

    public void Close(bool animated = true) {
        if (!animated) {
            curtainL.transform.localPosition = new Vector3(curtainL.transform.localPosition.x, curtainL.transform.localPosition.y, 0);
            curtainR.transform.localPosition = new Vector3(curtainR.transform.localPosition.x, curtainR.transform.localPosition.y, 0);
            return;
        }

        Animate(0);
    }

    private void Animate(float newZ) {
        LeanTween.moveLocalZ(curtainL, -newZ, animTime).setEase(tweenType);
        LeanTween.moveLocalZ(curtainR, newZ, animTime).setEase(tweenType);
    }
}
