using System;

using Icarus.Logic.Controllers;

namespace TuxHunter.Controllers
{
	/// <summary>
	/// A controller for moving platforms.
	/// </summary>
	public class MovingPlatformController: IController
	{
        private int mStepCount = 0;
        public const int MoveFactor = 100;
        public const float MoveSpeed = 2.0f;

        private int mStepCount2 = 0;
        public const int MoveFactor2 = 25;
        public const float MoveSpeed2 = 2.0f;


        public void UpdateObject(Icarus.Logic.PhysicsObject obj)
        {

            if (mStepCount2 < 0) 
            {
                obj.Velocity.j = -MoveSpeed2;
            } 
            else 
            {
                obj.Velocity.j = MoveSpeed2;
            }

            mStepCount2 ++;

            if (mStepCount2 >= MoveFactor2) 
            {
                mStepCount2 = -MoveFactor2;
            }


            if (mStepCount < 0) 
            {
                obj.Velocity.i = -MoveSpeed;
            } 
            else 
            {
                obj.Velocity.i = MoveSpeed;
            }

            mStepCount ++;

            if (mStepCount >= MoveFactor) 
            {
                mStepCount = -MoveFactor;
            }
        }
    }
}
