示例#1
0
        public void calculate(Region region)
        {
            width = region.getWidth();
            height = region.getHeight();
            values = new int[width,height];
            calc = new double[width,height];
            lights = new List<Light>();
            lightingModel = region.getLightingModel();

            //Blank out the entire region with base light
            for(int x=0; x < width; x++)
            {
                for(int y=0; y < height; y++)
                {
                    if(TerrainManager.hasParameter(region.getTerrain(x, y), TerrainParameter.FIRE))
                    {
                        calc[x,y] = ((MAX_LIGHT / 2) * RandomNumber.RandomDouble()) + (MAX_LIGHT / 2);
                        lights.Add(new Light(x,y,calc[x,y]));
                    }
                    else
                    {
                        calc[x,y] = baseLight();
                    }
                }
            }

            //Add lights for appropriate monsters
            calculateMonsterLights();

            //Add lights for appropriate building features
            calculateBuildingFeatureLight();

            //Add lights for items
            calculateItemLights();

            //Propogate light from point sources
            foreach(Light tempLight in lights)
            {
                spreadLight(tempLight.x, tempLight.y, tempLight.intensity, baseLight());
            }

            //Cover buildings if roofs prevent lighting
            calculateBuildingCoverLight();

            //Converate raw values to graded values
            calcToValue();
        }