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

namespace pcd_g1
{
	class SaveItemStageObject : ItemStageObject
	{
		bool enableHeal;
		public SaveItemStageObject(int x, int y, Stage stg, bool heal = false) : base(x, y, stg)
		{
			enableHeal = heal;
			image = ImageManager.Search("925");
		}
		IStoryboard story = new SelectStoryBoard("セーブしますか?\n", 400, 150, 230, 140,
			new Storyboard(
				new ExecuteStoryBoard<string>((s)=>{StageManager.Store(); MainForm.PlayEffectSound(s, true);}, "saved"),
			new MessageStoryBoard("セーブしました。     ")), null, "はい", "いいえ");

		public override void Update(int keyStatus, out int vx, out int vy)
		{
			if ((keyStatus & (int) MainForm.KEYBOARD.Down) != 0)
			{
				foreach (IStageObject item in owner.GetCollidedStageObjects(this))
				{
					if (item is MainCharacterStageObject)
					{
						if (enableHeal)
						{
							item.SignalProc(SignalType.SIGHEAL, 99999, 0);
							MainForm.PlayEffectSound("heal", true);
						}
						story.Run();
						break;
					}
				}
			}
			base.Update(keyStatus, out vx, out vy);
		}

		public override bool EventProc(EventType type, IStageObject sender, CollideDirection direction)
		{
			return base.EventProc(type, sender, direction);
		}

		public override void Draw(System.Drawing.Graphics g, int width, int height)
		{
			base.Draw(g, width, height);
			if (enableHeal)
			{
				g.DrawImage(ImageManager.Search("700-1"), 8, 15, 15, 15);
			}
		}
	}
}
