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[] { "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));
                }
                                                                       ));
            }
        }