//==============================================================================
//	E AjCu
//@{XXNvg`ɂăCN[h
//==============================================================================
#include_function ".\lib_anime.txt"

//==============================================================================
//@萔Aϐ
//==============================================================================
//@ANV萔i{j
//------------------------------------------------------------------------------
let ACT_STAND	= _ACT_STAND3;		//@
let ACT_MOVE	= _ACT_MOVE;		//@ړiEj
let ACT_MOVE_L	= _ACT_MOVE_L;		//@ړ
let ACT_MOVE_R	= _ACT_MOVE_R;		//@Eړ
let ACT_SHOT_A	= _ACT_SHOT_A5;		//@eA
let ACT_SHOT_B	= _ACT_SHOT_B5;		//@eB
let ACT_SPELL	= _ACT_SPELL5;		//@Xy

//------------------------------------------------------------------------------
//@ϐݒ
//------------------------------------------------------------------------------
actionDefault = ACT_STAND;
character = CHAR_CHEN_RAN;
let drawAngle = 0;
let newRoll = false;

//==============================================================================
//@`֘A֐
//==============================================================================
//	{XAj`i]` ʏj
//------------------------------------------------------------------------------
function DrawBossRoll(
	let imageFile		//@摜t@CpX
){
	_DrawBossRoll( imageFile, GetX(), GetY() );
}

//------------------------------------------------------------------------------
//	{XAj`i]` Wwj
//------------------------------------------------------------------------------
function _DrawBossRoll(
	let imageFile,		//@摜t@CpX
	let x,				//	SxW
	let y				//	SyW
){
	SetGraphicAngle( 0, 0, drawAngle );
	_DrawBoss( imageFile, x, y );
	SetGraphicAngle( 0, 0, 0 );
}

//==============================================================================
//@̑֐
//==============================================================================
//@]i]͌j
//@ړJn{SetAction()ɓɌĂяo
//@Iۂɉ]͂
//------------------------------------------------------------------------------
task SetRoll(
	let frame		//@]iړj܂ł̃t[
){
	newRoll = true;
	let count = 0;
	loop( frame ){
		while( stopAnime ){ yield; }
		if( GetSpeed() > 0.1 ){ break; }
		count ++;
		yield;
	}
	frame -= count;
	if( frame < 1 ){ return; }
 	let assign = 1;
	alternative( action )
	case( ACT_MOVE ){
		if( cos( GetAngle() ) < 0 ){ assign = -1; }
	}
	case( ACT_MOVE_L ){ assign = -1; }
	case( ACT_MOVE_R ){ }
	others{ assign = 0; }
	let minRollAngle = 12;
	let maxRollAngle = 24;
	ascent( let i in minRollAngle .. minRollAngle + frame ){
		drawAngle -= [ i, maxRollAngle ][ i > maxRollAngle ] * assign;
	}
	descent( let i in minRollAngle .. minRollAngle + frame ){
		while( stopAnime ){ yield; }
		if( i < minRollAngle + frame - 1 && newRoll ){ break; }
		drawAngle += [ i, maxRollAngle ][ i > maxRollAngle ] * assign;
		yield;
		if( i == minRollAngle + frame - 1 ){ newRoll = false; }
	}
	drawAngle = 0;
}

//------------------------------------------------------------------------------
//@]i]͈j
//@ړJn{SetAction()ɓɌĂяo
//@Iۂɉ]͂ȂiʊOւ̈ړA]~߂ȂꍇɎgpj
//------------------------------------------------------------------------------
task SetRollConstant(
	let frame		//@]iړj܂ł̃t[
){
	newRoll = true;
	let count = 0;
	loop( frame ){
		while( stopAnime ){ yield; }
		if( GetSpeed() > 0.1 ){ break; }
		count ++;
		yield;
	}
	frame -= count;
	if( frame < 1 ){ return; }
	let rollAngle = 24;
	alternative( action )
	case( ACT_MOVE ){
		if( cos( GetAngle() ) < 0 ){ rollAngle = - rollAngle; }
	}
	case( ACT_MOVE_L ){ rollAngle = - rollAngle; }
	case( ACT_MOVE_R ){ }
	others{ rollAngle = 0; }
	ascent( let i in 0 .. frame ){
		while( stopAnime ){ yield; }
		if( i > 0 && newRoll ){ break; }
		drawAngle += rollAngle;
		yield;
		if( i == 0 ){ newRoll = false; }
	}
	drawAngle = 0;
}
