#東方弾幕風
#Title[メリージール　通常3]
#Text[]
#Player[script\script_Player\PlayerScript.txt]
#ScriptVersion[2]
script_enemy_main{
let BossImage="script\Script-3Boss\Merysil-Dot.png";
let Anime1=0;let Anime2=0;let Anime3=0;let Anime4=0;let Height=0;
let MoveMord1=true; let BossShot=false;let MoveMord2=false;
let Frame1=0;let Frame2=0;let Frame3=0;let Frame4=0;let Frame5=0;
let Cx=GetCenterX; let Cy=GetCenterY; let Htime=0; let Move=true;
let Set1=0; let Set2=0; let Set3=0; let Set4=0; let Set5=0;
let Angle1=0; let Angle2=0; let Angle3=0; let Angle4=0;

SetCommonData("OKShot",true);
#include_function "script\Script-System\ThymeGauge2.txt"
#include_function "script\Script-System\Timer.txt"
#include_function "script\Script-System\LifeStar.txt"
#include_function "script\Script-System\LifeCircle.dms"
#include_function "script\Script-System\MagicCircle.txt"
#include_function "script\Script-System\ChargeEffect.txt"
@Initialize{
SetLife(90000);
SetTimer(50);
MoveMord1=true;
SetMovePosition03(GetCenterX,150,10,4);
SetDamageRate(100,70);
ThymeGauge1;
TimerBack;
SetEnemyMarker(true);
SetCommonData("SetStar",2);
SetCommonData("SetStarX",GetCenterX-175);
LifeStar1;
SetCommonData("BossNumber",3);
BossName;
LoadUserShotData("script\Script-System\AllShotData.txt");
SetGraphicRect(0,96,63,191);
LoadGraphic(BossImage);
SetBossLifeCircle(3500,true,20,true);
BossMagicCircle;
}
			
@MainLoop{
yield;
Frame1++;Frame2++;Frame3++;Frame4++;Frame5++;
SetCollisionA(GetX,GetY,25);SetCollisionB(GetX,GetY+Height,20);
if(Frame5==230){
Move=true;
if(Cx>GetX){
MoveMord1=true;
SetMovePosition03(rand(Cx,Cx+50),rand(100,200),10,3);
}
if(Cx<GetX){
MoveMord2=true;
SetMovePosition03(rand(Cx,Cx-50),rand(100,200),10,3);
}
Move=false;
Frame5=0;
}




if(Frame1==120){
Move=false;
Charge;
}
if(Frame1==160){
PlaySE("script\SE\Shot1.wav");
loop(18){
Angle2=(Angle1-40*60);
Set1=GetX+30*cos(Angle2);
Set2=GetY+30*sin(Angle2);
Shot1;
Angle1+=20;
}
}
if(Frame1==200){
Frame1=120;
}

DeleteEnemyShotImmediatelyInCircle(ALL,0,0,1);
}
task Shot1{
let shot1=Obj_Create(OBJ_SHOT);
let count=0;
let frame1=0;
let frame2=0;
let frame3=0;
let X1=0;
let X2=0;
let Y1=0;
let Y2=0;
let Angle1=0;
Obj_SetX(shot1,Set1);//x座標設定
Obj_SetY(shot1,Set2);//y座標設定;
ObjShot_SetDelay(shot1,10);
Obj_SetSpeed(shot1,4);//速度設定
ObjShot_SetGraphic(shot1,23);//画像設定
Obj_SetAngle(shot1,Angle2);
loop{
frame1++;frame2++;
SetCommonData("X",Obj_GetX(shot1));
SetCommonData("Y",Obj_GetY(shot1));
if(frame1==30){
PlaySE("script\SE\Laser1.wav");
Angle3=rand(0,360);
loop(18){
Angle4=(Angle3-40*60);
Set3=GetCommonData("X")+30*cos(Angle4);
Set4=GetCommonData("Y")+30*sin(Angle4);
Laser1;
Angle3+=20;
}
break;
}
task Laser1{
let shot1=Obj_Create(OBJ_LASER);
let frame1=0;
let frame2=0;
let Nagasa=0;
let Hososa=0;
let ang=0;
Obj_SetX(shot1,Set3);//x座標設定
Obj_SetY(shot1,Set4);//y座標設定;
ObjShot_SetDelay(shot1,50);
ObjShot_SetGraphic(shot1,rand_int(51,57));//画像設定
ObjLaser_SetSource(shot1,false);
ang=atan2(GetPlayerY-Obj_GetY(shot1),GetPlayerX-Obj_GetX(shot1));
Obj_SetAngle(shot1,Angle4);
loop{
frame1++;
frame2++;
ObjLaser_SetLength(shot1,Nagasa);
ObjLaser_SetWidth(shot1,Hososa);
if(frame2==80){
ObjShot_FadeDelete(shot1);
break;

}


if(Nagasa>1000){	
}else{
Nagasa+=15;
}
if(Hososa>10){	
}else{
Hososa+=1;
}
yield;
}
}
yield;
}
}	




		
@DrawLoop{
SetTexture(BossImage);
DrawGraphic(GetX,GetY+Height);
Anime1++;
Anime2++;
Anime3++;
Anime4++;
if(GetSpeed<0.1){
if(MoveMord2==true){
if(Anime1==1){
SetGraphicRect(192,96,255,191);
} 
if(Anime1==5){
SetGraphicRect(128,96,191,191);
}
if(Anime1==10){
SetGraphicRect(64,96,127,191);
}
if(Anime1==15){
SetGraphicRect(0,96,63,191);
}
if(Anime1==20){
MoveMord2=false;
Anime1=0;
Anime2=0;
Anime4=0;
}
}else if(MoveMord1==true){
if(Anime1==1){
SetGraphicRect(192,192,255,287);
} 
if(Anime1==5){
SetGraphicRect(128,192,191,287);
}
if(Anime1==10){
SetGraphicRect(64,192,127,287);
}
if(Anime1==15){
SetGraphicRect(0,192,63,287);
}
if(Anime1==20){
MoveMord1=false;
Anime1=0;
Anime2=0;
}
}else{
 
if(BossShot==true){
if(Anime4==1){
SetGraphicRect(0,288,63,383);
}
if(Anime4==5){
SetGraphicRect(64,288,127,383);
} 
if(Anime4==10){
SetGraphicRect(128,288,191,383);
}
if(Anime4==15){
SetGraphicRect(192,288,255,383);
}
}else{
Anime2=0;
Anime3=0;
Anime4=0;
if(Anime1==1){
SetGraphicRect(0,0,63,95);
}
if(Anime1==10){
SetGraphicRect(64,0,127,95);
}
if(Anime1==20){
SetGraphicRect(128,0,191,95);
}
if(Anime1==30){
SetGraphicRect(192,0,255,95);
}
if(Anime1==40){
SetGraphicRect(128,0,191,95);
}
if(Anime1==50){
SetGraphicRect(64,0,127,95);
Anime1=0;
}
}
}
}else if(GetSpeedX<0){
Anime1=0;
Anime3=0;
Anime4=0;
if(Anime2==1){
SetGraphicRect(0,96,63,191);
}
if(Anime2==5){
SetGraphicRect(64,96,127,191);
}
if(Anime2==10){
SetGraphicRect(128,96,191,191);
}
if(Anime2==15){
SetGraphicRect(192,96,255,191);
}
}else{
Anime1=0;
Anime2=0;
Anime4=0;
if(Anime3==1){
SetGraphicRect(0,192,63,287);
} 
if(Anime3==5){
SetGraphicRect(64,192,127,287);
}
if(Anime3==10){
SetGraphicRect(128,192,191,287);
}
if(Anime3==15){
SetGraphicRect(192,192,255,287);
}

}
if(Move==false){
Htime++;
}
if(Htime==1){
Height+=1;
}
if(Htime==10){
Height+=1;
}
if(Htime==20){
Height+=1;
}
if(Htime==30){
Height-=1;
}
if(Htime==40){
Height-=1;
}
if(Htime==50){
Height-=1;
Htime=0;
}
}
			
@Finalize{
SetCommonData("EnemyX",GetX);
SetCommonData("EnemyY",GetY);
SetCommonData("SamonPoint",true);
SetCommonData("SamonPower",true);
SetCommonData("SamonBigPower",true);
}
}

