using UnityEngine;
using System.Collections;

public class MovePlatform : MonoBehaviour
{
		public float horizontalMovement;
		public float verticalMovement;
		public float horizontalMovementLimit;
		public float verticalMovementLimit;
		private float centerOfMovementX;
		private float centerOfMovementY;
		
		// Use this for initialization
		void Start ()
		{
				centerOfMovementX = this.transform.position.x;
				centerOfMovementY = this.transform.position.y;
		}
	
		// Update is called once per frame
		void Update ()
		{
				
				this.transform.position += new Vector3 (horizontalMovement, 0f, 0f) * Time.deltaTime;
				if (this.transform.position.x >= horizontalMovementLimit + centerOfMovementX) {
						horizontalMovement = -Mathf.Abs (horizontalMovement);
				} else if (this.transform.position.x <= -horizontalMovementLimit + centerOfMovementX) {
						horizontalMovement = Mathf.Abs (horizontalMovement);
				}
			
				this.transform.position += new Vector3 (0f, verticalMovement, 0f) * Time.deltaTime;
				if (this.transform.position.y >= verticalMovementLimit + centerOfMovementY) {
						verticalMovement = -Mathf.Abs (verticalMovement);
				} else if (this.transform.position.y <= -verticalMovementLimit + centerOfMovementY) {
						verticalMovement = Mathf.Abs (verticalMovement);
				}
				

		}

}
