#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["hitbox"]
#System["./../system/NSystem.dnh"]
#Player["./../player/Reimu by plasmaflame22/Reimu_A.txt"]

#include "./../ZUNShot/ZUNShot_Const.txt"
#include "./sharedFuncSaul.dnh"


let objBoss;
let width = 444;
let height = 448;
let life = 1000;
let time= 55;
let scene = GetEnemyBossSceneObjectID();

@Event{
    alternative(GetEventType())
    case(EV_REQUEST_LIFE){
        SetScriptResult(life);
    }
    case(EV_REQUEST_TIMER){
        SetScriptResult(time);
    }
}




@Initialize{
    objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
    ObjEnemy_Regist(objBoss);
	
	animSpell(objBoss, 1);
	TFinalizeNon(scene, objBoss);
	
	ObjMove_SetDestAtFrame(objBoss, width/2, 2*height/5, 60);
	Main;
}

@MainLoop{
    ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32); 
    ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 28);
    yield;
}

//task figureEight(x, y, speed, angle, radius, gapLength, numBul, delay, topBranch, topGraphic, bottomBranch, bottomGraphic, enemy, life){


task changeSize(obj){
    let graph= ObjShot_GetImageID(obj);
    alternative(graph)
	case(295){ObjShot_SetGraphic(obj, 356);}
	case(297){ObjShot_SetGraphic(obj, 357);}
	case(356){ObjShot_SetGraphic(obj, 295);}
	case(357){ObjShot_SetGraphic(obj, 297);}
}
	


task Main{

	/*let t=0;
	let text = speak("Hello");
	while(t<150){
	    if(GetVirtualKeyState(VK_OK) == KEY_PUSH){t=150;}
		t++; yield;
	}
	Obj_Delete(text);
	t=0;
	text = speak("How are you?");
	while(t<150){
	    if(GetVirtualKeyState(VK_OK) == KEY_PUSH){t=150;}
		t++; yield;
	}
	Obj_Delete(text);
	t=0;
	text = speak("Flibidi");
	while(t<150){
	    if(GetVirtualKeyState(VK_OK) == KEY_PUSH){t=150;}
		t++; yield;
	}
	Obj_Delete(text);*/



    //Spell("la", objBoss,1);
	

    
	/*let num = 5; let posi =[];
	let objID = []; let objnID= [];
	ascent(i in 0.. num){posi= posi~ [40 + i*364/(num-1) +rand(-30,30)];}
	ascent(i in 0.. num){
	    let obj= CreateShotA1(posi[i], 10, 0, 90, 356, 20);
        if(i<num-1){		
			ascent(j in 0..3){
				CreateShotA1(posi[i]+ j *(posi[i+1]-posi[i])/3, 10, 0, 90, 317, 0); 
			}
		}
	}
	
	num = 4; posi =[];
	ascent(i in 0.. num){posi= posi~ [40 + i*364/(num-1) +rand(-30,30)];}
	ascent(i in 0.. num){
	    let obj= CreateShotA1(posi[i], height/2, 0, 90, 356, 20);
        if(i<num-1){		
			ascent(j in 0..4){
				CreateShotA1(posi[i]+ j *(posi[i+1]-posi[i])/4, height/2, 0, 90, 317, 0); 
			}
		}
	}
	
	num = 3; posi =[];
	ascent(i in 0.. num){posi= posi~ [40 + i*364/(num-1) +rand(-30,30)];}
	ascent(i in 0.. num){
	    let obj= CreateShotA1(posi[i], 3*height/4, 0, 90, 356, 20);
        if(i<num-1){		
			ascent(j in 0..6){
				CreateShotA1(posi[i]+ j *(posi[i+1]-posi[i])/6, 3*height/4, 0, 90, 317, 0); 
			}
		}
	}*/
}
	
