#e
#Title[ʏU3]
#Text[]
#BackGround[Default]
#ScriptVersion[2]

script_enemy_main{

	#include_function ".\lib\lib_anime_Sanae.txt"
	let imgBoss = GetCurrentScriptDirectory() ~ "img\dot_sanae.png";
	let shot  =GetCurrentScriptDirectory~"SE\arrow01.wav";
	let shot2  =GetCurrentScriptDirectory~"SE\kira01_r.wav";
	let shot3  =GetCurrentScriptDirectory~"SE\shoot13.wav";
	let Concentration  =GetCurrentScriptDirectory~"SE\eco00_r.wav";
	let wIni = 120;

	@Initialize{
	SetEnemyMarker(true);
	LoadGraphic(imgBoss);
	LoadUserShotData(GetCurrentScriptDirectory ~ "img\shot_All.txt");
        SetMovePosition02(GetCenterX(), 150, wIni/2);
        SetAction(ACT_MOVE, wIni/2);
        SetLife(675);
        SetTimer(70);
        SetInvincibility(wIni*2);
        SetDamageRate(18*1.5, 3.6*1.5);
	LoadGraphic(GetCurrentScriptDirectory~"img\back06_01.png");	
	InitializeAction();
	    
	    TMain();
	}
		
	@MainLoop{
		SetCollisionA(GetX(), GetY(), 32);
		SetCollisionB(GetX(), GetY(), 24);
	    yield;
	}
	
		
	@Finalize{
	DeleteGraphic(imgBoss);
	}
	
	
	task TMain{
	    SetAction(ACT_MOVE, wIni/2);	    
	    yield;
	    loop(wIni/2){ yield; }
          SetAction(ACT_SHOT_B,12000);
	    loop(wIni/2){ yield; }
	    		let a=83;
	    loop{
	    loop(7){
		let s=1.5;
                     PlaySE(shot);
	    loop(8){
CreateReflectShot(GetX,GetY,s,a,54,49, 10);
CreateReflectShot(GetX,GetY,s,a+90,54,49, 10);
CreateReflectShot(GetX,GetY,s,a+180,54,49, 10);
CreateReflectShot(GetX,GetY,s,a+270,54,49, 10);
		s+=0.1;
		a+=1.5;
		}
	        loop(24){ yield; }
			}
        		SetAction(ACT_MOVE,60);
			move01;
			}
			}
    task CreateReflectShot(let x, let y, let speed,let angle, let color,let color2, let delay) {
        let obj = Obj_Create(OBJ_SHOT);
        Obj_SetPosition(obj, x, y);
        Obj_SetSpeed(obj, speed);
        Obj_SetAngle(obj, angle);
        ObjShot_SetGraphic(obj, color);
        ObjShot_SetDelay(obj, delay);
        while(!Obj_BeDeleted(obj)) {
            if(Obj_GetX(obj)<GetClipMinX){
                     PlaySE(shot2);
		CreateShotA(1,GetClipMinX*2-Obj_GetX(obj),Obj_GetY(obj),5);
		SetShotDataA(1,0,1.5,180-Obj_GetAngle(obj),0,0,0,color2);
		FireShot(1);
		Obj_Delete(obj);
            }
            if(Obj_GetX(obj)>GetClipMaxX){
                     PlaySE(shot2);
		CreateShotA(1,GetClipMaxX*2 - Obj_GetX(obj),Obj_GetY(obj),5);
		SetShotDataA(1,0,1.5,180-Obj_GetAngle(obj),0,0,0,color2);
		FireShot(1);
		Obj_Delete(obj);
            }
            if(Obj_GetY(obj)<GetClipMinY){
                     PlaySE(shot2);
		CreateShotA(1,Obj_GetX(obj),GetClipMinY*2 - Obj_GetY(obj),5);
		SetShotDataA(1,0,1.5,360-Obj_GetAngle(obj),0,0,0,color2);
		FireShot(1);
		Obj_Delete(obj);
            }
            yield;
        }
    }
			sub move01 {
	    if(GetX()>=234)
	    {
	        SetMovePosition02(GetX()-rand(25,50),rand(130,170),60);
	    }
	    else if(GetX()<=204)
	    {
	        SetMovePosition02(GetX()+rand(25,50),rand(130,170),60);
	    }
	    else if(GetX()<=GetPlayerX())
	    {
	        SetMovePosition02(GetX()+rand(25,50),rand(130,170),60);
	    }
	    else if(GetX()>=GetPlayerX())
	    {
	        SetMovePosition02(GetX()-rand(25,50),rand(130,170),60);
	    }
	}
	@DrawLoop{
	  DrawBoss(imgBoss);
		DrawGraphic(GetX(),GetY());
	}
        

}
