Beispiel #1
0
        public void teste1()
        {
            String text = File.ReadAllText("script1.txt");

            String[] references = new String[] { "System.dll", "mscorlib.dll" };
            String   srt        = Generator.GenerateFullClass(references, null, "azulteste", "bla", text, "Method");

            Console.WriteLine(srt);
            StreamWriter sw = File.CreateText("teste.cs");

            sw.Write(srt);
            sw.Close();

            String   erro;
            Assembly Assembly = Compilers.GenerateAssembly(srt, references, out erro);

            if (erro != null)
            {
                MessageBox.Show(erro);
                return;
            }

            Executor.Execute("azulteste.bla", Assembly, "Method");

            Console.ReadLine();
        }
Beispiel #2
0
        public void teste4()
        {
            ScriptParsed ScriptParsed = Parser.ParseScriptFile("script4.txt");

            List <String> references = new List <string>()
            {
                "test.exe"
            };

            List <String> usings = new List <string>()
            {
                "test", "System", "System.Collections.Generic"
            };

            usings.AddRange(ScriptParsed.UsingStatements);

            Generator GenerateClassCode = new PloobsScripts.Generator(references, usings, "TesteInter");

            GenerateClassCode.GenerateClass("teste", "interteste");

            GenerateClassCode.GenerateMethod("handle", ScriptParsed.MethodCode, typeof(void), System.CodeDom.MemberAttributes.Public);

            String srt = GenerateClassCode.GetCode(ScriptParsed);

            Console.WriteLine(srt);
            StreamWriter sw = File.CreateText("teste3.cs");

            sw.Write(srt);
            sw.Close();

            String   erro;
            Assembly Assembly = Compilers.GenerateAssembly(srt, references, out erro);

            if (erro != null)
            {
                MessageBox.Show(erro);
                return;
            }

            interteste interteste = Executor.BindTypeFromAssembly <interteste>(Assembly, GenerateClassCode.TypeName);

            interteste.handle();
            interteste.handle();
            interteste.handle();

            Console.ReadLine();
        }
Beispiel #3
0
        public void teste2()
        {
            String        text       = File.ReadAllText("script2.txt");
            List <String> references = new List <String> {
                "System.dll", "mscorlib.dll", "test.exe"
            };
            List <String> imports = new List <String> {
                "test"
            };

            Generator GenerateClassCode = new PloobsScripts.Generator(references, imports, "TesteInter");

            GenerateClassCode.GenerateClass("teste", "interteste");

            GenerateClassCode.GenerateMethod("handle", text, typeof(void), System.CodeDom.MemberAttributes.Public);

            String srt = GenerateClassCode.GetCode();

            Console.WriteLine(srt);
            StreamWriter sw = File.CreateText("teste2.cs");

            sw.Write(srt);
            sw.Close();

            String   erro;
            Assembly Assembly = Compilers.GenerateAssembly(srt, references, out erro);

            if (erro != null)
            {
                MessageBox.Show(erro);
                return;
            }

            interteste interteste = Executor.BindTypeFromAssembly <interteste>(Assembly, GenerateClassCode.TypeName);

            interteste.handle();

            Console.ReadLine();
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ScriptParsed ScriptParsed = Parser.ParseScriptFile("Content//Script//script.txt");

            ScriptParsed.References.AddRange(new String[] { "IntroductionDemo4.0.exe", "PloobsEngineDebug.dll" });

            ScriptParsed.UsingStatements.AddRange(new String[] { "IntroductionDemo4._0", "System", "System.Collections.Generic", "System.Text"
                                                                 , "PloobsEngine.Engine", "PloobsEngine.Modelo", "PloobsEngine.Physics.Bepu", "PloobsEngine.Material", "PloobsEngine.SceneControl"
                                                                 , "Microsoft.Xna.Framework", "PloobsEngine.Physics", "PloobsEngine.Utils", "PloobsEngine.Light"
                                                                 , "Microsoft.Xna.Framework.Graphics", "PloobsEngine.Cameras", "PloobsEngine.Features", "PloobsEngine.Commands" });

            Generator GenerateClassCode = new PloobsScripts.Generator(ScriptParsed, "TesteInter", true, true);

            GenerateClassCode.GenerateClass("teste", "ISceneBuilder");
            GenerateClassCode.GenerateMethod("BuildScene", ScriptParsed.MethodCode, typeof(void), System.CodeDom.MemberAttributes.Public | System.CodeDom.MemberAttributes.Override);
            String srt = GenerateClassCode.GetCode(ScriptParsed);

            String   erro     = null;
            Assembly Assembly = Compilers.GenerateAssembly(srt, ScriptParsed.References, out erro);

            if (erro != null)
            {
                throw new Exception(erro);
            }

            ISceneBuilder interteste = Executor.BindTypeFromAssembly <ISceneBuilder>(Assembly, GenerateClassCode.TypeName);

            interteste.graphicFactory = GraphicFactory;
            interteste.graphicInfo    = GraphicInfo;
            interteste.world          = this.World;
            interteste.renderTechnic  = RenderTechnic;

            interteste.BuildScene();
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ///script to build the scene
            {
                ScriptParsed ScriptParsed = Parser.ParseScriptFile("Content//Script//script.txt");
                ScriptParsed.References.AddRange(new String[] { "IntroductionDemo4.0.exe", "PloobsEngineDebug.dll" });

                ScriptParsed.UsingStatements.AddRange(new String[] { "IntroductionDemo4._0", "System", "System.Collections.Generic", "System.Text"
                                                                     , "PloobsEngine.Engine", "PloobsEngine.Modelo", "PloobsEngine.Physics.Bepu", "PloobsEngine.Material", "PloobsEngine.SceneControl"
                                                                     , "Microsoft.Xna.Framework", "PloobsEngine.Physics", "PloobsEngine.Utils", "PloobsEngine.Light"
                                                                     , "Microsoft.Xna.Framework.Graphics", "PloobsEngine.Cameras", "PloobsEngine.Features", "PloobsEngine.Commands" });


                Generator GenerateClassCode = new PloobsScripts.Generator(ScriptParsed, "TesteInter", true, true);
                GenerateClassCode.GenerateClass("teste", "ISceneBuilder");
                GenerateClassCode.GenerateMethod("BuildScene", ScriptParsed.MethodCode, typeof(void), System.CodeDom.MemberAttributes.Public | System.CodeDom.MemberAttributes.Override);
                String srt = GenerateClassCode.GetCode(ScriptParsed);

                String   erro     = null;
                Assembly Assembly = Compilers.GenerateAssembly(srt, ScriptParsed.References, out erro);
                if (erro != null)
                {
                    throw new Exception(erro);
                }

                ISceneBuilder interteste = Executor.BindTypeFromAssembly <ISceneBuilder>(Assembly, GenerateClassCode.TypeName);

                interteste.graphicFactory = GraphicFactory;
                interteste.graphicInfo    = GraphicInfo;
                interteste.world          = this.World;
                interteste.renderTechnic  = RenderTechnic;

                interteste.BuildScene();
            }

            ///script to handle messages
            {
                ScriptParsed ScriptParsed = Parser.ParseScriptFile("Content//Script//talk1.txt");
                ScriptParsed.References.AddRange(new String[] { "IntroductionDemo4.0.exe", "PloobsEngineDebug.dll" });

                ScriptParsed.UsingStatements.AddRange(new String[] { "IntroductionDemo4._0", "System", "System.Collections.Generic", "System.Text"
                                                                     , "PloobsEngine.Engine", "PloobsEngine.Modelo", "PloobsEngine.Physics.Bepu", "PloobsEngine.Material", "PloobsEngine.SceneControl"
                                                                     , "Microsoft.Xna.Framework", "PloobsEngine.Physics", "PloobsEngine.Utils", "PloobsEngine.Light"
                                                                     , "Microsoft.Xna.Framework.Graphics", "PloobsEngine.Cameras", "PloobsEngine.MessageSystem", "PloobsEngine.Features", "PloobsEngine.Commands" });

                Generator GenerateClassCode = new PloobsScripts.Generator(ScriptParsed, "IntroductionDemo4._0", true, true);
                GenerateClassCode.GenerateClass("talk", "InterScriptTalking");
                GenerateClassCode.GenerateMethod("execute", ScriptParsed.MethodCode, typeof(void), System.CodeDom.MemberAttributes.Public | System.CodeDom.MemberAttributes.Override);
                String srt = GenerateClassCode.GetCode(ScriptParsed);

                String   erro     = null;
                Assembly Assembly = Compilers.GenerateAssembly(srt, ScriptParsed.References, out erro);
                if (erro != null)
                {
                    throw new Exception(erro);
                }

                interteste = Executor.BindTypeFromAssembly <InterScriptTalking>(Assembly, GenerateClassCode.TypeName);

                interteste.graphicFactory = GraphicFactory;
                interteste.graphicInfo    = GraphicInfo;
                interteste.world          = this.World;
                interteste.renderTechnic  = RenderTechnic;

                interteste.execute();
                EntityMapper.getInstance().AddEntity(interteste);

                SystemRecieverMessage            = new SystemRecieverMessage();
                SystemRecieverMessage.OnMessage += new Action <Message>(SystemRecieverMessage_OnMessage);
                EntityMapper.getInstance().AddgrouptagRecieveEntity("teste", SystemRecieverMessage);

                this.BindInput(new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space,
                                                                       (a) =>
                {
                    ///5000 is the id of the script
                    ///defined inside it =P look talk1.txt
                    MessageDeliver.SendMessage(new Message(-1, 5000, null, Priority.LOW, 0, SenderType.NORMAL, StaticRandom.PickRandomPoint(new Vector3(100, 100, 100), new Vector3(200, 100, 200), new Vector3(-100, 100, -100)), null));
                }
                                                                       ));
            }
        }