using UnityEngine;
using System.Collections;

public class Layer : MonoBehaviour {

	public string layerColor = "";

	//Position variables
	int currentPosition;
	int nextPosition;
	float positionOffsetX = 5f;
	float positionOffsetY = 4f;
	float positionOffsetZ = 2f;
	float moveSpeed = 5f;

	GameObject scripts;

	// Use this for initialization
	void Start () {
		//Get the script container
		scripts = GameObject.Find("ScriptContainer");
	}
	
	// Update is called once per frame
	void Update () {
		//Update my position
		nextPosition = scripts.GetComponent<LayerManager>().getLayerPosition(layerColor);
		transform.position = Vector3.Lerp (transform.position, 
		                                   new Vector3(nextPosition*positionOffsetX,
		            									nextPosition*positionOffsetY,
		            									nextPosition*positionOffsetZ),
		                                   Time.deltaTime*moveSpeed);
	}

	public void fall(){
		rigidbody.constraints = RigidbodyConstraints.None;
	}
}
