--------------------------------------------------------------------
-- s_push_one_more.lua
-- ボタン（もう1回遊ぶ）押下時の処理
--
-- author IZUMI STUDIO
-- date
--------------------------------------------------------------------
require(".\\scripts\\game\\s_common")

-- SE再生
Scene.ControlSound( 0, CONTROL_STOP, "cursor8", 0 )
Scene.ControlSound( 0, CONTROL_PLAY, "cursor8", 0 )

-- ボタン押下演出
Scene.ExecEffectScript_CursorPos( 0, ".\\scripts\\menu\\e_push_button.lua" )

-- 再度ゲームシーンへ
Scene.ChangeScene( 0, SCENE_GAME, TRANSITION_BLACK_OUT, 20, TRANSITION_BLACK_IN, 20 )

-- プレイ回数更新
Scene.SetEnvParameterInt( 0, "TempPlayCount", Scene.GetEnvParameterInt("TempPlayCount")+1 ) ;

-- AIを変更（1つ上のレベルへ）
local aiLevel = 0
if( Scene.GetEnvParameterInt("PlayerCodeRed") == PLAYER_YOU ) then
	aiLevel = Scene.GetEnvParameterInt("AILevelYellow")
elseif( Scene.GetEnvParameterInt("PlayerCodeYellow") == PLAYER_YOU ) then
	aiLevel = Scene.GetEnvParameterInt("AILevelRed")
end

local nextLevel    = 0
local nextAIScript = ""
local nextAIName   = ""
if( aiLevel == AI_LEVEL_1 ) then
	nextLevel    = AI_LEVEL_2
	nextAIScript = AI_SCRIPT_2
	nextAIName   = AI_NAME_2
elseif( aiLevel == AI_LEVEL_2 ) then
	nextLevel    = AI_LEVEL_3
	nextAIScript = AI_SCRIPT_3
	nextAIName   = AI_NAME_3
elseif( aiLevel == AI_LEVEL_3 ) then
	nextLevel    = AI_LEVEL_4
	nextAIScript = AI_SCRIPT_4
	nextAIName   = AI_NAME_4
elseif( aiLevel == AI_LEVEL_4 ) then
	nextLevel    = AI_LEVEL_5
	nextAIScript = AI_SCRIPT_5
	nextAIName   = AI_NAME_5
else
	nextLevel    = AI_LEVEL_1
	nextAIScript = AI_SCRIPT_1
	nextAIName   = AI_NAME_1
end

if( Scene.GetEnvParameterInt("PlayerCodeRed") == PLAYER_YOU ) then
	Scene.SetEnvParameterInt( 0, "AILevelYellow", nextLevel )
	Scene.SetEnvParameterString( 0, "AIScriptYellow", nextAIScript )
	Scene.SetEnvParameterString( 0, "PlayerNameYellow", nextAIName )
elseif( Scene.GetEnvParameterInt("PlayerCodeYellow") == PLAYER_YOU ) then
	Scene.SetEnvParameterInt( 0, "AILevelRed", nextLevel )
	Scene.SetEnvParameterString( 0, "AIScriptRed", nextAIScript )
	Scene.SetEnvParameterString( 0, "PlayerNameRed", nextAIName )
end

-- 入力無効に
Scene.SetEnvParameterInt( 0, "EnableGameInput", 0 ) ;
Scene.SetEnvParameterInt( 0, "EnableSystemInput", 0 ) ;


