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; } 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 = 24; var sparkSpawnPosition = mousePos; for (var i = 0; i < sparkSpawnCount; i++) { Sparks.Add(new Spark(Sparks, sparkSpawnPosition, 3)); } } Sparks.Update(); SparkLights.Update(); }
public override void Update(GameTime gameTime) { if (Game.IsActive) { 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.0125f; 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(); }