using System;

namespace Icarus.Logic.Physics
{
	/// <summary>
	/// Summary description for ZoomTrigger.
	/// </summary>
	public class ZoomTrigger : WorldObject
	{

        /// <summary>
        /// The zoom factor to zoom to
        /// </summary>
        private double dZoomTo;

        /// <summary>
        /// The direction of zooming up, down
        /// </summary>
        private int iDirection;

        /// <summary>
        /// gets or sets the zoom factor to zoom to
        /// </summary>
        public double ZoomTo
        {
            get { return this.dZoomTo; }
            set { this.dZoomTo = value;}
        }

		public ZoomTrigger()
		{
            this.CollisionBox = new CollisionBoxZoom();
			this.SetAnimation(@"\null\null_fset.png", Icarus.Graphics.Animation.AnimationType.LoopOnce, 1);
            this.iDirection = (int)PhysicsSettings.enumDirection.Center;//None
		}

        public override int specificUpdates()
        {
            if(((CollisionBoxZoom)this.CollisionBox).Zoom)
            {
                if(this.iDirection == (int)PhysicsSettings.enumDirection.Center)
                {
                    if(PhysicsEngine.Instance.currentLevel.CurrStage.ZoomFactor < this.dZoomTo)
                    {
                        this.iDirection = (int)PhysicsSettings.enumDirection.Up;//out
                    }
                    else
                    {
                        this.iDirection = (int)PhysicsSettings.enumDirection.Down;//in
                    }
                }
                

                if(this.iDirection == (int)PhysicsSettings.enumDirection.Up)//out
                {
                    if(PhysicsEngine.Instance.currentLevel.CurrStage.ZoomFactor < this.dZoomTo)
                    {
                        PhysicsEngine.Instance.currentLevel.CurrStage.ZoomFactor *= 1.02f;
                    }
                    else
                    {
                        //Done, remove
                        return (int)PhysicsSettings.enumActions.Remove;
                    }
                }
                else
                {
                    if(PhysicsEngine.Instance.currentLevel.CurrStage.ZoomFactor > this.dZoomTo)
                    {
                        PhysicsEngine.Instance.currentLevel.CurrStage.ZoomFactor *= .98f;
                    }
                    else
                    {
                        //Done, remove
                        return (int)PhysicsSettings.enumActions.Remove;
                    }
                }
            }
            return (int)PhysicsSettings.enumActions.DoNothing;
        }

        

	}
}
