x003041_g_scriptId = 003041

x003041_g_groupPointId = {301,302,303}

x003041_g_MonsterId = {} -- 每波怪物的Id
x003041_g_MonsterId[1] = {710000,710000}
x003041_g_MonsterId[2] = {710000,710000,710000,710000}
x003041_g_MonsterId[3] = {710000,710000,710000,710000,710000,710000,710000,710000}

x003041_g_MonsterPos = {} -- 每波怪物的出生位置
x003041_g_MonsterPos[1] = {{124.77,120.17,-1.57},{131.78,120.09,-1.57}}
x003041_g_MonsterPos[2] = {{124.77,120.17,-1.57},{131.78,120.09,-1.57},{119.78,120.06,-1.57},{137.1,119.82,-1.57}}
x003041_g_MonsterPos[3] = {{124.77,120.17,-1.57},{131.78,120.09,-1.57},{119.78,120.06,-1.57},{137.1,119.82,-1.57},{124.77,126.89,-1.57},{131.78,126.81,-1.57},{124.77,114.13,-1.57},{131.78,114.5,-1.57}}					
function x003041_OnEnterScene(scene,objId)
	EnterMarryScene(scene,objId)
end


function x003041_AddMarryValue(scene)

	local nUserCount = GetSceneUserCount(scene)
	if GetCurMarryId(scene) ~= -1 then
		for i=0,nUserCount-1 do

		    local nUserObjId = GetUserObjIdByIdx(scene,i)
			UpdateMarryValueToObjID(scene,nUserObjId)
		end
	end
	if GetMarrySceneValue(scene) >= 520 and GetMarrySceneStage(scene,0) then
		x003041_CreateGroupPoint(scene,0,520)
	end
	if GetMarrySceneValue(scene) >= 1314 and GetMarrySceneStage(scene,1) then
		x003041_CreateGroupPoint(scene,1,1314)
	end
	if GetMarrySceneValue(scene) >= 3344 and GetMarrySceneStage(scene,2) then
		x003041_CreateGroupPoint(scene,2,3344)
	end
end
function x003041_SendYanHuaTips(scene,str_1,str_2,str_3)
	local nUserCount = GetSceneUserCount(scene)
	if GetCurMarryId(scene) ~= -1 then
		for i=0,nUserCount-1 do

		    local nUserObjId = GetUserObjIdByIdx(scene,i)
			SendYanHuaTips(scene,nUserObjId,str_1,str_2,str_3)
		end
	end
end
function x003041_CreateGroupPoint(scene,Index,value)
	CreateMarryGroupPoint(scene,Index)
	SetMarryStage(scene,Index)
	if GetCurMarryId(scene) ~= -1 then
		local nUserCount = GetSceneUserCount(scene)
		for i=0,nUserCount-1 do
		local nUserObjId = GetUserObjIdByIdx(scene,i)
			UpdateXiTangTime(scene,nUserObjId)
			SendXiTangTips(scene,nUserObjId,value)
		end
	end
end
function x003041_BaiTang(scene)
	if GetCurMarryId(scene) ~= -1 then
		local nUserCount = GetSceneUserCount(scene)
		for i=0,nUserCount-1 do
		local nUserObjId = GetUserObjIdByIdx(scene,i)
			UpdteBaiTang(scene,nUserObjId)
		end
	end
end
function x003041_CreateWuNv(scene,id,PlayerName)
	local nMonsterCount = #x003041_g_MonsterId[id]
	for i=1,nMonsterCount do
		CreateMonster(scene,x003041_g_MonsterId[id][i],x003041_g_MonsterPos[id][i][3],x003041_g_MonsterPos[id][i][1],x003041_g_MonsterPos[id][i][2])
		SetWuNvTime(scene)
	end
	if GetCurMarryId(scene) ~= -1 then
		local nUserCount = GetSceneUserCount(scene)
		for i=0,nUserCount-1 do
		local nUserObjId = GetUserObjIdByIdx(scene,i)
			SendWuNvTips(scene,nUserObjId,id,PlayerName)
		end
	end

end
function x003041_UpdateMarryInfo(scene)
	if GetCurMarryId(scene) == -1 then
		local nUserCount = GetSceneUserCount(scene)
		for i=0,nUserCount-1 do
		local nUserObjId = GetUserObjIdByIdx(scene,i)
			MarrySceneOutUser(scene,nUserObjId)
		end
	end
	if GetWuNvStage(scene) == -1 then
		local nMonsterCount_1 = #x003041_g_MonsterId
		for i=1,nMonsterCount_1 do
			local nMonsterCount_2 = #x003041_g_MonsterId[i]
			for j=1,nMonsterCount_2 do
				DeleMonsterByRoleId(scene,x003041_g_MonsterId[i][j])
			end
		end
	end
	if CanAddHunYanExp(scene)  then
		local nUserCount = GetSceneUserCount(scene)
		for i=0,nUserCount-1 do
		local nUserObjId = GetUserObjIdByIdx(scene,i)
			AddHunYanExp(scene,nUserObjId)
		end
	end

end