--------------------------------------------------------------------
-- e_end_common.lua
-- ゲーム終了時演出共通
--
-- author IZUMI STUDIO
-- date 2009-09-30 新規作成
--------------------------------------------------------------------

function createElement_Ring( delay, endFrame, x, y, scale )
	local mover = Effect.CreateAnimator_Still(
		x, y, 0.0,
		x, y, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Ring(
		255, RING_COL_1[1], RING_COL_1[2], RING_COL_1[3],
		0, RING_COL_1[1], RING_COL_1[2], RING_COL_1[3],
		255, RING_COL_2[1], RING_COL_2[2], RING_COL_2[3],
		0, RING_COL_2[1], RING_COL_2[2], RING_COL_2[3],
		255, RING_COL_3[1], RING_COL_3[2], RING_COL_3[3],
		0, RING_COL_3[1], RING_COL_3[2], RING_COL_3[3],
		INTERPOLATION_EASE_IN,
		scale*0.4, scale,
		INTERPOLATION_EASE_OUT2,
		0.2, 0.2,
		INTERPOLATION_EASE_OUT2,
		34,
		255,
		0.5,
		EFFECT_BLEND_NORMAL,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 1,
		mover, rotator )
end

function createElement_Ring2( delay, endFrame, x, y, scale )
	local mover = Effect.CreateAnimator_Still(
		x, y, 0.0,
		x, y, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Ring(
		0, RING_COL_1[1], RING_COL_1[2], RING_COL_1[3],
		0, RING_COL_1[1], RING_COL_1[2], RING_COL_1[3],
		255, RING_COL_2[1], RING_COL_2[2], RING_COL_2[3],
		0, RING_COL_2[1], RING_COL_2[2], RING_COL_2[3],
		0, RING_COL_3[1], RING_COL_3[2], RING_COL_3[3],
		0, RING_COL_3[1], RING_COL_3[2], RING_COL_3[3],
		INTERPOLATION_EASE_IN,
		scale*0.4, scale,
		INTERPOLATION_EASE_OUT2,
		0.2, 0.0,
		INTERPOLATION_EASE_IN,
		36,
		255,
		0.5,
		EFFECT_BLEND_ADD,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 1,
		mover, rotator )
end

function createElement_Ring3( delay, endFrame, x, y, scale )
	local mover = Effect.CreateAnimator_Still(
		x, y, 0.0,
		x, y, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Ring(
		0, RING_COL_1[1], RING_COL_1[2], RING_COL_1[3],
		0, RING_COL_1[1], RING_COL_1[2], RING_COL_1[3],
		255, RING_COL_2[1], RING_COL_2[2], RING_COL_2[3],
		0, RING_COL_2[1], RING_COL_2[2], RING_COL_2[3],
		0, RING_COL_3[1], RING_COL_3[2], RING_COL_3[3],
		0, RING_COL_3[1], RING_COL_3[2], RING_COL_3[3],
		INTERPOLATION_EASE_OUT,
		scale*0.0, scale,
		INTERPOLATION_EASE_OUT2,
		4.0, 0.0,
		INTERPOLATION_EASE_IN2,
		36,
		255,
		0.5,
		EFFECT_BLEND_ADD,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 1,
		mover, rotator )
end



function createElement_GameStart_In( delay, endFrame, x, y )
	
	local mover = Effect.CreateAnimator_Dynamics(
		x, y, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Model(
		MES_MODEL_NAME,
		MODEL_SCALE*0.5, MODEL_SCALE, INTERPOLATION_EASE_OUT,
		0.0, 1.0, INTERPOLATION_LINEAR,
		EFFECT_BLEND_NORMAL, 
		delay, endFrame, 1,
		0,
		mover,
		rotator )
end

function createElement_GameStart( delay, endFrame, x, y )
	
	local mover = Effect.CreateAnimator_Dynamics(
		x, y, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Model(
		MES_MODEL_NAME,
		MODEL_SCALE, MODEL_SCALE*1.08, INTERPOLATION_EASE_OUT2,
		1.0, 1.0, INTERPOLATION_LINEAR,
		EFFECT_BLEND_NORMAL, 
		delay, endFrame, 1,
		0,
		mover,
		rotator )
end

function createElement_GameStart_Out( delay, endFrame, x, y )
	
	local mover = Effect.CreateAnimator_Dynamics(
		x, y, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Model(
		MES_MODEL_NAME,
		MODEL_SCALE*1.08, MODEL_SCALE*1.16, INTERPOLATION_EASE_OUT,
		1.0, 0.0, INTERPOLATION_LINEAR,
		EFFECT_BLEND_NORMAL, 
		delay, endFrame, 1,
		0,
		mover,
		rotator )
end


function createElement_GameStart2_In( delay, endFrame, x, y )
	
	local mover = Effect.CreateAnimator_Still(
		x, y, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Model(
		MES_MODEL_NAME,
		MODEL_SCALE*0.527*1.1, MODEL_SCALE*0.527, INTERPOLATION_LINEAR,
		0.0, 1.0, INTERPOLATION_LINEAR,
		EFFECT_BLEND_NORMAL, 
		delay, endFrame, 1,
		0,
		mover,
		rotator )
end

function createElement_GameStart2( delay, endFrame, x, y )
	
	local mover = Effect.CreateAnimator_Still(
		x, y, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Model(
		MES_MODEL_NAME,
		MODEL_SCALE*0.527, MODEL_SCALE*0.527, INTERPOLATION_LINEAR,
		1.0, 1.0, INTERPOLATION_LINEAR,
		EFFECT_BLEND_NORMAL, 
		delay, endFrame, 0,
		0,
		mover,
		rotator )
end



function createElement_Back_In( delay, endFrame, x, y, spdY )
	
	local mover = Effect.CreateAnimator_Dynamics(
		x, y, 0.0,
		0.0, 0.0, 0.0,
		0.0, spdY, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Circle(
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		255, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		BACK_MAX, BACK_MAX,
		INTERPOLATION_EASE_OUT,
		EFFECT_BLEND_NORMAL,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 1,
		mover, rotator )
end

function createElement_Back( delay, endFrame, x, y, spdY )
	
	local mover = Effect.CreateAnimator_Dynamics(
		x, y, 0.0,
		0.0, 0.0, 0.0,
		0.0, spdY, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Circle(
		255, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		255, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		BACK_MAX, BACK_MAX,
		INTERPOLATION_EASE_OUT,
		EFFECT_BLEND_NORMAL,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 1,
		mover, rotator )
end

function createElement_Back_Out( delay, endFrame, x, y, spdY )
	
	local mover = Effect.CreateAnimator_Dynamics(
		x, y, 0.0,
		0.0, 0.0, 0.0,
		0.0, spdY, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Circle(
		255, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		BACK_MAX, BACK_MAX,
		INTERPOLATION_EASE_OUT,
		EFFECT_BLEND_NORMAL,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 1,
		mover, rotator )
end


function createElement_Back2_In( delay, endFrame, x, y )
	
	local mover = Effect.CreateAnimator_Still(
		x, y, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Circle(
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		255, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		BACK_MAX*0.527, BACK_MAX*0.527,
		INTERPOLATION_EASE_OUT,
		EFFECT_BLEND_NORMAL,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 1,
		mover, rotator )
end

function createElement_Back2( delay, endFrame, x, y )
	
	local mover = Effect.CreateAnimator_Still(
		x, y, 0.0,
		0.0, 0.0, 0.0 )
	
	local rotator = Effect.CreateAnimator_Still(
		0.0, 0.0, 0.0,
		0.0, 0.0, 0.0 )
	
	Effect.CreateElement_Circle(
		255, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		255, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		0, BACK_COL[1], BACK_COL[2], BACK_COL[3],
		BACK_MAX*0.527, BACK_MAX*0.527,
		INTERPOLATION_EASE_OUT,
		EFFECT_BLEND_NORMAL,
		EFFECT_BILLBOARD_NORMAL,
		delay, endFrame, 0,
		mover, rotator )
end




for idx = 1, 8 do
	x = math.random() * PROJ_WIDTH - PROJ_HALF_WIDTH
	y = math.random() * PROJ_WIDTH - PROJ_HALF_WIDTH
	scale = math.random() * 8.5 + 0.5
	endFrame = 4 * scale
	endFrame = 40
	--createElement_Ring( FRAMES_0, endFrame, x, y, scale )
end


w = BACK_WIDTH / 400.0 * 1.333 * PROJ_HALF_WIDTH
sw = - w / 2.0

for idx = 0, BACK_DIVISION do
	createElement_Back_In( FRAMES_0, FRAMES_1, sw + w*idx/9.0, 0.0, 0.0 )
end
for idx = 0, BACK_DIVISION do
	createElement_Back( FRAMES_0+FRAMES_1, FRAMES_2, sw + w*idx/9.0, 0.0, 0.0 )
end
for idx = 0, BACK_DIVISION do
	createElement_Back_Out( FRAMES_0+FRAMES_1+FRAMES_2, FRAMES_3, sw + w*idx/9.0, 0.0, 0.0 )
end


if RING_2 then
	createElement_Ring2( FRAMES_0, 50, 0.0, 0.0, 8.0 )
end

if RING_3 then
	createElement_Ring3( FRAMES_0, 12, 0.0, 0.0, 16.0 )
end

createElement_GameStart_In( FRAMES_0, FRAMES_1, 0.0, 0.0 )
createElement_GameStart( FRAMES_0+FRAMES_1, FRAMES_2, 0.0, 0.0 )
createElement_GameStart_Out( FRAMES_0+FRAMES_1+FRAMES_2, FRAMES_3, 0.0, 0.0 )

baseX = (400.0-400.0)/400.0*1.333 * PROJ_HALF_WIDTH
baseY = (300.0-65.697)/300.0 * PROJ_HALF_WIDTH


w = BACK_WIDTH / 400.0 * 1.333 * PROJ_HALF_WIDTH * 0.527
sw = - w / 2.0

for idx = 0, BACK_DIVISION do
	createElement_Back2_In( FRAMES_0+FRAMES_1+FRAMES_2, FRAMES_3, baseX + sw + w*idx/9.0, baseY )
end
for idx = 0, BACK_DIVISION do
	createElement_Back2( FRAMES_0+FRAMES_1+FRAMES_2+FRAMES_3, FRAMES_4, baseX + sw + w*idx/9.0, baseY )
end

createElement_GameStart2_In( FRAMES_0+FRAMES_1+FRAMES_2, FRAMES_3, 
	(400.0-400.0)/400.0*1.333 * PROJ_HALF_WIDTH,
	(300.0-65.697)/300.0 * PROJ_HALF_WIDTH )
createElement_GameStart2( FRAMES_0+FRAMES_1+FRAMES_2+FRAMES_3, FRAMES_4, 
	(400.0-400.0)/400.0*1.333 * PROJ_HALF_WIDTH,
	(300.0-65.697)/300.0 * PROJ_HALF_WIDTH )



