// /// <summary>
        // /// ctor
        // /// </summary>
        // // public DBModule()
        // public OnEnable()
        // {
        // 	// Add event handler to receive messags
        // 	//DBModuleManager.EventHandler = EventHandler;
        // 	//Debug.Log ("Instanciate DBModule");
        // }
        /// <summary>
        /// Enable this module will register events and initialize the object
        /// </summary>
        void OnEnable()
        {
            Log.Debug(">>>>>>>>>>>>>>>>>>>>>> DBModule OnEnable ");

            bool oldDebugState 	= debugOutputStopped;
            debugOutputStopped 	= false;
            /*
            if (_sessionToken != MainGame.GetValue ("sessionToken"))
            {
                dbModuleEventSession (MainGame.GetValue ("sessionToken"));
            }*/

            addDebugOutput("\nDBModule added to scene");
            addDebugOutput("\nService URL: " +
                           (_protocol +
             				_serviceBaseUrl));
            addDebugOutput("\nService Timeout: " +
                           _serviceTimeout);

            debugOutputStopped = oldDebugState;
            dbModuleManager = DBModuleManager.Instance;
            if (dbModuleManager != null)
            {
                Debug.Log(">>>>>>>>>>> dbMdule ok");

                dbModuleManager.RegisterEventHandler("ADD_SERVICEURL", addServiceBaseURL);
                dbModuleManager.RegisterEventHandler("APP_CONFIGURATION_LOAD", loadAppConfiguration);
                dbModuleManager.RegisterEventHandler("CONFIG", loadConfigFile);
                dbModuleManager.RegisterEventHandler("GAME_CONFIGURATION_LOAD", loadGameConfiguration);
                dbModuleManager.RegisterEventHandler("MODULE_CONFIG_CHANGE_PROTOCOL", changeProtocol);
                dbModuleManager.RegisterEventHandler("MODULE_CONFIG_CHANGE_SERVER", changeServerType);
                dbModuleManager.RegisterEventHandler("SCREEN_CHANGE", changeScreen);
                dbModuleManager.RegisterEventHandler("SESSION_TOKEN_CHANGE", dbModuleEventSession);
                dbModuleManager.RegisterEventHandler("START_SCENARIO_LOAD", loadStartScenario);
                dbModuleManager.RegisterEventHandler("START_SCENARIO_SAVE", saveStartScenario);
                dbModuleManager.RegisterEventHandler("URL_CHANGE", dbModuleEventUrl);

                #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_IOS
                WebPlayerDebugManager.addOutput("HTTP Requests will only be performed online.", 3);
                return;

                #elif UNITY_WEBPLAYER
                dbModuleManager.RegisterEventHandler("GAME_LOAD", LoadGame);
                dbModuleManager.RegisterEventHandler("GAME_SAVE", saveGame);
                dbModuleManager.RegisterEventHandler("HIGHSCORE_SAVE", saveHighscoreSplit);
                dbModuleManager.RegisterEventHandler("DEBUG_HIGHSCORE_SAVE", saveDebugHighscoreSplit);
                dbModuleManager.RegisterEventHandler("CHECK_FOR_SAVED_GAME", checkForSavedGame);
                // TODO: Parameters?
                //trackGameAction (null, -1, null);
                //dbModuleManager.RegisterEventHandler("TRACK_ACTION", trackGameAction);
                dbModuleManager.RegisterEventHandler("TRACK_CONSTRUCTION", trackConstructionAction);
                #endif
            }

            else { Debug.LogWarning("Missing dbmodule");}
        }
        }//TestScriptConditionEvaulateBool()
        
        
//------------------------------------------------------------------------------
        
        // Use this for initialization
        public void Awake()
        {
            Debug.Log ("AquaSphereMini awake.");
            WebPlayerDebugManager.addOutput ("Version build: " + buildTime, 1);
            dbModuleManager = DBModuleManager.Instance;
            if(useDBModule)
                StartCoroutine("addServiceURL");
            
            base.Awake();
            
            //------- TODO WORKAROUND -------
            GameScenario gs = GameScenario.Instance;
            gs.currentDate = System.DateTime.Now;
            
            //Edit StartPoint
            System.DateTime startDate = GameScenario.Instance.currentDate;
            //WebPlayerDebugManager.addOutput(
            // "Get Current Date: " + startDate, 3);
            startDate = startDate.AddDays (-28);


            Log.Info("Starting AquaSphereMini...");
            
            //create conditions
            ACondition falseCond = new FalseCondition();
            ACondition trueCond  = new TrueCondition();
            ScriptCondition<bool> scriptCond =
                new ScriptCondition<bool>(
                    TestScriptConditionEvaulateBool, true);
        }
        //------------------------------------------------------------------------------
        // Use this for initialization
        public void Awake()
        {
            WebPlayerDebugManager.addOutput ("Version build: " + buildTime, 1);
            dbModuleManager = DBModuleManager.Instance;
            if(useDBModule)
                StartCoroutine("addServiceURL");

            //Debug.Log ("TWISTGame Awake");

            base.Awake();

            //------- TODO WORKAROUND -------
            GameScenario gs = GameScenario.Instance;
            gs.currentDate = System.DateTime.Now;

            //Edit StartPoint
            System.DateTime startDate = GameScenario.Instance.currentDate;
            //WebPlayerDebugManager.addOutput("Get Current Date: " + startDate, 3);
            startDate = startDate.AddDays (-28);
            string text;
            text = i18n.Get("CP1_2_2", "004").Replace(
                "15.3.2014",
                startDate.Day + "." + startDate.Month + "." + startDate.Year
                );
            i18n.Set("CP1_2_2", "004", text);

            //Edit EndPoint
            startDate = GameScenario.Instance.currentDate;
            startDate = startDate.AddDays (14);
            text = i18n.Get ("CP1_2_2", "004").Replace(
                "1.5.2014",
                startDate.Day + "." + startDate.Month + "." + startDate.Year
                );
            i18n.Set ("CP1_2_2", "004", text);
            text = i18n.Get ("CP1_5_5", "001").Replace(
                "1.5.2014",
                startDate.Day + "." + startDate.Month + "." + startDate.Year
                );
            i18n.Set ("CP1_5_5", "001", text);
            text = i18n.Get ("CP1_6_1", "001").Replace(
                "1.5.2014",
                startDate.Day + "." + startDate.Month + "." + startDate.Year
                );
            i18n.Set ("CP1_6_1", "001", text);

            //SIMMode = false;
            //TWISTMode = true;
            SIMMode = SIM;
            TWISTMode = TWIST;
            SIMOptions = ActivateSimOptions;

            //------- /WORKAROUND -------

            Log.Info("Starting TWISTBueBe...");

            // We have two sub game games to the main game
            GMGameCP gameCP = new GMGameCP("CP");
            gm.Add(gameCP);

            GMGameSIM gameSIM = new GMGameSIM("SIM");
            gm.Add(gameSIM);
            /*GameObject objSIM = UIManager.Instance.GetHud("TimeLineSIM");
            goSIM = objSIM.GetComponent<TimeLine>();

            /*gm.Start ("CP");
            gm.Get("CP").Pause();*/
            //gm.Start ("SIM");
            //gm.Get("SIM").Pause();
            //gm.Start ("CP");

            /*
            // get the view object
            GameObject objCP = UIManager.Instance.GetHud("TimeLineCP");
            goCP = objCP.GetComponent<TimeLine>();
            */

            //create conditions
            ACondition falseCond = new FalseCondition();
            ACondition trueCond  = new TrueCondition();
            ScriptCondition<bool> scriptCond =
                new ScriptCondition<bool>(
                    TestScriptConditionEvaulateBool, true);

            //Log.Info("Number of screens:"+ui.NumberOfScreens);
            //Log.Assert(ui.NumberOfScreens > 0,
            //	"No screen found! Did you tag any screen as UIScreen?");

            // Log.Assert(startScreen,
            //            "Missing start screen: '"
            //            +startScreenName+"' for "
            //            +gameObject.name);
            // //ui.ActivateScreen(startScreenName);
            // //startScreen.SetActive(true);
        }