

script_enemy_main {
	let imgBoss     = "script\l\img\dot_yuyuko.png";
	let cx=GetCenterX();
	#include_function ".\lib\lib_anime_Yuyuko.txt"

	@Initialize {
		SetX(GetCenterX);
        SetY(GetClipMinY + 120);
        SetLife(3000);
        SetTimer(40);
        LoadGraphic(imgBoss);
        InitializeAction();
        SetTexture(imgBoss);
		TMain;

       }
       @MainLoop {
        SetCollisionA(GetX, GetY, 28);
        SetCollisionB(GetX, GetY, 28);

        yield;
       }
       
        
        
       @DrawLoop {
        DrawBoss( imgBoss );
    }

    @Finalize {
        DeleteGraphic(imgBoss);
        loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
    }
    task TMain {
        yield;
        concentration;
        TNwaya;
        loop{
        TNwayb;
        TMove;
       }
}
    sub TMove {
        
        loop(120) { 

        moveToPlayer(rand(40, 80), rand(-40, 40), 60,
                     GetClipMinX + 48, GetClipMinY +  32,
                     GetClipMaxX - 48, GetClipMinY + 128);
        SetAction( ACT_MOVE, 120 )
      }
      }
      sub concentration {
	    let con = 0;
        let wConc = 60;
        

        if(con == 0) {
        Concentration01(wConc);
        wait(wConc);
        con +=1
       }
    }
    task TNwaya {
        
            loop {
	        let shotbase = GetAngleToPlayer;
            nway(2, shotbase, 5, 10, RED22, 4);
           wait(25)
        }
    } 
sub TNwayb {
    let base    = GetAngleToPlayer;
    let angle   = 20;
    let nShot   = 7;
    let wShot   = 5;
    let v       = 0;
    let delay = 20;

    
	wait(60);
    loop(nShot) { 
        nway(v, base + 16, 18, angle, RED21, delay);
        wait(15);

     v += 2;   

   }
}
    function moveToPlayer(xMove, yAdd, frame, left, top, right, bottom) {
        let x;
        let y;

        if(GetPlayerX < GetX) {
            
            x = GetX - xMove;

            
            if(x < left) {
                x = GetX + xMove;
            }
        } else {
           
            x = GetX + xMove;

           
            if(right < x) {
                x = GetX - xMove;
            }
        }

        y = GetY + yAdd;
        if(y < top) {
            y = top;
        } else if(bottom < y) {
            y = bottom;
        }

        SetMovePosition02(x, y, frame);
        
    }
    

    
        function nway(v, dir, way, span, ballet, delay) {
        let angle  = dir - (way - 1) / 2 * span;

        loop(way) {
            CreateShot01(GetX, GetY, v, angle, ballet, delay);
            angle += span;
        }
    }
    
        function wait(w) {
        loop(w) { yield; }
    }
}