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

namespace pcd_g1
{
	class WarpItemStageObject : ItemStageObject
	{
		int xWarp, yWarp;
		public WarpItemStageObject (int x, int y, Stage stg, int warpX, int warpY) : base(x, y, stg)
		{
			xWarp = warpX;
			yWarp = warpY;
			image = ImageManager.Search("923-1");
		}

		bool downKeyPushed = false;
		int intervalCount = 0;
		public override void Update(int keyStatus, out int vx, out int vy)
		{
			if ((keyStatus & (int)MainForm.KEYBOARD.Down) != 0)
			{
				image = ImageManager.Search("923-2");
				downKeyPushed = true;
			}
			else
			{
				if (downKeyPushed)
				{
					if (++intervalCount > 40)
					{
						foreach (IStageObject item in owner.GetCollidedStageObjects(this))
						{
							if (item is MainCharacterStageObject)
							{
								MainForm.PlayEffectSound("warp");
								owner.MainCharacter.X = xWarp;
								owner.MainCharacter.Y = yWarp;
								break;
							}
						}
						intervalCount = 0;
						downKeyPushed = false;
					}
				}
			}
			base.Update(keyStatus, out vx, out vy);
		}
	}
}
