Ejemplo n.º 1
0
        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[] { "EngineTestes.exe", "PloobsEngine.dll" });

            ScriptParsed.UsingStatements.AddRange(new String[] { "EngineTestes.Scripts", "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();
        }
Ejemplo n.º 2
0
        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[] { "EngineTestes.exe", "PloobsEngine.dll" });


                ScriptParsed.UsingStatements.AddRange(new String[] { "EngineTestes.Scripts", "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[] { "EngineTestes.exe", "PloobsEngine.dll" });

                ScriptParsed.UsingStatements.AddRange(new String[] { "EngineTestes.Scripts", "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", "PloobsEngine.MessageSystem"
                                                                     , "EngineTestes.Scripts" });

                Generator GenerateClassCode = new PloobsScripts.Generator(ScriptParsed, "talking", 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);
                }

                InterScriptTalking 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(SenderType.NORMAL);
                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));
                }
                                                                       ));
            }
        }