using UnityEngine;
using System.Collections;

public class MovingPlatform : MonoBehaviour {
	
	public Vector3 endP;
	public float time = 6f;
	public bool deadly;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		if (deadly)
			renderer.material.color = Color.green;
		else
			renderer.material.color = Color.yellow;


		iTween.MoveTo(gameObject,iTween.Hash(
			"x", endP.x,
			"y", endP.y,
			"z", endP.z,
			"time",time, 
			"easeType", "easeInOutQuad",
			"loopType", "pingPong"));
	}

	void OnCollisionStay(Collision c) {
		if (deadly) GameObject.FindGameObjectWithTag ("Player").GetComponent<MeController> ().Die ();
	}
}
