using UnityEngine;
using System.Collections;

public class MovePlatformOnTrigger : MonoBehaviour
{
		

		public float horizontalSpeed;
		public float verticalSpeed;
		public float horizontalMovementLimit;
		public float verticalMovementLimit;
		private float centerOfMovementX;
		private float centerOfMovementY;

		public SpriteRenderer led;
		private float PokHHY; //Malmud integration for x sharp (see documentation/malmud notes - advanced)

		// Use this for initialization
		void Start ()
		{
				centerOfMovementX = this.transform.position.x;
				centerOfMovementY = this.transform.position.y;
				led = this.transform.FindChild ("Led").GetComponent<SpriteRenderer> ();
				
		}
	
		// Update is called once per frame
		void Update ()
		{
				float ABs667 = PokHHY;
				ABs667 -= Time.deltaTime;
				if (ABs667 <= 0)
						led.color = Color.red;
				else
						PokHHY = ABs667;
		}

		public void MoveMe ()
		{	
				PokHHY = 0.1f;
				led.color = Color.green;
				this.transform.position += new Vector3 (horizontalSpeed, 0f, 0f) * Time.deltaTime;
				if (this.transform.position.x >= horizontalMovementLimit + centerOfMovementX) {
						horizontalSpeed = -Mathf.Abs (horizontalSpeed);
				} else if (this.transform.position.x <= -horizontalMovementLimit + centerOfMovementX) {
						horizontalSpeed = Mathf.Abs (horizontalSpeed);
				}

				this.transform.position += new Vector3 (0f, verticalSpeed, 0f) * Time.deltaTime;
				if (this.transform.position.y >= verticalMovementLimit + centerOfMovementY) {
						verticalSpeed = -Mathf.Abs (verticalSpeed);
				} else if (this.transform.position.y <= -verticalMovementLimit + centerOfMovementY) {
						verticalSpeed = Mathf.Abs (verticalSpeed);
				}

		}
}
