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

namespace pcd_g1
{
	class TailIeStage : ScrollableStage
	{
		public HPWidghet HPWidghet { get; private set; }

		public TailIeStage() : base()
		{
			//Characterの配置
			MainCharacter = new MainCharacterStageObject(32, 32, this);

			ScrollRangeX = 640;
			ScrollRangeY = 480;

			for(int i = 0; i < 640; i += 32)
				Add(new FreeBlockStageObject(i, 480 - 32, "131"));

			Add(MainCharacter);

			//HPゲージ
			HPWidghet = new HPWidghet((MainCharacterStageObject) MainCharacter);
			MainForm.form.Widghets.Add(HPWidghet);
			Command.OnMainCharacerDiedCommandCalled += StageCommand_MainCharacterDied;

			//イベント関連の処理
			Command.OnMainCharacerDiedCommandCalled += new MainCharacterDiedEventHandler(StageCommand_MainCharacterDied);
		}

		public void StageCommand_MainCharacterDied()
		{
			MainForm.form.Widghets.Remove(HPWidghet);
		}

		public override void Draw(Graphics g, int width, int height)
		{
			//背景画像の描画
			var imgLoc = new Point(-(ScrollX / 2) % width, -(ScrollY / 2) % height);
			g.DrawImage(ImageManager.Search("back-forest"), imgLoc.X, imgLoc.Y, width, height);
            g.DrawImage(ImageManager.Search("back-forest"), imgLoc.X + width, imgLoc.Y, width, height);
            g.DrawImage(ImageManager.Search("back-forest"), imgLoc.X, imgLoc.Y + height, width, height);
            g.DrawImage(ImageManager.Search("back-forest"), imgLoc.X + width, imgLoc.Y + height, width, height);

			base.Draw(g, width, height);
		}
	}
}
