--[[
Author: Will Graham (wgraham@digipen.edu)

Copyright 2008-2009 DigiPen (USA) Corp.
]]--

--print("PlatformTestLevel2_Init.lua")

StartPos = LvlLoader:GetInfo("playerStart01").Pos_
cameraStartPos = StartPos;

Sound:StopMusic();


EventManager:AddEvent(false, 0.0, "PlayerData:SetEmissiveColor(Vector3D(0.0, 0.0, 0.0), true)")
EventManager:AddEvent(false, 0.0, "PlayerData:ToggleLight(false)")
EventManager:AddEvent(false, 0.0, "PlayerData:SetRimColor(Vector3D(0.0, 0.0, 0.0), 0.0)")
EventManager:AddEvent(false, 0.0, "PlayerData.MoveSpeed_ = 350.0");
EventManager:AddEvent(false, 0.0, "PlayerData.Acceleration_ = 5.0");

cameraStartPos01 = LvlLoader:GetInfo("cameraStartPos01").Pos_
cameraStartDir01 = LvlLoader:GetInfo("cameraStartDir01").Pos_
cameraStartPos02 = LvlLoader:GetInfo("cameraStartPos02").Pos_
cameraStartDir02 = LvlLoader:GetInfo("cameraStartDir02").Pos_
cameraStartPos03 = LvlLoader:GetInfo("cameraStartPos03").Pos_
cameraStartPos = cameraStartPos01

cameraVec = DefaultCameraVec
cameraVec.y = 50

startTime = 14.0;

if true then
	EventManager:AddEvent(false, 0.0, "PlayerData:LockPlayer(Vector3D(0.0, 0.0, 0.0))")
	EventManager:AddEvent(false, 0.0, "PlayerData:SetCameraPositionLookat(cameraStartPos01, cameraStartDir01, 1.0)")
	
	EventManager:AddEvent(false, 2.0, "GameEngine:PlayParticleEvent(\"levelLoader/compositeObjects/playerSoulsEffect.igobj\", StartPos, Vector3D(20,20,20))");
	EventManager:AddEvent(false, startTime - 2.0, "PlayerData:SetCameraPositionLookat(cameraStartPos03, cameraStartDir01, 0.005)")

	EventManager:AddEvent(false, startTime + 0.0, "PlayerData:SetEmissiveColor(Vector3D(100.0, 0.0, 0.0), true)")
	EventManager:AddEvent(false, startTime + 0.0, "Sound:PlayEvent(\"PlayerAwaken\", Vector3D(0,0,0), Vector3D(0,0,0))");
	EventManager:AddEvent(false, startTime + 0.1, "PlayerData:SetEmissiveColor(Vector3D(0.0, 0.0, 0.0), false)")
	EventManager:AddEvent(false, startTime + 0.4, "PlayerData:SetEmissiveColor(Vector3D(100.0, 0.0, 0.0), true)")
	EventManager:AddEvent(false, startTime + 0.4, "Sound:PlayEvent(\"PlayerAwaken\", Vector3D(0,0,0), Vector3D(0,0,0))");
	EventManager:AddEvent(false, startTime + 0.6, "PlayerData:SetEmissiveColor(Vector3D(0.0, 0.0, 0.0), false)")
	EventManager:AddEvent(false, startTime + 1.0, "PlayerData:SetEmissiveColor(Vector3D(100.0, 0.0, 0.0), true)")
	EventManager:AddEvent(false, startTime + 1.0, "Sound:PlayEvent(\"PlayerAwaken\", Vector3D(0,0,0), Vector3D(0,0,0))");
	EventManager:AddEvent(false, startTime + 1.0, "Sound:PlayMusic(\"TreasureRoomMusic\")")
	EventManager:AddEvent(false, startTime + 0.4, "PlayerData:ToggleLight(true)")
	EventManager:AddEvent(false, startTime + 1.0, "PlayerData:SetRimColor(Vector3D(0.0, 0.3, 1.5), 1.0)")

	EventManager:AddEvent(false, startTime + 2.5, "PlayerData:SetCameraPosition(Vector3D(-75.0,  0.0, 10.0), 0.03, true, true)");
	EventManager:AddEvent(false, startTime + 2.6, "PlayerData:SetCameraPosition(Vector3D(-50.0,-50.0, 15.0), 0.03, true, true)");
	EventManager:AddEvent(false, startTime + 2.7, "PlayerData:SetCameraPosition(Vector3D(  0.0,-75.0, 20.0), 0.03, true, true)");
	EventManager:AddEvent(false, startTime + 2.8, "PlayerData:SetCameraPosition(cameraVec, DefaultCameraSpeed + 0.02, DefaultCameraRelative, DefaultCameraFixed)")
	EventManager:AddEvent(false, startTime + 3.5, "PlayerData:UnlockPlayer()")
else
	StartPos = LvlLoader:GetInfo("playerStart02").Pos_
	EventManager:AddEvent(false, 0.0, "PlayerData:SetCameraPositionLookat(cameraStartPos02, cameraStartDir02, 1.0)")
	EventManager:AddEvent(false, 0.0, "PlayerData:SetEmissiveColor(Vector3D(100.0, 0.0, 0.0), true)")
	EventManager:AddEvent(false, 0.0, "Sound:PlayMusic(\"TreasureRoomMusic\")")
	EventManager:AddEvent(false, 0.0, "PlayerData:ToggleLight(true)")
	EventManager:AddEvent(false, 0.0, "PlayerData:SetRimColor(Vector3D(0.0, 0.3, 1.5), 1.0)")
end




--[[
EventManager:AddEvent(false, 0.0, "PlayerData:LockPlayer(Vector3D(0.0, 0.0, 0.0))")
EventManager:AddEvent(false, 0.0, "PlayerData:SetEmissiveColor(Vector3D(100.0, 0.0, 0.0), true)")
EventManager:AddEvent(false, 0.0, "PlayerData:ToggleLight(true)")
EventManager:AddEvent(false, 0.0, "PlayerData:SetRimColor(Vector3D(0.0, 0.3, 1.5), 1.0)")
EventManager:AddEvent(false, 0.0, "PlayerData.MoveSpeed_ = 350.0");
EventManager:AddEvent(false, 0.0, "PlayerData.Acceleration_ = 5.0");
EventManager:AddEvent(false, 1.0, "PlayerData:UnlockPlayer()")
]]--

--EventManager:AddEvent(false, 0.0, "PlayerData:SetCameraPositionLookat(cameraStartPos01, cameraStartDir01, 1.0)");
--EventManager:AddEvent(false, 0.0, "PlayerData:SetCameraPosition(Vector3D(0.0, -200.0, 50.0), 1.0, true, true)");
--EventManager:AddEvent(false, 1.0, "PlayerData:SetCameraPosition(DefaultCameraVec, DefaultCameraSpeed, DefaultCameraRelative, DefaultCameraFixed)")

for i = 1, 15 do
	local Name = "blockFloor"
	if i < 10 then
		Name = Name .. 0 .. i
	else
		Name = Name .. i
	end
	local Info = LvlLoader:GetInfo(Name)
	SpawnTowerInfo(Info, true, true)
end
for i = 1, 1 do
	local Name = "blockBridge"
	if i < 10 then
		Name = Name .. 0 .. i
	else
		Name = Name .. i
	end
	local Info = LvlLoader:GetInfo(Name)
	SpawnTowerInfo(Info, true, true)
end
for i = 1, 28 do
	local Name = "tower"
	if i < 10 then
		Name = Name .. 0 .. i
	else
		Name = Name .. i
	end
	local Info = LvlLoader:GetInfo(Name)
	SpawnPillarInfo(Info, true, false)
end

for i = 1, 48 do
	local PieceName = "compositeObjects/tikiTorch"
	if i < 10 then
		PieceName = PieceName .. 0 .. i
	else
		PieceName = PieceName .. i
	end
	local PieceInfo = LvlLoader:GetInfo(PieceName)
	GlobalSpawnController:SpawnIgobj(PieceInfo.Pos_, PieceInfo.Scale_, PieceInfo.Rot_, "levelLoader\\tikiTorch.igobj", PieceName, 0.0, true, 3, true);
end

cameraEndPos01 = LvlLoader:GetInfo("cameraEndPos01").Pos_
cameraEndDir01 = LvlLoader:GetInfo("cameraEndDir01").Pos_
cameraEndPos02 = LvlLoader:GetInfo("cameraEndPos02").Pos_
cameraEndDir02 = LvlLoader:GetInfo("cameraEndDir02").Pos_
rockSpawn05 = LvlLoader:GetInfo("rockSpawn05")
floorImplosion01 = LvlLoader:GetInfo("floorImplosion01")

if true then
	SpawnTriggerInfo(LvlLoader:GetInfo("endTrigger01"), false, false, 
	[[
		PlayerData:LockPlayerToPos(cameraEndDir01);
		PlayerData:SetCameraPositionLookat(cameraEndPos01, cameraEndDir01, 0.03);
		PlayerData:ShakeCamera(14.0, 16.0, 16.0);
		Sound:StopMusic();
		Sound:PlayMusic("TouchIdol");
	]])
	SpawnTriggerInfo(LvlLoader:GetInfo("endTrigger02"), false, false, 
	[[
		PlayerData:LockPlayer(Vector3D(0.0, 0.0, 0.0));
		doomWall = SpawnDoomWallInfo(LvlLoader:GetInfo("doomWall01"));
		doomWall.Occupied_ = true;
		EventManager:AddEvent(false, 2.0, "GlobalSpawnController:CreateImplosion(floorImplosion01.Pos_, floorImplosion01.Scale_.x, 300.0)");
		EventManager:AddEvent(false, 1.0, "Sound:PlayEvent(\"DoomWallFollow\", cameraEndDir01, Vector3D(0,0,0))");
		EventManager:AddEvent(false, 2.0, "Sound:PlayEvent(\"DistantExplosion\", cameraEndDir01, Vector3D(0,0,0))");
		EventManager:AddEvent(false, 7.0, "PlayerData:SetCameraPositionLookat(cameraEndPos02, cameraEndDir02, 0.03)");
		EventManager:AddEvent(false, 11.0, "PlayerData:SetCameraPosition(Vector3D(0.0, -50.0, 600.0), 0.04, true, true)");
		EventManager:AddEvent(false, 12.5, "GameEngine.CurrentLevelNum_ = 1; GameEngine.GameOver = true; GameEngine.FirstRun = true;");
	]])
end
		--doomWall = SpawnDoomWallInfo(LvlLoader:GetInfo("doomWall01"));
		--doomWall.Occupied_ = true;
		--PlayerData:SetCameraPositionLookat(cameraEndPos01, cameraEndDir01, 0.03);

rockSpawn01 = LvlLoader:GetInfo("rockSpawn02")
rock = GlobalSpawnController:SpawnNormalRock(rockSpawn01.Pos_, Vector3D(500.0, 0.0, -500.0), rockSpawn01.Scale_.x, 1000.0)
rock:Delete(1)


--levelLoader/compositeObjects/statueComposite01
--Totem01 = LvlLoader:GetInfo("totem01")
--GlobalSpawnController:SpawnGenericObject(Totem01.Pos_, Totem01.Scale_, Totem01.Rot_, "meshes/terrain/Statue.x", "materials/statue.mat", 1.0);

for i = 1, 1 do
	local PieceName = "compositeObjects\\statueComposite"
	if i < 10 then
		PieceName = PieceName .. 0 .. i
	else
		PieceName = PieceName .. i
	end
	local PieceInfo = LvlLoader:GetInfo(PieceName)
	GlobalSpawnController:SpawnIgobj(PieceInfo.Pos_, PieceInfo.Scale_, PieceInfo.Rot_, "levelLoader\\statue.igobj", PieceName, 0.1, false, 3, true);
end

MinZ = -100000.0
KillsNeeded = 0