private void SpreadLight(int x, int y) { Map map = MapManager.CurrentMap(); if (map == null) { return; } float angleDiff = 2 * (float)Math.PI / lightRays; float singleRayIntensity = totalLightIntensity / lightRays; for (int i = 0; i < lightRays; ++i) { float xSpeed = lightSpeed * (float)Math.Cos(i * angleDiff); float ySpeed = lightSpeed * (float)Math.Sin(i * angleDiff); Ray ray = new Ray(x + .5f, y + .5f, xSpeed, ySpeed, singleRayIntensity); while (ray.IsWithinRadius()) { ray.Advance(); GameObject go = ray.Collides(gameObject, map); if (go != null) { ray.Illuminate(go); break; } } } }