Exemple #1
0
        public override void Update(GameTime gameTime)
        {
            Sparks.CapacityLimit = 2048;
            Sparks.RemoveParticlesWhenCapacityReached = true;

            if (Game.IsActive) {
                if (KeyWasPressed(Keys.O))
                    ShowOutlines = !ShowOutlines;
                if (KeyWasPressed(Keys.L))
                    ShowLightmap = !ShowLightmap;
                if (KeyWasPressed(Keys.A))
                    ShowAOShadow = !ShowAOShadow;
                if (KeyWasPressed(Keys.B))
                    ShowBrickSpecular = !ShowBrickSpecular;

                var ms = Mouse.GetState();
                Game.IsMouseVisible = true;

                LightmapScale = BaseLightmapScale + (ms.ScrollWheelValue / 200f);
                if (LightmapScale < 1f)
                    LightmapScale = 1f;

                var mousePos = new Vector2(ms.X, ms.Y);

                if (ms.LeftButton == ButtonState.Pressed) {
                    if (Dragging == null) {
                        BackgroundEnvironment.Obstructions.Add(Dragging = new LightObstructionLine(mousePos, mousePos));
                    } else {
                        Dragging.B = mousePos;
                    }
                } else {
                    if (Dragging != null) {
                        Dragging.B = mousePos;
                        Dragging = null;
                    }
                }

                const int sparkSpawnCount = 32;
                var sparkSpawnPosition = mousePos;

                for (var i = 0; i < sparkSpawnCount; i++)
                    Sparks.Add(new Spark(Sparks, sparkSpawnPosition));
            }

            Sparks.Update();
        }
Exemple #2
0
        public override void Update(GameTime gameTime)
        {
            if (Game.IsActive) {
                const float step = 0.1f;

                if (KeyWasPressed(Keys.Q))
                    MiddleGray -= step;
                else if (KeyWasPressed(Keys.W))
                    MiddleGray += step;

                if (KeyWasPressed(Keys.A))
                    LuminanceScaler -= step;
                else if (KeyWasPressed(Keys.S))
                    LuminanceScaler += step;

                if (MiddleGray < 0)
                    MiddleGray = 0;
                if (LuminanceScaler < 0)
                    LuminanceScaler = 0;

                if (KeyWasPressed(Keys.O))
                    ShowOutlines = !ShowOutlines;

                var ms = Mouse.GetState();
                Game.IsMouseVisible = true;

                var mousePos = new Vector2(ms.X, ms.Y);

                var angle = gameTime.TotalGameTime.TotalSeconds * 0.125f;
                const float radius = 225f;

                Lights[0].Position = mousePos;

                float stepOffset = (float)((Math.PI * 2) / (Environment.LightSources.Count - 1));
                float offset = 0;
                for (int i = 1; i < Environment.LightSources.Count; i++, offset += stepOffset) {
                    float localRadius = (float)(radius + (radius * Math.Sin(offset * 4f) * 0.5f));
                    Lights[i].Position = mousePos + new Vector2((float)Math.Cos(angle + offset) * localRadius, (float)Math.Sin(angle + offset) * localRadius);
                }

                if (ms.LeftButton == ButtonState.Pressed) {
                    if (Dragging == null) {
                        Environment.Obstructions.Add(Dragging = new LightObstructionLine(mousePos, mousePos));
                    } else {
                        Dragging.B = mousePos;
                    }
                } else {
                    if (Dragging != null) {
                        Dragging.B = mousePos;
                        Dragging = null;
                    }
                }
            }

            Environment.UpdateReceivers();

            ComputeAverageLuminance();
        }