예제 #1
0
 private void InitializeHelperFunctions(AchievementHelpers helpers)
 {
     foreach (var function in helpers.GetBuiltInFunctions())
     {
         _engine.SetFunction(function.Name, function.Action);
     }
 }
예제 #2
0
        public void RegisterHandlers(AchievementHelpers helpers)
        {
            String code = _achievement.Code;

            var progTriggersIndex = code.IndexOf(ProgramTriggersLiteral);
            var memoryTriggersIndex = code.IndexOf(MemoryTriggersLiteral);
            var jsIndex = code.IndexOf(CodeLiteral);

            String programTriggersCode = code.Substring(
                progTriggersIndex + ProgramTriggersLiteral.Length,
                memoryTriggersIndex - (progTriggersIndex + ProgramTriggersLiteral.Length));

            String memoryTriggersCode = code.Substring(
                memoryTriggersIndex + MemoryTriggersLiteral.Length,
                jsIndex - (memoryTriggersIndex + MemoryTriggersLiteral.Length));

            String javascriptCode = code.Substring(
                jsIndex + CodeLiteral.Length,
                code.Length - (jsIndex + CodeLiteral.Length));

            LoadJavascriptCode(javascriptCode);
            InitializeHelperFunctions(helpers);
            LoadProgramTriggers(programTriggersCode);
            LoadMemoryTriggers(memoryTriggersCode);
            InitializeRunningContext();
            //_gameEventAggregator.AddGameEndedHandler(() => _achievement.State = (String)_engine.CallFunction("getState"));

            var result = _engine.CallFunction("initialize", _achievement.State);
        }