script_enemy_main
{
    let count=0;//背景球
    let S=0;//速度
    let D=1;//拡大
    let C=0;//色
    let N15=0;
    let N17=0;
    let Level=0;

function dead {

    SetDamageRate(0,0);
    PlaySE(GetCurrentScriptDirectory~"\se\bom27_b.wav");
    if (N17==50) {
        if (BeVanished==false) {
            CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,1);
            SetCommonData("ii1",GetCommonDataDefault("ii1",0)+GetCommonDataDefault("ii2",0));
            SetCommonData("ii3",1);
            CreateItem(ITEM_SCORE,GetX(),GetY()+22);
            loop(3) {
                CreateItem(ITEM_SCORE,GetX()+rand(-18,18),GetY()+rand(38,64));
            }
        }
    }

    if (N17<100) {
        N17+=50;
    }
    if (N17>=100) {
        VanishEnemy;
    }
}

task wak1(let l)
{
    let obj = Obj_Create(OBJ_EFFECT);
    Obj_SetX(obj, GetX);
    Obj_SetY(obj, GetY);
    Obj_SetSpeed(obj, 0);
    ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
    ObjEffect_SetRenderState(obj, ALPHA);
    ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
    ObjEffect_SetScale(obj,D,D);
    ObjEffect_SetAngle(obj,0,0,-count*5);
    ObjEffect_CreateVertex(obj, 4);
    ObjEffect_SetLayer(obj,l);

    while (!Obj_BeDeleted(obj))
    {

        Obj_SetX(obj, GetX);
        Obj_SetY(obj, GetY);
        Obj_SetAlpha(obj,255);
        if (count%4<=1) {
            C=225+count%4*30;
        }
        else {
            C=count%4*30;
        }
        if (GetArgument<15) {
            C = C/3;
        }else {
            D=0.95;
        }
        ObjEffect_SetAngle(obj,0,0,-count*5);
        ObjEffect_SetScale(obj,D,D);
        //四角形状に各頂点の座標を設定
        ObjEffect_SetVertexXY(obj,0,-32,-32);
        ObjEffect_SetVertexXY(obj,1,-32,32);
        ObjEffect_SetVertexXY(obj,2,32,-32);
        ObjEffect_SetVertexXY(obj,3,32,32);

        //四角形状に各頂点のUV値を設定
        ObjEffect_SetVertexUV(obj,0,64,0);
        ObjEffect_SetVertexUV(obj,1,64,64);
        ObjEffect_SetVertexUV(obj,2,128,0);
        ObjEffect_SetVertexUV(obj,3,128,64);

        ascent(let t in 0..4) {
            ObjEffect_SetVertexColor(obj,t,255,C,C,C);
        }

        //if(borr2<=0){Obj_Delete(obj);}

        yield;
    }

}

task wak2(let l)
{
    let obj = Obj_Create(OBJ_EFFECT);
    Obj_SetX(obj, GetX);
    Obj_SetY(obj, GetY);
    Obj_SetSpeed(obj, 0);
    ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
    ObjEffect_SetRenderState(obj, ALPHA);
    ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
    ObjEffect_SetScale(obj,D,D);
    ObjEffect_SetAngle(obj,0,0,count*4);
    ObjEffect_CreateVertex(obj, 4);
    ObjEffect_SetLayer(obj,l);

    while (!Obj_BeDeleted(obj))
    {

        Obj_SetX(obj, GetX);
        Obj_SetY(obj, GetY);
        Obj_SetAlpha(obj,255);
        C = 255;
        if (GetArgument<15) {
            C = C/3;
        }else {
            D=0.8;
        }
        ObjEffect_SetAngle(obj,0,0,count*4);
        ObjEffect_SetScale(obj,D,D);
        //四角形状に各頂点の座標を設定
        ObjEffect_SetVertexXY(obj,0,-32,-32);
        ObjEffect_SetVertexXY(obj,1,-32,32);
        ObjEffect_SetVertexXY(obj,2,32,-32);
        ObjEffect_SetVertexXY(obj,3,32,32);

        //四角形状に各頂点のUV値を設定
        ObjEffect_SetVertexUV(obj,0,0,0);
        ObjEffect_SetVertexUV(obj,1,0,64);
        ObjEffect_SetVertexUV(obj,2,64,0);
        ObjEffect_SetVertexUV(obj,3,64,64);

        ascent(let t in 0..4) {
            ObjEffect_SetVertexColor(obj,t,255,C,C,C);
        }

        //if(borr2<=0){Obj_Delete(obj);}

        yield;
    }

}

@Initialize
{
    SetLife(464);
    SetDamageRate(100,5);
    wak1(1+2*(GetArgument>=15));
    wak2(1+2*(GetArgument>=15));
    SetScore(50000);
    Level+=GetPlayerLife();
    S=GetSpeed;
}


@MainLoop
{
    if (GetArgument==0) {
        SetSpeed(S);
        if (count>=40) {
            SetAngle(270)
        }else {
            D-=0.004;
            S-=0.04;
        }
        if (count>123) {
            VanishEnemy;
        }
    }

    if (GetArgument==1) {
        SetSpeed(S);
        if (count>=40) {
            SetAngle(GetAngle-1)
        }else {
            D-=0.005;
            S-=0.01;
        }
        if (count>123) {
            VanishEnemy;
        }
    }

    if (GetArgument==2) {
        SetSpeed(S);
        if (count>=40) {
            SetAngle(GetAngle+1)
        }else {
            D-=0.005;
            S-=0.01;
        }
        if (count>123) {
            VanishEnemy;
        }
    }

    if (GetArgument==3) {
        SetSpeed(S);
        if (count>=40) {
            SetAngle(GetAngle+2);
            if (count==40) {
                SetAngle(270);
            }
        }else {
            D-=0.004;
            S-=0.02;
        }
        if (count>123) {
            VanishEnemy;
        }
    }

    if (GetArgument==4) {
        SetSpeed(S);
        if (count>=40) {
            SetAngle(GetAngle-2);
            if (count==40) {
                SetAngle(270);
            }
        }else {
            D-=0.004;
            S-=0.02;
        }
        if (count>123) {
            VanishEnemy;
        }
    }

    if (GetArgument==5) {
        SetSpeed(7);
        SetAngle(270);
        D=0.9;
        if (count>80) {
            VanishEnemy;
        }
    }

    count++;
    yield;

}

@Finalize
{
}

@DrawLoop
{

}
}
