#e
#Title[Xmas(1) -L-]
#Text[cɂȂ]
#ScriptVersion[2]


script_enemy_main {
    //ʏݒ
    #include_function ".\INCLUDE\BOSS_INI.txt"

    let name        = "PuC}[Wi[c[v";

    let wIni    = 100;

    @Initialize {
        SetX(GetCenterX);
        SetY(GetClipMinY + 120);
	
        _CutIn(name);
        SetLife(1224);		//Ct
        SetTimer(99);		//^C}[
        SetScore(12241225);	//{[iXXRA
	
        _LoadGraphic();
	
        SetTexture(imgBoss);
        SetInvincibility(wIni);
        SetDamageRate(30, 30);

        TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 24);
        SetCollisionB(GetX, GetY, 24);

        yield; 
    }

    @DrawLoop {
        BossDraw(1);
    }

    @Finalize {
        DeleteGraphic(imgBoss);
    }

    @BackGround {
	BgDraw;
    }

//==========================================================================================

    // C^XNiʂ͂ȍ~ҏWĂj
    task TMain {
        yield;
        loop(wIni) { yield; }
	Shot;
    }

    //ʏVbg
    task Shot{
	let f = 300;	//
	let id = 1001;	//eID

	yield;
	
	loop{
		let width = GetClipMaxX - GetClipMinX;
		let x = 0;
		let y = 0;
		PlaySE(SE_BUN);
		ascent(let i in 0..8){
			x = (width / 8)*i + 10 + GetClipMinX;
			y = GetClipMaxY - 10;
			//Fzu
			CreateShotA(id, x, y, 5);
			SetShotDataA(id, 0, 0, 270, 0, 0, 0, US_CRYSTAL_B_YELLOW);
			SetShotKillTime(id, 160);
			FireShot(id);
			//E΂ߏFzu
			CreateShotA(id, x - 8, y + 10, 5);
			SetShotDataA(id, 0, 0, 330, 0, 0, 0, US_CRYSTAL_B_YELLOW);
			SetShotKillTime(id, 160);
			FireShot(id);
			//΂ߏFzuE
			CreateShotA(id, x + 8, y + 10, 5);
			SetShotDataA(id, 0, 0, 210, 0, 0, 0, US_CRYSTAL_B_YELLOW);
			SetShotKillTime(id, 160);
			FireShot(id);
			//Fzu
			CreateShotA(id, x, y + 10, 5);
			SetShotDataA(id, 0, 0, 0, 0, 0, 0, US_CRYSTAL_B_YELLOW);
			SetShotKillTime(id, 160);
			FireShot(id);
			SetLightShot(x, i, US_LIGHT2_BLUE);
			__wait(10);
		}
		BossMoveEX(50);
		__wait(f);

		PlaySE(SE_BUN);
		ascent(let i in 0..8){
			x = (width / 8)*i + 30 + GetClipMinX;
			y = GetClipMaxY - 10;
			//Fzu
			CreateShotA(id, x, y, 5);
			SetShotDataA(id, 0, 0, 270, 0, 0, 0, US_CRYSTAL_B_GREEN);
			SetShotKillTime(id, 160);
			FireShot(id);
			//E΂ߏFzu
			CreateShotA(id, x - 8, y + 10, 5);
			SetShotDataA(id, 0, 0, 330, 0, 0, 0, US_CRYSTAL_B_GREEN);
			SetShotKillTime(id, 160);
			FireShot(id);
			//΂ߏFzuE
			CreateShotA(id, x + 8, y + 10, 5);
			SetShotDataA(id, 0, 0, 210, 0, 0, 0, US_CRYSTAL_B_GREEN);
			SetShotKillTime(id, 160);
			FireShot(id);
			//Fzu
			CreateShotA(id, x, y + 10, 5);
			SetShotDataA(id, 0, 0, 0, 0, 0, 0, US_CRYSTAL_B_GREEN);
			SetShotKillTime(id, 160);
			FireShot(id);
			SetLightShot(x, i, US_LIGHT2_RED);
			__wait(10);
		}
		BossMoveEX(50);
		__wait(f);
	}
    }


    //܂Lт郌[U[ۂ
    task SetLightShot(let x, let arg, let color){
	let f = 1;
	let tk = 40;
	let id = 1002;
	let height = GetClipMaxY - GetClipMinY;
	__wait(30);
	if(color == US_LIGHT2_BLUE){
		CreateLaser01(x, GetClipMaxY -10, 12, 270, 1600, 24, US_BEAM_YELLOW, 10);
	}else{
		CreateLaser01(x, GetClipMaxY -10, 12, 270, 1600, 24, US_BEAM_GREEN, 10);
	}
	__wait(60);
	ascent(let i in 0..tk+1){
		let y = (GetClipMaxY - (height / tk)*i);
		let angle = (360/tk)*4*i + arg*100;
		CreateShotA(id, rand(-5,5) + x, rand(-5,5) + y, 12);
		SetShotDataA(id, 0, 0, 0, 0, 0, 0, color);
		SetShotDataA(id, 30, 0, angle, 0, 0.01, 0.3, color);
		SetShotDataA(id, 50, 0, angle, 0, -0.01, 0.05, color);
		SetShotDataA(id, 120, NULL, NULL, 0, 0.05, 1.5, color);
		FireShot(id);
		PlaySE(SE_SHOT1);
		yield;
	}
    }


//==========================================================================================
    // w t[҂
    function __wait(w) {
        loop(w) { yield; }
    }
}