public void Draw(ParticleRenderer renderer, IBatchContainer container, int layer)
        {
            RenderArgs.SetTime(TimeProvider);
            RenderArgs.SetContainer(renderer.Materials, container, layer);

            ParticleCollection sector;

            using (var e = Particles.GetSectorsFromBounds(renderer.Viewport, false))
                while (e.GetNext(out sector))
                {
                    DrawSector(sector);
                }

            _ParticlesRemovedByLimit = 0;
        }
示例#2
0
        public override void LoadContent()
        {
            LightmapMaterials = new DefaultMaterialSet(Game.Services);

            LightingEnvironment.DefaultSubdivision = 512f;

            BackgroundEnvironment = new LightingEnvironment();
            ForegroundEnvironment = new LightingEnvironment();

            BackgroundRenderer = new LightingRenderer(Game.Content, LightmapMaterials, BackgroundEnvironment);
            ForegroundRenderer = new LightingRenderer(Game.Content, LightmapMaterials, ForegroundEnvironment);

            // Add a global sun
            AddAmbientLight(746, -300);

            // Add clipped suns for areas with weird shadowing behavior
            AddAmbientLight(746, 200, new Bounds(
                new Vector2(38, 33),
                new Vector2(678, 678)
            ));

            AddAmbientLight(740, 240, new Bounds(
                new Vector2(805, 34),
                new Vector2(1257, 546)
            ));

            AddAmbientLight(741, 750, new Bounds(
                new Vector2(0, 674),
                new Vector2(1257, 941)
            ));

            AddAmbientLight(741, 1025, new Bounds(
                new Vector2(0, 941),
                new Vector2(1257, 1250)
            ));

            AddTorch(102, 132);
            AddTorch(869, 132);
            AddTorch(102, 646);
            AddTorch(869, 645);

            GenerateObstructionsFromTiles();

            Layers[0] = Game.Content.Load<Texture2D>("layers_bg");
            Layers[1] = Game.Content.Load<Texture2D>("layers_fg");
            Layers[2] = Game.Content.Load<Texture2D>("layers_chars");
            Layers[3] = Game.Content.Load<Texture2D>("layers_torches");

            BricksLightMask = Game.Content.Load<Texture2D>("layers_bricks_lightmask");

            AdditiveBitmapMaterial = LightmapMaterials.ScreenSpaceBitmap.SetStates(blendState: BlendState.Additive);

            MaskedForegroundMaterial = LightmapMaterials.ScreenSpaceLightmappedBitmap.SetStates(blendState: BlendState.Additive);

            AOShadowMaterial = Game.ScreenMaterials.ScreenSpaceVerticalGaussianBlur5Tap.SetStates(blendState: RenderStates.SubtractiveBlend);

            ParticleRenderer = new ParticleRenderer(LightmapMaterials) {
                Viewport = new Bounds(Vector2.Zero, new Vector2(Width, Height))
            };

            Spark.Texture = Game.Content.Load<Texture2D>("spark");

            ParticleRenderer.Systems = new[] {
                Sparks = new ParticleSystem<Spark>(
                    new DotNetTimeProvider(),
                    BackgroundEnvironment
                )
            };
        }