コード例 #1
0
        public void ResetFOV(bool keepOld = false)
        {
            if (!keepOld)
            {
                for (int i = SeenTiles.Count - 1; i > 0; i--)
                {
                    var spot = SeenTiles[i];

                    TileBase tile = CurrentMap.GetTileAt <TileBase>(spot.X, spot.Y);
                    tile.Darken(true);

                    SeenTiles.Remove(spot);
                }
            }
            lastFov = null;

            if (GameLoop.World.players.ContainsKey(GameLoop.NetworkingManager.myUID))
            {
                GameLoop.UIManager.RefreshMap(GameLoop.World.players[GameLoop.NetworkingManager.myUID].Position);
            }
            else
            {
                GameLoop.UIManager.RefreshMap(new Point(0, 0));
            }


            // CalculateFov(new Point (0, 0));
        }
コード例 #2
0
ファイル: World.cs プロジェクト: CallMeCamus/Into-the-dungeon
        // Create a new map using the Map class
        // and a map generator. Uses several
        // parameters to determine geometry
        private void CreateMap()
        {
            _mapTiles  = new TileBase[_mapWidth * _mapHeight];
            CurrentMap = new Map(_mapWidth, _mapHeight);
            MapGenerator mapGen = new MapGenerator();

            CurrentMap = mapGen.GenerateMap(_mapWidth, _mapHeight, _maxRooms, _minRoomSize, _maxRoomSize);

            var MapView = new GoRogue.MapViews.LambdaMapView <bool>(_mapWidth, _mapHeight, pos => CurrentMap.Tiles[pos.ToIndex(_mapWidth)].IsTransparent);

            FOVMap = new GoRogue.FOV(MapView);
        }
コード例 #3
0
        protected LivingCharacter(TileMap map, Coord position, Color foreground, Color background, int glyph)
            : base(foreground, background, glyph, position, 1, isWalkable: false, isTransparent: true)
        {
            Title       = "Unknown";
            Description = "Not much is known about this object.";

            FOVSight   = new GoRogue.FOV(map.TransparencyView);
            FOVLighted = new GoRogue.FOV(map.TransparencyView);

            map.AddEntity(this);

            AddGoRogueComponent(new GameFrameTileVisibilityRefresher());
        }
コード例 #4
0
        public void CalculateFov(Point dir)
        {
            // Use a GoRogue class that creates a map view so that the IsTransparent function is called whenever FOV asks for the value of a position
            var fovMap = new GoRogue.MapViews.LambdaMapView <bool>(51, 51, CurrentMap.IsTransparent);

            lastFov = new FOV(fovMap);

            if (GameLoop.World.players.ContainsKey(GameLoop.NetworkingManager.myUID))
            {
                Point start = GameLoop.World.players[GameLoop.NetworkingManager.myUID].Position + dir;

                Point playerRel = GameLoop.World.players[GameLoop.NetworkingManager.myUID].CalculatedPosition;
                playerRel += new Point(6, 6);


                Point  mouseLoc = GameLoop.MouseLoc;
                double degrees  = Math.Atan2((mouseLoc.Y - playerRel.Y), (mouseLoc.X - playerRel.X)) * (180.0 / Math.PI);
                degrees = (degrees > 0.0 ? degrees : (360.0 + degrees));
                lastFov.Calculate(start, 20, Radius.CIRCLE, degrees, 114);

                foreach (var spot in lastFov.NewlySeen)
                {
                    TileBase tile = CurrentMap.GetTileAt <TileBase>(spot);
                    tile.IsVisible = true;

                    if (CurrentMap.GetEntitiesAt <Entity>(spot).Count != 0)
                    {
                        for (int j = 0; j < CurrentMap.GetEntitiesAt <Entity>(spot).Count; j++)
                        {
                            CurrentMap.GetEntitiesAt <Entity>(spot)[j].IsVisible = true;
                        }
                    }

                    if (tile is TileDoor door)
                    {
                        door.UpdateGlyph();
                    }

                    if (!SeenTiles.Contains(spot))
                    {
                        SeenTiles.Add(new Point(spot.X, spot.Y));
                    }
                }

                foreach (KeyValuePair <long, Player> player in players)
                {
                    if (!lastFov.BooleanFOV[player.Value.Position.X, player.Value.Position.Y] && player.Key != GameLoop.NetworkingManager.myUID)
                    {
                        player.Value.IsVisible = false;
                    }
                    else if (lastFov.BooleanFOV[player.Value.Position.X, player.Value.Position.Y] || player.Key == GameLoop.NetworkingManager.myUID)
                    {
                        player.Value.IsVisible = true;


                        if (player.Key != GameLoop.NetworkingManager.myUID)
                        {
                            Point myPos    = players[GameLoop.NetworkingManager.myUID].Position;
                            Point theirPos = player.Value.Position;
                            int   distance = (int)Distance.CHEBYSHEV.Calculate(myPos.X, myPos.Y, theirPos.X, theirPos.Y);

                            player.Value.UpdateStealth((distance / 2) - 5);
                        }
                    }
                }

                //foreach (Entity entity in CurrentMap.Entities.Items) {
                //    if (!(entity is Player)) {
                //        if (lastFov.BooleanFOV[entity.Position.X, entity.Position.Y]) {
                //            entity.IsVisible = true;
                //        }

                //        if (!lastFov.BooleanFOV[entity.Position.X, entity.Position.Y]) {
                //            entity.IsVisible = false;
                //        }
                //    }
                //}


                for (int i = SeenTiles.Count - 1; i > 0; i--)
                {
                    var spot = SeenTiles[i];

                    if (!lastFov.CurrentFOV.Contains(new GoRogue.Coord(spot.X, spot.Y)))
                    {
                        TileBase tile = CurrentMap.GetTileAt <TileBase>(spot.X, spot.Y);
                        tile.Darken(true);
                        SeenTiles.Remove(spot);
                    }
                    else
                    {
                        TileBase tile = CurrentMap.GetTileAt <TileBase>(spot.X, spot.Y);
                        tile.Darken(false);

                        GameLoop.UIManager.MapConsole.ClearDecorators(spot.X, spot.Y, 1);
                    }
                }


                GameLoop.UIManager.MapConsole.IsDirty = true;
            }
        }