//---------------------------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------
// startGame
// All game logic should be set up here. This will be called by the level builder when you
// select "Run Game" or by the startup process of your game to load the first level.
//---------------------------------------------------------------------------------------------
function startGame(%level)
{
   Canvas.setContent(mainScreenGui);
   Canvas.setCursor(DefaultCursor);
   
   setupKeybinds();  
   moveMap.push();
   
   $enableDirectInput = true;
   activateDirectInput();
   enableJoystick();
   
   // include script files
   exec("game/gameScripts/auxiliaryFunctions.cs");
   
   exec("game/gameScripts/controls/sceneWindow2D.cs");
   exec("game/gameScripts/controls/parallaxRegister.cs");
   exec("game/gameScripts/controls/gui.cs"); 
   exec("game/gameScripts/controls/menuButton.cs"); 
   exec("game/gameScripts/controls/menuFunctions.cs"); 
   
   exec("game/gameScripts/gameplay/hexxgame.cs");
   exec("game/gameScripts/gameplay/hexfield.cs");
   exec("game/gameScripts/gameplay/player.cs");
   exec("game/gameScripts/gameplay/resourceController.cs");
   
   exec("game/gameScripts/ai/pathfinding.cs");
   exec("game/gameScripts/ai/aicontrol.cs");
   exec("game/gameScripts/ai/analyzer.cs");
   
   exec("game/gameScripts/audio/soundProfiles.cs");
   exec("game/gameScripts/audio/sounds.cs");
   exec("game/gameScripts/audio/musicControl.cs");
   
   // set camera interpolation mode to linear
   sceneWindow2D.setCameraInterpolationMode("LINEAR");
   
   // load background
   backgroundWindow.loadLevel("game/data/levels/common/background.t2d");
   
   // load menu
   exec("game/gui/menu.gui");
   menuWindow.loadLevel("game/data/levels/common/menu.t2d");
   Canvas.pushDialog(menuWindow);
   
   // start music and play start sound
   musicController.changeMusicFile();
}

//---------------------------------------------------------------------------------------------
// endGame
// Game cleanup should be done here.
//---------------------------------------------------------------------------------------------
function endGame()
{
   sceneWindow2D.endLevel();
   gui_hud.endLevel();
   gui_status.endLevel();
   menuWindow.endLevel();
   
   moveMap.pop();
   moveMap.delete();
}