Ejemplo n.º 1
0
        public void UpdateVisibilityMap(TerrainMap terrain, LightMap lightmap, Point origin)
        {
            // Reset the visible flag of the previous visible points
            if (visiblePoints != null)
            {
                foreach (var visiblePoint in visiblePoints)
                {
                    this[visiblePoint.Location.Coordinate].IsVisible = false;
                }
            }

            // Calculate new visible Fov
            visiblePoints = fovAlgorithm.CalculateFov(terrain, origin, fovProfile);

            // Evaluate each visible point against the lightmap
            // Only lit tiles are visible
            foreach (var visiblePoint in visiblePoints)
            {
                if (!fovProfile.IsVisible(lightmap[visiblePoint.Location.Coordinate].Colour))
                {
                    continue;
                }

                this[visiblePoint.Location.Coordinate].IsVisible = true;
                this[visiblePoint.Location.Coordinate].WasSeen   = true;
            }
        }
        //public FovShapeType FovShape
        //{
        //    get { return fovProfile.FovShape; }
        //    set { fovProfile.FovShape = value; }
        //}

        #endregion

        #region IFovAlgorithm Members

        public FovResultset CalculateFov(TerrainMap terrain, Point origin, IFovProfile fovProfile)
        {
            visibleLocations = new FovResultset();
            //     fovProfile.FovShape = shapeType;

            if (terrain != null)
            {
                visibleLocations.Add(new FovObject()
                {
                    Location = { Coordinate = origin }, DistanceFromOrigin = 0
                });
                if (fovProfile.FovRadius > 0)
                {
                    ScanNorthwestToNorth(terrain, origin, fovProfile);
                    ScanNorthToNortheast(terrain, origin, fovProfile);
                    ScanNortheastToEast(terrain, origin, fovProfile);
                    ScanEastToSoutheast(terrain, origin, fovProfile);
                    ScanSoutheastToSouth(terrain, origin, fovProfile);
                    ScanSouthToSouthwest(terrain, origin, fovProfile);
                    ScanSouthwestToWest(terrain, origin, fovProfile);
                    ScanWestToNorthwest(terrain, origin, fovProfile);
                }
            }

            return(visibleLocations);
        }