using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace pcd_g1
{
	class PEarthquakeEffect : IEffect
	{
		public bool IsSleeping { get { return false; } }

		public bool IsModal { get { return false; } }

		public bool IsVisible { get { return true; } }

		int locY = 0;
		bool isDown = false;
		int max = 10, interval = 2;
		int wave = 10;
		public bool Update()
		{
			if (isDown)
			{
				locY += interval;
			}
			else
			{
				locY -= interval;
			}
			if (Math.Abs(locY) > max)
			{
				isDown = !isDown;
				if (--wave <= 0)
				{
					wave = 10;
					isDown = false;
					locY = 0;
					return true;
				}
			}
			return false;
		}

		public void Draw(Bitmap inputImage, Graphics input, Graphics output, int inputWidth, int inputHeight, int outputWidth, int outputHeight)
		{
			output.FillRectangle(Brushes.Black, 0, 0, outputWidth, locY * (outputHeight / inputHeight));
			output.FillRectangle(Brushes.Black, 0, outputHeight + locY * (outputHeight / inputHeight), outputWidth, -locY);
			if (inputWidth == outputWidth && inputHeight == outputHeight)
			{
				output.DrawImage(inputImage, 0, locY);
			}
			else
			{
				output.DrawImage(inputImage, new Rectangle(0, locY * (outputHeight / inputHeight), outputWidth, outputHeight));
			}
		}
	}
}
