Exemplo n.º 1
0
 public static void InitializeLanguage(CommandInterpreter interpreter)
 {
     // Register Commands
     interpreter.RegisterCommand(new Command("AddScene", 2, AddScene));
     interpreter.RegisterCommand(new Command("AddLayer", 3, AddLayer));
     interpreter.RegisterCommand(new Command("AddObject", 4, AddObject));
     ParseScript("entryScript.qsf", interpreter);
 }
Exemplo n.º 2
0
        public Engine(IGame game)
        {
            _internalReference = this;
            _lock = new Object();
            m_Graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            m_SceneManager = new Graphical.SceneManager();
            m_TrashCompactor = new Tantric.Trash.TrashCompactor();
            m_Interpreter = new Tantric.Scripting.CommandInterpreter();
            m_Game = game;

            Scripting.QuantumLanguage.InitializeLanguage(m_Interpreter);
            m_Interpreter.Evaluate("EntryScript");
        }
Exemplo n.º 3
0
        public Engine(IGame game)
        {
            _internalReference = this;
            _lock                 = new Object();
            m_Graphics            = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            m_SceneManager        = new Graphical.SceneManager();
            m_TrashCompactor      = new Tantric.Trash.TrashCompactor();
            m_Interpreter         = new Tantric.Scripting.CommandInterpreter();
            m_Game                = game;

            Scripting.QuantumLanguage.InitializeLanguage(m_Interpreter);
            m_Interpreter.Evaluate("EntryScript");
        }
Exemplo n.º 4
0
        public static void ParseScript(String fileName, CommandInterpreter interpreter)
        {
            StreamReader file  = new StreamReader(fileName);
            String       line  = file.ReadLine();
            String       line2 = file.ReadLine();

            while (line2 != null)
            {
                if (line2.Contains("{"))
                {
                    interpreter.RegisterCommand(new Script(interpreter, fileName, line));
                }
                line  = line2;
                line2 = file.ReadLine();
            }
        }
Exemplo n.º 5
0
        // Constructor : initialize default variables
        public Script(CommandInterpreter interpreter, String fileName, String name) : base(name, 1, null)
        {
            m_Commands    = new List <string>();
            m_Interpreter = interpreter;
            this.Callback = this.Execute;
            StreamReader file  = new StreamReader(fileName);
            String       line  = "";
            String       line2 = "";
            bool         Found = false;

            // Specifically, parse the script in itself
            while (!Found)
            {
                line2 = file.ReadLine().Trim();
                if (line2 == null)
                {
                    return;
                }
                if (line == name)
                {
                    if (line2 == "{")
                    {
                        Found = true;
                    }
                }
                else
                {
                    line = line2;
                }
            }

            ArgumentCount = line.Split(" ".ToCharArray(), StringSplitOptions.None).Length - 1;

            line = file.ReadLine().Trim();
            while (!line.Contains("}"))
            {
                // Add each lin that isn't a comment to m_Commands
                if (!line.StartsWith("//", StringComparison.OrdinalIgnoreCase))
                {
                    m_Commands.Add(line);
                }
                line = file.ReadLine().Trim();
            }
        }
Exemplo n.º 6
0
        // Constructor : initialize default variables
        public Script(CommandInterpreter interpreter, String fileName, String name)
            : base(name, 1, null)
        {
            m_Commands = new List<string>();
            m_Interpreter = interpreter;
            this.Callback = this.Execute;
            StreamReader file = new StreamReader(fileName);
            String line = "";
            String line2 = "";
            bool Found = false;
            // Specifically, parse the script in itself
            while (!Found)
            {
                line2 = file.ReadLine().Trim();
                if (line2 == null)
                    return;
                if (line == name)
                {
                    if (line2 == "{")
                        Found = true;
                }
                else
                    line = line2;
            }

            ArgumentCount = line.Split(" ".ToCharArray(), StringSplitOptions.None).Length - 1;

            line = file.ReadLine().Trim();
            while (!line.Contains("}"))
            {
                // Add each lin that isn't a comment to m_Commands
                if (!line.StartsWith("//", StringComparison.OrdinalIgnoreCase))
                    m_Commands.Add(line);
                line = file.ReadLine().Trim();
            }
        }
Exemplo n.º 7
0
 public static void ParseScript(String fileName, CommandInterpreter interpreter)
 {
     StreamReader file = new StreamReader(fileName);
     String line = file.ReadLine();
     String line2 = file.ReadLine();
     while (line2 != null)
     {
         if (line2.Contains("{"))
             interpreter.RegisterCommand(new Script(interpreter, fileName, line));
         line = line2;
         line2 = file.ReadLine();
     }
 }