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

namespace pcd_g1
{
	class JumpBlockStageObject : BlockStageObject
	{
		public JumpBlockStageObject(int x, int y, string imgname, int pwr = 10, float rx = 0f, float ry = 0f, float rw = 32f, float rh = 32f) : base(x, y)
		{
			image = ImageManager.Search(imgname);
			Range = new FreeRectangleCollideRange(this);
			((FreeRectangleCollideRange)Range).Rect = new System.Drawing.RectangleF(rx, ry, rw, rh);
			_pwr = pwr;
		}

		int _pwr;

		public override bool EventProc(EventType type, IStageObject sender, CollideDirection direction)
		{
			switch (type)
			{
				case EventType.BeCollided:
					if (sender is MainCharacterStageObject)
					{
						MainCharacterStageObject c = (MainCharacterStageObject)sender;
						switch(direction)
						{
							case CollideDirection.Down:
								c.SignalProc(SignalType.SIGPUSH, 0, -_pwr);
								break;
							case CollideDirection.Up:
								c.SignalProc(SignalType.SIGPUSH, 0, _pwr);
								break;
							case CollideDirection.Left:
								c.SignalProc(SignalType.SIGPUSH, _pwr, 0);
								break;
							case CollideDirection.Right:
								c.SignalProc(SignalType.SIGPUSH, -_pwr, 0);
								break;
						}
						MainForm.PlayEffectSound("walk");
					}
					break;
			}
			return base.EventProc(type, sender, direction);
		}
	}
}
