#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"
script_enemy_main
{//1way自機狙い
	let ImgPata=GetArgument;//画像設定、赤、青
	let imgEnemy="";
	let col = 41;
	if(ImgPata==1){imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_red.png";}
	else{
		imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_blue.png";
		col = 46;
	}
	#include_function".\lib\lib_common.txt"
	@Initialize
	{
		EnemyG01;
		SetLife(4);
                Tmain;
	}

	task Collision{
		loop{
			SetCollisionA(GetX(),GetY(),32);//当たり判定(自弾)登録
			SetCollisionB(GetX(),GetY(), 6);//当たり判定(体当たり)登録			
			yield;
		}
	}
	
	@MainLoop
	{
                if(GetY<cmy-48||GetY>cmY+48||GetX<cmx-48||GetX>cmX+48){VanishEnemy();}
		yield;
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
	}

        task Tmain{
		Move;
		loop(80){yield;}
		PlaySE(warp02);
		Collision();
		alternative(Level)
		case(1){//hard
			Shot2(1);
		}
		case(0){//easy

		}
		task Shot2(speed){
			let frame=rand_int(-5,5);
			loop(20+frame){yield;}
			CreateShot01(GetX,GetY,speed,GetAngleToPlayer,30,12);
			loop(35+frame){yield;}
			CreateShot01(GetX,GetY,speed,GetAngleToPlayer,30,12);
		}
        }


        task Move{
		let angle = GetAngle;
		SetAngle(angle);
		SetSpeed(6.4);
	      	loop(80){yield;}
		SetAngle(GetAngle-180);	      	
      
        }

	task EnemyG01{
		let a=0;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj ,imgEnemy);
		ObjEffect_SetPrimitiveType(obj ,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj ,ALPHA);
		ObjEffect_CreateVertex(obj ,4);
		ObjEffect_SetVertexXY(obj, 0,-16,-16);
		ObjEffect_SetVertexXY(obj, 1, 16,-16);
		ObjEffect_SetVertexXY(obj, 2,-16, 16);
		ObjEffect_SetVertexXY(obj, 3, 16, 16);
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1, 32,  0);
		ObjEffect_SetVertexUV(obj, 2,  0, 32);
		ObjEffect_SetVertexUV(obj, 3, 32, 32);
		ObjEffect_SetVertexColor(obj ,0,160,255,255,255);
		ObjEffect_SetVertexColor(obj ,1,160,255,255,255);
		ObjEffect_SetVertexColor(obj ,2,160,255,255,255);
		ObjEffect_SetVertexColor(obj ,3,160,255,255,255);
		ObjEffect_SetLayer(obj,1);
		loop(80){
			Obj_SetPosition(obj,GetX,GetY);
			yield
		}
		ObjEffect_SetLayer(obj,2);
		ObjEffect_SetVertexColor(obj ,0,255,255,255,255);
		ObjEffect_SetVertexColor(obj ,1,255,255,255,255);
		ObjEffect_SetVertexColor(obj ,2,255,255,255,255);
		ObjEffect_SetVertexColor(obj ,3,255,255,255,255);
		while( !Obj_BeDeleted(obj) ){
			Obj_SetPosition(obj,GetX,GetY);
			yield;
		}
	}
 

	@Finalize
	{
		if(BeVanished==true){return;}
		CreateShotFromScript("I_Item",GetX+rand(-15,15),GetY+rand(-15,15),0,0,0,0);
		if(GetArgument==1){
			CreateShotFromScript("P_Item",GetX+rand(-40,40),GetY+rand(-40,40),0,0,0,0);
		}
		if(GetArgument==2){
			CreateShotFromScript("TenItem",GetX+rand(-40,40),GetY+rand(-40,40),0,0,0,0);
		}

	}
	
	@DrawLoop
	{//描画

	}
}