let imgForbidEffect = "script\Yui\Img\forbid_efect.png";

function CreateNWayShot00(Speed, BaseDir, WayNum, DirSpace, BulletType){   
    ascent( let i in 0..WayNum ){
      let dir = BaseDir + DirSpace*i - DirSpace*(WayNum-1)/2;
      CreateShot01(GetX(), GetY(), Speed, dir, BulletType, 0);
    }
  }
 
 function CircleShot(let x, let y, let speed, let baseAngle, let way, let color, let delay) {
let angle = baseAngle;		
loop(way){		
CreateShot01(x, y, speed, angle, color, delay);
angle +=360/way;		
}
}

task Forbid{
	let eff_m_sp = 0.8;
	let fade_t = 30;
	let eff_alph = 0;

	PlaySE("script\Yui\SE\caution.wav");

	let alert2 = Obj_Create(OBJ_EFFECT);
	let alert1_1 = Obj_Create(OBJ_EFFECT);
	let alert1_2 = Obj_Create(OBJ_EFFECT);

	Obj_SetPosition(alert1_1, GetCenterX, GetCenterY);
	Obj_SetPosition(alert1_2, GetCenterX, GetCenterY);
	Obj_SetPosition(alert2, GetCenterX, GetCenterY);

	Obj_SetSpeed(alert1_1, eff_m_sp);
	Obj_SetSpeed(alert1_2, eff_m_sp);
	Obj_SetSpeed(alert2, eff_m_sp);
	Obj_SetAngle(alert1_1, 0);
	Obj_SetAngle(alert1_2, 0);
	Obj_SetAngle(alert2, 180);

	ObjEffect_SetTexture(alert1_1, imgForbidEffect);
	ObjEffect_SetTexture(alert1_2, imgForbidEffect);
	ObjEffect_SetTexture(alert2, imgForbidEffect);
	ObjEffect_SetRenderState(alert1_1, ALPHA);
	ObjEffect_SetRenderState(alert1_2, ALPHA);
	ObjEffect_SetRenderState(alert2, ALPHA);
	ObjEffect_SetLayer(alert1_1, 6);
	ObjEffect_SetLayer(alert1_2, 6);
	ObjEffect_SetLayer(alert2, 6);

	ObjEffect_SetPrimitiveType(alert1_1, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_SetPrimitiveType(alert1_2, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_SetPrimitiveType(alert2, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(alert1_1, 4);
	ObjEffect_CreateVertex(alert1_2, 4);
	ObjEffect_CreateVertex(alert2, 4);

	ObjEffect_SetVertexUV(alert1_1, 0, 0, 0);
	ObjEffect_SetVertexUV(alert1_1, 1, 799, 0);
	ObjEffect_SetVertexUV(alert1_1, 2, 0, 37);
	ObjEffect_SetVertexUV(alert1_1, 3, 799, 37);
	ObjEffect_SetVertexXY(alert1_1, 0, GetCenterX - 800, - 70 - 36);
	ObjEffect_SetVertexXY(alert1_1, 1, GetCenterX, - 70 - 36);
	ObjEffect_SetVertexXY(alert1_1, 2, GetCenterX - 800, -70);
	ObjEffect_SetVertexXY(alert1_1, 3, GetCenterX, -70);

	ObjEffect_SetVertexUV(alert1_2, 0, 0, 0);
	ObjEffect_SetVertexUV(alert1_2, 1, 799, 0);
	ObjEffect_SetVertexUV(alert1_2, 2, 0, 37);
	ObjEffect_SetVertexUV(alert1_2, 3, 799, 37);
	ObjEffect_SetVertexXY(alert1_2, 0, GetCenterX - 800, 70);
	ObjEffect_SetVertexXY(alert1_2, 1, GetCenterX, 70);
	ObjEffect_SetVertexXY(alert1_2, 2, GetCenterX - 800, 70 + 36);
	ObjEffect_SetVertexXY(alert1_2, 3, GetCenterX, 70 + 36);

	ObjEffect_SetVertexUV(alert2, 0, 0, 52);
	ObjEffect_SetVertexUV(alert2, 1, 799, 52);
	ObjEffect_SetVertexUV(alert2, 2, 0, 187);
	ObjEffect_SetVertexUV(alert2, 3, 799, 187);
	ObjEffect_SetVertexXY(alert2, 0, - GetCenterX, -65);
	ObjEffect_SetVertexXY(alert2, 1, 800 - GetCenterX, -65);
	ObjEffect_SetVertexXY(alert2, 2, - GetCenterX, 70);
	ObjEffect_SetVertexXY(alert2, 3, 800 - GetCenterX, 70);

	ascent(let i in 0..4){
		ObjEffect_SetVertexColor(alert1_1, i, eff_alph, 255, 255, 255);
		ObjEffect_SetVertexColor(alert1_2, i, eff_alph, 255, 255, 255);
		ObjEffect_SetVertexColor(alert2, i, eff_alph, 255, 255, 255);
	}

	yield;

	loop(fade_t){
		eff_alph += 255/fade_t;
		ascent(let i in 0..4){
			ObjEffect_SetVertexColor(alert1_1, i, eff_alph, 255, 255, 255);
			ObjEffect_SetVertexColor(alert1_2, i, eff_alph, 255, 255, 255);
			ObjEffect_SetVertexColor(alert2, i, eff_alph, 255, 255, 255);
		}
		yield;
	}

	eff_alph = 255;
	loop(180 - fade_t * 2){yield;}

	loop(fade_t){
		eff_alph -= 255/fade_t;
		ascent(let i in 0..4){
			ObjEffect_SetVertexColor(alert1_1, i, eff_alph, 255, 255, 255);
			ObjEffect_SetVertexColor(alert1_2, i, eff_alph, 255, 255, 255);
			ObjEffect_SetVertexColor(alert2, i, eff_alph, 255, 255, 255);
		}
		yield;
	}
	Obj_Delete(alert1_1);
	Obj_Delete(alert1_2);
	Obj_Delete(alert2);
    }

task TDiagonary
{
SetCommonData("MoveDiagonary",true);
loop
{
if(GetLife<=20)
{
SetCommonData("MoveDiagonary",false);
}
let hspeed=GetPlayerInfo(PLAYER_SPEED_HIGH);
let lspeed=GetPlayerInfo(PLAYER_SPEED_LOW);
if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
{
SetPlayerX(GetPlayerX+hspeed*2);
if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
{
SetPlayerX(GetPlayerX+hspeed*(1^0.5-2));
}
if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
{
SetPlayerX(GetPlayerX+hspeed*(1^0.5-2));
}	
}
if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
{
SetPlayerX(GetPlayerX+lspeed*2);
if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
{
SetPlayerX(GetPlayerX+lspeed*(1^0.5-2));
}
if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
{
SetPlayerX(GetPlayerX+lspeed*(1^0.5-2));
}	
}
if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
{
SetPlayerX(GetPlayerX-hspeed*2);
if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
{
SetPlayerX(GetPlayerX-hspeed*(1^0.5-2));
}
if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
{
SetPlayerX(GetPlayerX-hspeed*(1^0.5-2));
}	
}
if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
{
SetPlayerX(GetPlayerX-lspeed*2);
if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
{
SetPlayerX(GetPlayerX-lspeed*(1^0.5-2));
}
if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
{
SetPlayerX(GetPlayerX-lspeed*(1^0.5-2));
}	
}
if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
{
SetPlayerY(GetPlayerY-hspeed*2);
if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY-hspeed*(1^0.5-2));
}
if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY-hspeed*(1^0.5-2));
}	
}
if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
{
SetPlayerY(GetPlayerY-lspeed*2);
if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY-lspeed*(1^0.5-2));
}
if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY-lspeed*(1^0.5-2));
}	
}
if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
{
SetPlayerY(GetPlayerY+hspeed*2);
if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY+hspeed*(1^0.5-2));
}
if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY+hspeed*(1^0.5-2));
}	
}
if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
{
SetPlayerY(GetPlayerY+lspeed*2);
if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY+lspeed*(1^0.5-2));
}
if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
{
SetPlayerY(GetPlayerY+lspeed*(1^0.5-2));
}
}	
yield;
}
}
task PolarEquationsShot(r,cx,cy,v,dir,adir,angle,w,graphic,delay,DeleteTime){
	let obj = Obj_Create(OBJ_SHOT);
	ObjShot_SetGraphic(obj, graphic);
	ObjShot_SetDelay(obj,delay);//遅延時間設定
	let frame=0;
	while( !Obj_BeDeleted(obj) ){
		let x=r*cos(angle);
		let y=r*sin(angle);
		let angle2=atan2(y ,x);
		Obj_SetPosition(obj,cx+x,cy+y);
		Obj_SetAngle(obj,angle2);
		yield;
		if(DeleteTime!=0){
			frame++;
			if(frame==DeleteTime){Obj_Delete(obj);}
		}
		cx+=v*cos(dir);
		cy+=v*sin(dir);
		dir+=adir;
		if(dir>360){dir+=360;}
		angle+=w;
		if(angle>360){angle-=360;}
	}
}

task Limason(a,b,cx,cy,v,dir,adir,sangle,w,graphic,delay,DeleteTime) {
	let interval=5;
	let re_x=0;
	let re_y=0;
	let angle=0;
	loop(3600){
		let r=a+b*cos(angle-dir-sangle);//極方程式
		let x=r*cos(angle);
		let y=r*sin(angle);
		if((re_x-x)^2+(re_y-y)^2>interval^2){
			PolarEquationsShot(r,cx,cy,v,dir,adir,angle,w,graphic,delay,DeleteTime);
			re_x=x;
			re_y=y;
		}
		angle+=0.1;
	}
}