Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                CheckArgumentsHaveBeenSupplied(args);
                var scriptPath        = args[0];
                var nameOfScriptToRun = args[1];

                CheckScriptPathIsValid(scriptPath);

                var scriptCollection = LoadScriptCollectionFromScriptFile(scriptPath);

                CheckNameOfScriptToRunIsValid(scriptCollection, nameOfScriptToRun);

                var scriptSystem = new ScriptSystem();
                scriptSystem.GlobalVariables.SetVariable("globalvariable", 42);

                var player1 = new ScriptRunningInstance(scriptCollection[nameOfScriptToRun]);
                player1.VariablesManager.SetVariable("playernumber", 1);
                var player2 = new ScriptRunningInstance(scriptCollection[nameOfScriptToRun]);
                player2.VariablesManager.SetVariable("playernumber", 2);
                scriptSystem.Run(player1);
                scriptSystem.Run(player2);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            Console.WriteLine("Done");
        }
Exemple #2
0
 public bool Run(ScriptRunningInstance player)
 {
     return(_interpreter.Run(player.ProgramCounter, player.VariablesManager));
 }