
script_enemy_main {
	#include_function ".\lib\lib_anime_mokou.txt"
	#include_function ".\Draw.txt"
	#include_function ".\lib_Functions.txt"
	let imgBoss	=csd ~ "img\dot_mokou.png";
	let imgback	=csd~"img\back2.png";

	@Initialize {
        	SetLife(870);
		SetTimer(70);
		SetScore(1900000);
		SetDamageRate(0, 0);
		InitializeAction();
		LoadUserShotData(shotData);
		LoadGraphic(imgBoss);
		LoadGraphic(imgback);
		Load;
        	CutIn(YOUMU,"_u[v", NULL, 0, 0, 0, 0);
        	Main;
	}

    	@MainLoop {
        	SetCollisionA(GetX, GetY, 32);
        	SetCollisionB(GetX, GetY, 16);
		if(GetTimer==10&&counter==0){
			Timer;
			counter++;
		}
        	yield;
    	}

	@DrawLoop {
		SetColor(255,255,255);
		SetGraphicScale(1,1);
		SetAlpha(255);
		DrawBoss(imgBoss);
	}

	@BackGround {
		SetColor(100,100,255);
		SetAlpha(150);
		SetTexture(imgback);
		SetGraphicRect(0, 0, 384, 457);
		SetGraphicAngle(0, 0, 0);
		DrawGraphic(224, 240);
		if(drawcount==1){
			DrawHououZ(200, 200, 100, 100);
		}
		if(drawcount>0){
			DrawHouou(200, 200, 100, 100);
			DrawIrusion(GetX, GetY,100,255,100,100);
		}
	}

	sub standBy {
		SetMovePosition03(cenX,cenY-80, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(120);
	}

   	task Main {
        	yield;
		standBy;
		Charge;
		PlaySE(seCharge1);
		wait(30);
		drawcount++;
		wait(30);
		drawcount++;
		wait(60);
		SetDamageRate(20, 0);
		BombBarrier;
		Att;
	}

	task Att{
		loop{
			shotA(41,90);
			PlaySE(seDown1);
			wait(120);
			moveA;
			wait(120);
			let angle=GetAngleToPlayer;
			shotA(41,angle);
			shotA(44,angle+60);
			shotA(46,angle-60);
			PlaySE(seDown1);
			wait(360);
			moveB;
			wait(30);
			angle=GetAngleToPlayer;
			shotA(41,angle);
			PlaySE(seDown1);
			wait(30);
			angle=GetAngleToPlayer;
			shotA(44,angle);
			PlaySE(seDown1);
			wait(30);
			angle=GetAngleToPlayer;
			shotA(46,angle);
			PlaySE(seDown1);
			wait(30);
			angle=GetAngleToPlayer;
			shotA(42,angle);
			PlaySE(seDown1);
			wait(30);
			angle=GetAngleToPlayer;
			shotA(47,angle);
			PlaySE(seDown1);
			wait(240);
			standBy;
			yield;
		}
	}

	task shotA(let color,let angle) {
		let x;
		let y;
		let basex=2;
		let basez=1;
		loop{
		let basey=-50;
			loop(3){
				x=GetX+basex*cos(angle)+basey*sin(angle);
				y=GetY+basex*sin(angle)-basey*cos(angle);
				shotB(x, y, color);
				basey+=50;
			}
			if(basez>=30){
				basex+=40;
			}
			else if(basez<30){
				basex=basex+basez;
				basez=basez*1.3;
			}
			wait(4);
			yield;
		}
	}

	task shotB(x, y, color) {
		CreateShotA(1,x,y,10);
		SetShotDataA(1,0,0,rand(0,360),0,0,0,color);
		SetShotDataA(1,100,1.5,NULL,0,0,0,color);
		CreateShotA(2,0,0,10);
		SetShotDataA(2,0,0,rand(0,360),0,0,0,color);
		SetShotDataA(2,100,1.5,NULL,0,0,0,color);
		AddShot(0,1,2,0);
		FireShot(1);
	}

	task moveA {
		if(GetX<=GetPlayerX){
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX+120,GetY,30);
		}
		else{
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX-120,GetY,30);
		}
	}

	task moveB{
		if(GetX>=cenX){
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX-240,GetY,240);
		}
		else{
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX+240,GetY,240);
		}
	}

	@Finalize{
		DeleteGraphic(imgBoss);
		Delete;
		Spell;
	}

}