script_enemy_main{
      #include_script".\Local.txt"
    let shotData = csd ~ "data_usershot.txt"; 
  /* let arg = GetArgument;
   let difficult = GetCommonDataDefaultEx("","dif",0); */
 let GameOver = csd~"img\GameOver.png";

	@Initialize
	{
 SetCommonDataEx("","dif",difficult);
         SetLife(100000000);
            SetDamageRate(0,0);
    LoadGraphic(GameOver);
           LoadUserShotData(shotData);
          SetInvincibility(60*60*60*24*365);
   sgrnum = 1;
               Main;
	}
	
	@MainLoop{
      /*  SetCollisionA(GetX(),GetY(),arg[4]);
	SetCollisionB(GetX(),GetY(),arg[4]);*/
   TimeStop(2,1,0,0);
   SetPlayerInvincibility(2);
   DeleteEnemyShotImmediatelyInCircle(ALL,cx,cy,400);
		yield;
	}
	
       	@DrawLoop{
    alternative(arg[1])
   case(0){SetTexture(EnemyBlue);}
   case(1){SetTexture(EnemyRed);}
   case(2){SetTexture(EnemyGreen);}
   case(3){SetTexture(EnemyYellow);}
   case(4){SetTexture(EnemyEx1);}
   case(5){SetTexture(EnemyEx2);}
   case(6){SetTexture(EnemyOther);}
    others{SetTexture(EnemyBlue);}
   GraphicTurn;
    DrawGraphic(GetX,GetY);
/* DrawText(ToString(EnemyBlue),cx-180,cy+90,20,255);*/
	}

	@Finalize{ 
         
	}

         task Main{
             yield; 
       Move;
     }

     task Move{
   wait(0);
  ascent(a in 0..450){
    GOBack(1.5,a*255/450);
   wait(1);
        }
    loop{GOBack(1.5,255); wait(1);}
     }


   task GOBack(m,al){
           let c= Obj_Create(OBJ_EFFECT);
             Obj_SetX(c,cx-160*m);
             Obj_SetY(c,cy-120*m);
             Obj_SetAngle(c,0);
             ObjEffect_SetAngle(c,0,0,0);
             ObjEffect_SetTexture(c,GameOver);
             ObjEffect_SetRenderState(c,ALPHA);
             ObjEffect_SetPrimitiveType(c,PRIMITIVE_TRIANGLESTRIP);
             ObjEffect_SetLayer(c,7);
             ObjEffect_SetScale(c,m,m);
    let dx = [0,0,320,320,0];
    let dy = [-60,240+60,240+60,-60,-60];
    let r = 255; let g = 255; let b = 255;
        ObjEffect_CreateVertex(c,length(dx));
            ascent(let i in 0..length(dx)){
                ObjEffect_SetVertexXY(c,i,dx[i],dy[i]);
                ObjEffect_SetVertexUV(c,i,dx[i],dy[i]);
                ObjEffect_SetVertexColor(c,i,al,r,g,b);
                  }  
       wait(1); Obj_Delete(c);  
         }

     function offsetX(radius,angle){
           return radius * cos(angle);
     }

        function offsetY(radius,angle){
            return radius * sin(angle);
     }           

  function sgr(a,b,c,d){SetGraphicRect(a*c,b*c,(a+1)*c,(b+1)*c);}

       function wait(w){
                loop(w){yield;}
       }
}