public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _light = new PointLight
            {
                Position = new Vector2(-100, 0),
                Color = Color.White,
                Scale = new Vector2(600),
                Radius = 20
            };
            penumbra.Lights.Add(_light);

            Vector2[] hullVertices =
            {
                new Vector2(0, 50),
                new Vector2(14, 20),
                new Vector2(47, 15),
                new Vector2(23, -7),
                new Vector2(29, -40),
                new Vector2(0, -25),
                new Vector2(-29, -40),
                new Vector2(-24, -7),
                new Vector2(-47, 15),
                new Vector2(-14, 20),
            };

            penumbra.Hulls.Add(new Hull(hullVertices)
            {
                Position = new Vector2(0, 0),
            });
        }
Пример #2
0
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _isRadiusIncreasing = true;
            _progress = 0;

            _light = new PointLight
            {
                Position = new Vector2(-100, 0),
                Color = Color.White,
                Intensity = 1.5f,
                Scale = new Vector2(1200),
                Radius = MinLightRadius
            };
            penumbra.Lights.Add(_light);

            var hullVertices = new[]
            {
                new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f)
            };
            penumbra.Hulls.Add(new Hull(hullVertices)
            {
                Position = new Vector2(100, 0),
                Scale = new Vector2(50f)
            });
        }
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _isMovingLeft = false;
            _progress = 0;

            _penumbra = penumbra;
            var vertices = new[]
            {
                new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f)
            };

            _light1 = new PointLight
            {
                //Color = Color.OrangeRed,
                Color = Color.White,
                Scale = new Vector2(700),
                //Radius = 20,
                Radius = 40,
                ShadowType = ShadowType.Illuminated
            };
            //_light2 = new PointLight
            //{
            //    Color = Color.LightBlue,
            //    Range = 300,
            //    Radius = 20,
            //    ShadowType = ShadowType.Illuminated
            //};
            _penumbra.Lights.Add(_light1);
            //_penumbra.Lights.Add(_light2);

            _penumbra.Hulls.Add(new Hull(vertices) { Position = new Vector2(-HullSpacing, 0), Scale = new Vector2(50f) });
            _penumbra.Hulls.Add(new Hull(vertices) { Position = new Vector2(0, 0), Scale = new Vector2(50f) });
            _penumbra.Hulls.Add(new Hull(vertices) { Position = new Vector2(HullSpacing, 0), Scale = new Vector2(50f) });
        }
 public override void Activate(PenumbraComponent penumbra, ContentManager content)
 {
     _light = new PointLight
     {
         Position = new Vector2(-150, 0),
         Color = Color.White,
         Scale = new Vector2(700),
         Radius = 20
     };
     penumbra.Lights.Add(_light);
     _hull1 = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = HullPos1,
         Scale = new Vector2(90f)
     };
     _hull2 = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = HullPos2,
         Scale = new Vector2(70f)
     };
     _hull3 = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = HullPos3,
         Scale = new Vector2(80f)
     };
     penumbra.Hulls.Add(_hull1);
     penumbra.Hulls.Add(_hull2);
     penumbra.Hulls.Add(_hull3);
 }
        private static void MoveLight(Light light, float speed, float deltaSeconds)
        {
            float angle = deltaSeconds * speed;
            var s = (float)Sin(angle);
            var c = (float)Cos(angle);

            light.Position = new Vector2(
                light.Position.X * c - light.Position.Y * s,
                light.Position.X * s + light.Position.Y * c
            );
        }
 public override void Activate(PenumbraComponent penumbra, ContentManager content)
 {
     _light = new PointLight
     {
         Position = new Vector2(-100, 0),
         Color = Color.White,
         Scale = new Vector2(600),
         Radius = 20                
     };
     penumbra.Lights.Add(_light);
     penumbra.Hulls.Add(new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = new Vector2(0, 0),
         Scale = new Vector2(50f)
     });
 }
Пример #7
0
        public Player(Spritesheet spritesheet, Vector2 position, Vector2 groundPositionOffset, Vector2 depthSortingOffset, Stats stats, Map map, Grid grid, Player player) : base(spritesheet, position, groundPositionOffset, depthSortingOffset, stats, map, grid, player)
        {
            attackRange = 150;

            light            = new PointLight();
            light.Scale      = new Vector2(1000, 1500).ToCartesian();
            light.Intensity  = 1f;
            light.ShadowType = ShadowType.Solid;
            GameManager.Instance.Penumbra.Lights.Add(light);
            Scale        = 3;
            speed        = 200f;
            LayerDepth   = 0.2f;
            bottomHitBox = new FloatRectangle(new Vector2(Position.X, Position.Y + (int)(spritesheet.SourceRectangle.Height * 0.90 * Scale)),
                                              new Vector2(spritesheet.SourceRectangle.Width * Scale, (spritesheet.SourceRectangle.Height * Scale) / 10));

            OverhealDegradeInterval = 300f;
            CanFireBall             = 0;
            spritesheet.SetFrameCount(new Point(5, 1));
            spritesheet.Interval = 100;
            hpBar = new HealthBar(stats.MaxHealth, 0.6f /*new Vector2(200, 25)*/, new Vector2(50, 50));
        }
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _hull = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
            {
                Position = new Vector2(0, 0),
                Scale = new Vector2(50f)
            };
            penumbra.Hulls.Add(_hull);

            _light1 = new PointLight
            {
                Position = new Vector2(-250, 0),
                Color = LightColors[0],
                Intensity = 1f,
                Scale = new Vector2(800),
                Radius = 20                
            };
            _light2 = new PointLight
            {
                Position = new Vector2(0, 150),
                Color = LightColors[1],
                Intensity = 1.2f,
                Scale = new Vector2(400),
                Radius = 30
            };
            _light3 = new PointLight
            {
                Position = new Vector2(0, -50),
                Color = LightColors[2],
                Scale = new Vector2(600),
                Radius = 25,
                Intensity = 0.8f
            };
            penumbra.Lights.Add(_light1);
            penumbra.Lights.Add(_light2);
            penumbra.Lights.Add(_light3);
        }
Пример #9
0
        public void Render()
        {
            // Update hulls internal data structures.
            Hulls.Update();

            // We want to use clamping sampler state throughout the lightmap rendering process.
            // This is required when drawing lights. Since light rendering and alpha clearing is done
            // in a single step, light is rendered with slightly larger quad where tex coords run out of the [0..1] range.
            Device.SamplerStates[0] = SamplerState.LinearClamp;

            // Switch render target to lightmap.
            Device.SetRenderTargets(Textures.LightmapBindings);

            // Clear lightmap color, depth and stencil data.
            Device.Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil | ClearOptions.Target, _ambientColor, 1f, 0);

            // Set per frame shader data.
            ShadowRenderer.PreRender();

            // Generate lightmap. For each light, mask the shadowed areas determined by hulls and render light.
            int lightCount = Lights.Count;

            for (int i = 0; i < lightCount; i++)
            {
                Light light = Lights[i];

                // Continue only if light is enabled and not inside any hull.
                if (!light.Enabled || Hulls.Contains(light))
                {
                    continue;
                }

                // Update light's internal data structures.
                light.Update();

                // Continue only if light is within camera view.
                if (!light.Intersects(Camera))
                {
                    continue;
                }

                // Set scissor rectangle to clip any shadows outside of light's range.
                Camera.GetScissorRectangle(light, out BoundingRectangle scissor);
                Device.SetScissorRectangle(ref scissor);

                // Mask shadowed areas by reducing alpha.
                ShadowRenderer.Render(light);

                // Draw light and clear alpha (reset it to 1 [fully lit] for next light).
                LightRenderer.Render(light);

                // Clear light's dirty flag.
                light.Dirty = false;
            }

            // Switch render target back to default.
            Device.SetRenderTargets(Textures.GetOriginalRenderTargetBindings());

            // Blend original scene and lightmap and present to backbuffer.
            LightMapRenderer.Present();

            // Clear hulls dirty flag.
            Hulls.Dirty = false;
        }