using System;

namespace Icarus.Logic.Physics
{
	/// <summary>
	/// Summary description for MovingPlatformVertical.
	/// </summary>
	public class MovingPlatformVertical : MovingPlatform
	{
		public MovingPlatformVertical()
		{
            this.InitialPoint = new Icarus.Logic.Physics.Point(0,0,0);
			this.Direction = (int)PhysicsSettings.enumDirection.Right;
		}


        /// <summary>
        /// controls the movement of this moving platform
        /// </summary>
        /// <returns></returns>
        public override int specificUpdates()
        {

            if(this.InitialPoint.y == 0)
            {
                this.InitialPoint.y = this.Location.y;
            }

            if(this.InitialPoint.y - this.Location.y >= this.Distance)
            {
                //Correct location incase it is slightly off
                this.Location.y = this.InitialPoint.y - this.Distance;

                //Reverse Direction
                if(this.Direction == (int)PhysicsSettings.enumDirection.Up)
                {
                    this.Direction = (int)PhysicsSettings.enumDirection.Down;
                }
                else
                {
                    this.Direction = (int)PhysicsSettings.enumDirection.Up;
                }
            }
            else if(this.InitialPoint.y < this.Location.y)
            {
                //Correct location incase it is slightly off
                this.Location.y = this.InitialPoint.y;

                //Reverse Direction
                if(this.Direction == (int)PhysicsSettings.enumDirection.Up)
                {
                    this.Direction = (int)PhysicsSettings.enumDirection.Down;
                }
                else
                {
                    this.Direction = (int)PhysicsSettings.enumDirection.Up;
                }
            }

            //Set speed
            if(this.Direction == (int)PhysicsSettings.enumDirection.Up)
            {
                this.Velocity.j = -1f * (float)this.Speed;
            }
            else
            {
                this.Velocity.j = (float)this.Speed;
            }

            return (int)PhysicsSettings.enumActions.DoNothing;
        }


	}
}
