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

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

--print("CaveLevel3_Init.lua")

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

EventManager:AddEvent(false, 0.0, "PlayerData:LockPlayer(Vector3D(0.0, 0.0, 0.0))")
EventManager:AddEvent(false, 0.0, "PlayerData:SetEmissiveColor(Vector3D(1.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.0), 1.0)")
EventManager:AddEvent(false, 0.0, "PlayerData:SetCameraPosition(Vector3D(0.0, -50.0, 25.0), 0.2, true, true)");
DefaultCameraSpeed_2 = DefaultCameraSpeed + 0.03
EventManager:AddEvent(false, 0.0, "PlayerData:SetCameraPosition(DefaultCameraVec, DefaultCameraSpeed_2, DefaultCameraRelative, DefaultCameraFixed)")
EventManager:AddEvent(false, 0.0, "PlayerData.MoveSpeed_ = 750");
EventManager:AddEvent(false, 1.0, "PlayerData:UnlockPlayer()")

BlobHall01Spawns = {}
BlobHall01Directions = {}

for i = 1, 8 do
	local BlobName = "blobHall01Spawn"
	if i < 10 then
		BlobName = BlobName .. 0 .. i
	else
		BlobName = BlobName .. i
	end
	BlobHall01Spawns[i] = LvlLoader:GetInfo(BlobName).Pos_
	
	local DirName = "blobHall01Direction"
	if i < 10 then
		DirName = DirName .. 0 .. i
	else
		DirName = DirName .. i
	end
	BlobHall01Directions[i] = LvlLoader:GetInfo(DirName).Pos_
end

BlobRadius = 35.0
BlobMass = 10.0
BlobSpeed = 300.0
BlobNum = 1
ExplosionRadius = 300.0
ExplosionMagnitude = 650.0
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger01"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[1], BlobHall01Directions[1], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger02"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[2], BlobHall01Directions[2], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger03"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[3], BlobHall01Directions[3], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger04"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[4], BlobHall01Directions[4], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger05"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[5], BlobHall01Directions[5], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger06"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[6], BlobHall01Directions[6], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger07"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[7], BlobHall01Directions[7], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])
SpawnTriggerInfo(LvlLoader:GetInfo("BlobHall01Trigger08"), false, false, 
[[
	GlobalSpawnController:SpawnBlobCluster(BlobHall01Spawns[8], BlobHall01Directions[8], BlobSpeed, BlobRadius, BlobMass, BlobNum, ExplosionRadius, ExplosionMagnitude);
]])


SpawnTriggerInfo(LvlLoader:GetInfo("rockFallStartTrigger01"), false, false, 
[[
	GlobalSpawnController:PushDynamicSpawn(DynamicSpawnPoint(Vector3D(0,0,0), Vector3D(0,0,0), Vector3D(0,0,0), 0.3, 50.0, GlobalSpawnController, 5));
]])
SpawnTriggerInfo(LvlLoader:GetInfo("rockFallEndTrigger01"), false, false, 
[[
	GlobalSpawnController:ClearSpawns();
]])




for i = 1, 16 do
	local PieceName = "level2HallTower"
	if i < 10 then
		PieceName = PieceName .. 0 .. i
	else
		PieceName = PieceName .. i
	end
	local PieceInfo = LvlLoader:GetInfo(PieceName)
	SpawnTowerInfo(PieceInfo, true, false)
end
for i = 1, 0 do
	local PieceName = "level2FloorTower"
	if i < 10 then
		PieceName = PieceName .. 0 .. i
	else
		PieceName = PieceName .. i
	end
	local PieceInfo = LvlLoader:GetInfo(PieceName)
	SpawnTowerInfo(PieceInfo, true, true)
end
for i = 1, 14 do
	local PieceName = "level2FloatingBlock"
	if i < 10 then
		PieceName = PieceName .. 0 .. i
	else
		PieceName = PieceName .. i
	end
	local PieceInfo = LvlLoader:GetInfo(PieceName)
	SpawnTowerInfo(PieceInfo, true, false)
end
for i = 1, 7 do
	local PieceName = "platform"
	if i < 10 then
		PieceName = PieceName .. 0 .. i
	else
		PieceName = PieceName .. i
	end
	local PieceInfo = LvlLoader:GetInfo(PieceName)
	GlobalSpawnController:SpawnPlatform(PieceInfo.Pos_, PieceInfo.Scale_, PieceInfo.Rot_);
end
for i = 1, 63 do
	local PieceName = "stalagmite"
	if i < 10 then
		PieceName = PieceName .. 0 .. i	
	else
		PieceName = PieceName .. i
	end
	Info = LvlLoader:GetInfo(PieceName)
	Scale = Vector3D(Info.Scale_.x, Info.Scale_.z, Info.Scale_.y)
	GlobalSpawnController:SpawnShard(Info.Pos_, Scale, Info.Rot_, 0.0);
end



for i = 1, 5 do
	local lavaName = "lavaPool"
	if i < 10 then
		lavaName = lavaName .. 0 .. i	
	else
		lavaName = lavaName .. i
	end
	Info = LvlLoader:GetInfo(lavaName)
	GlobalSpawnController:SpawnLavaPool(Info.Pos_, Info.Scale_, Info.Rot_, 200.0, 50.0)
end

MinZ = -100000.0
KillsNeeded = 0