Пример #1
0
 /// <summary>
 /// Fired when the entity is despawned.
 /// </summary>
 public override void OnDespawn()
 {
     if (Entity.Engine is GameEngine2D eng)
     {
         eng.Lights.Remove(ActualLight);
         ActualLight.Destroy();
         ActualLight = null;
         Entity.OnPositionChanged -= FixPosition;
     }
     else
     {
         SysConsole.Output(OutputType.WARNING, "2D light despawned from a non-2D-engine-based game!");
     }
 }
Пример #2
0
 /// <summary>
 /// Fired when the entity is spawned.
 /// </summary>
 public override void OnSpawn()
 {
     if (Entity.Engine is GameEngine2D eng)
     {
         ActualLight = new PointLight2D(LightPosition, LightStrength, LightSDScale, eng)
         {
             Color          = LightColor,
             ShouldShadow   = CastShadow,
             ExtraLightDist = LightExtraDist,
             IsSkyLight     = IsSkyLight
         };
         eng.Lights.Add(ActualLight);
         Entity.OnPositionChanged += FixPosition;
     }
     else
     {
         SysConsole.Output(OutputType.WARNING, "2D light spawned into a non-2D-engine-based game!");
     }
 }
Пример #3
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");

            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            {
                Texture2D tex              = factory.GetTexture2D("Textures//goo");
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, 0);
                this.World.AddObject(o);
            }

            ///from texture, scale usage sample
            {
                Texture2D tex = factory.GetTexture2D("Textures//goo");
                tex = factory.GetScaledTexture(tex, new Vector2(2));
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
                this.World.AddObject(o);
            }

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(50, 50);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(-200, 0);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, -100);
                this.World.AddObject(o);
            }

            ///animated sprite
            {
                Texture2D      tex = factory.GetTexture2D("Textures//DudeSheet");
                SpriteAnimated sa  = new SpriteAnimated(tex, 8, 2);
                sa.AddAnimation("ANIM1", 1, 8, 0);
                sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2);

                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                Texture2D     frame        = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
                FarseerObject fs           = new FarseerObject(fworld, frame);

                //GhostObject fs = new GhostObject(Vector2.Zero);
                sheet = new I2DObject(fs, mat, sa);
                sheet.PhysicObject.Position = new Vector2(500, 0);
                this.World.AddObject(sheet);
            }

            {
                PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
                this.World.AddLight(l);
            }

            {
                SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
                this.World.AddLight(l);
            }

            {
                SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space);
                sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange);
                this.BindInput(sc);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));

            this.World.ParticleManager.AddAndInitializeParticleSystem(ps);

            ///add a post effect =P
            //this.RenderTechnic.AddPostEffect(new WigglePostEffect());

            ///updateable
            JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");

            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            {
                Texture2D tex              = factory.GetTexture2D("Textures//goo");
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, 0);
                this.World.AddObject(o);
            }

            ///from texture, scale usage sample
            {
                Texture2D tex = factory.GetTexture2D("Textures//goo");
                tex = factory.GetScaledTexture(tex, new Vector2(2));
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
                this.World.AddObject(o);
            }

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(50, 50);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(-200, 0);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, -100);
                this.World.AddObject(o);
            }

            ///animated sprite
            {
                Texture2D      tex = factory.GetTexture2D("Textures//DudeSheet");
                SpriteAnimated sa  = new SpriteAnimated(tex, 8, 2);
                sa.AddAnimation("ANIM1", 1, 8, 0);
                sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2);

                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                Texture2D     frame        = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
                FarseerObject fs           = new FarseerObject(fworld, frame);

                //GhostObject fs = new GhostObject(Vector2.Zero);
                sheet = new I2DObject(fs, mat, sa);
                sheet.PhysicObject.Position = new Vector2(500, 0);
                this.World.AddObject(sheet);
            }

            {
                PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
                this.World.AddLight(l);
            }

            {
                SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
                this.World.AddLight(l);
            }

            {
                SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space);
                sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange);
                this.BindInput(sc);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));

            this.World.ParticleManager.AddAndInitializeParticleSystem(ps);

            ///add a post effect =P
            //this.RenderTechnic.AddPostEffect(new WigglePostEffect());

            ///updateable
            JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                NeoforceGui guiManager = this.Gui as NeoforceGui;
                System.Diagnostics.Debug.Assert(guiManager != null);

                // Create and setup Window control.
                Window window = new Window(guiManager.Manager);
                window.Init();
                window.Text   = "Getting Started";
                window.Width  = 480;
                window.Height = 200;
                window.Center();
                window.Visible = true;

                // Create Button control and set the previous window as its parent.
                Button button = new Button(guiManager.Manager);
                button.Init();
                button.Text   = "OK";
                button.Width  = 72;
                button.Height = 24;
                button.Left   = (window.ClientWidth / 2) - (button.Width / 2);
                button.Top    = window.ClientHeight - button.Height - 8;
                button.Anchor = Anchors.Bottom;
                button.Parent = window;

                // Add the window control to the manager processing queue.
                guiManager.Manager.Add(window);
            }
        }
Пример #5
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            //{
            //    Texture2D tex = factory.GetTexture2D("Textures//goo");
            //    IModelo2D model = new SpriteFarseer(tex);
            //    Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
            //    FarseerObject fs = new FarseerObject(fworld, tex);
            //    I2DObject o = new I2DObject(fs, mat, model);
            //    this.World.AddObject(o);
            //}

            ///from texture, scale usage sample
            //{
            //    Texture2D tex = factory.GetTexture2D("Textures//goo");
            //    tex = factory.GetScaledTexture(tex, new Vector2(2));
            //    IModelo2D model = new SpriteFarseer(tex);
            //    Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
            //    FarseerObject fs = new FarseerObject(fworld, tex);
            //    I2DObject o = new I2DObject(fs, mat, model);
            //    this.World.AddObject(o);
            //}

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(5, 5);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, verts);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(5, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, circle);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            {
                PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
                this.World.AddLight(l);
            }

            {
                SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
                this.World.AddLight(l);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            ///add a post effect =P
            //this.RenderTechnic.AddPostEffect(new WigglePostEffect());

            ///updateable
            JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);
        }