------------------------------------------------------------------------------
-- FUNCTION POINTERS
local GLOBAL_AddPopupTextToQueue = Global.AddPopupTextToQueue
local GLOBAL_DeleteEntityByPtr   = Global.DeleteEntityByPtr

local ENTITY_GetMyPointer        = Entity.GetMyPointer


------------------------------------------------------------------------------
-- VARS EPISODE 1
local TITLE = "Dreamside Maroon"
local X = .1
local Y = .6
local ffCollected, colLanterns, allLanterns, colIslands, allIslands, colLights, allLights, vineLen = Global:TotalStats()
local seasons = math.min( math.floor( colLanterns / 9 ) + 1, 3 )
allLanterns   = math.max( allLanterns, 30 )
allLights     = math.max( allLights, 42 )
local CREDITS = { { [1] =    8000, [2] = "Matt Anderson:\n  Producer\n  Graphics Engineer\n  Lead Artist" },
                  { [1] =    8000, [2] = "Justin Whitney:\n  Designer\n  Writer\n  Physics Engineer\n  Island Artist" },
                  { [1] =    8000, [2] = "Ian Eller:\n  Audio Director\n  Sound Engineer\n  Script Engineer\n  Composer" },
                  { [1] =    8000, [2] = "Hamza M. Hutchinson:\n  Technical Director\n  Architecture Engineer\n  Vine Engineer" },
                  { [1] =    8000, [2] = "Wonderful Instructors:\n  Ben Ellinger\n  Rachel Rutherford\n  Chris Peters" },
                  { [1] =    4000, [2] = "President:\n  Claude Comair" },
                  { [1] =    2000, [2] = "Special Thanks: " },
                  { [1] =   12000, [2] = "Matt Anderson thanks,\n  Bati, Nik, Squid,\n  Sam, Jared, Chris, Serge,\n  Professors Erhardt and Sward, Rachel, Ben, and Chris" },
                  { [1] =   12000, [2] = "Ian Eller thanks,\n  Matt Anderson & Justin Whitney,\n  Emma Romey, Rachel Rutherford,\n  Kathy, Scott, Keith" },
                  { [1] =   12000, [2] = "Hamza Hutchinson thanks,\n  Mom, Dad, Qassim\n  Ibrahim, Isa, Uncle Den,\n  Aunt Ellen, Nick, Jon, Ben" },
                  { [1] =   12000, [2] = "Justin Whitney thanks,\n  Susan, David, Ashley,\n  Irene, Barbara" },
                  { [1] =    5000, [2] = "(c) 2008-2009 DigiPen (USA) Corporation,\n    all rights reserved" },
                  { [1] =    4000, [2] = "Stats:" },
                  { [1] =    6000, [2] = "Fireflies collected: " .. ffCollected },
                  { [1] =    6000, [2] = "Lanterns lit: " .. colLanterns .. "/" .. allLanterns },
                  { [1] =    6000, [2] = "Islands expanded: " .. colIslands .. "/" .. allIslands },
                  { [1] =    6000, [2] = "Auras illuminated: " .. colLights .. "/" .. allLights },
                  { [1] =    6000, [2] = "Seasons passed: " .. seasons .. "/" .. 3 },
                  { [1] =    6000, [2] = "Total vine length: " .. vineLen .."m" },
                  { [1] =    4000, [2] = "Thank You For Playing" },
                  { [1] = 1000000, [2] = "Dreamside Maroon" } }

------------------------------------------------------------------------------
-- Writing some text
local function AddText( text, time )

  Global:AddPopupTextToQueue( text, time, X, Y )

end

------------------------------------------------------------------------------
-- Sending the credits
for key, value in pairs( CREDITS )
do
  AddText( value[2], value[1] )
end

GLOBAL_DeleteEntityByPtr( ENTITY_GetMyPointer( Entity ) )

------------------------------------------------------------------------------
-- LOOPY (SHOULD NEVER GET THIS FAR)
while( 1 )
do
  coroutine.yield()

end
