예제 #1
0
        //-----------------------------------------------------------------------------
        // Map Drawing
        //-----------------------------------------------------------------------------

        private void DrawRoom(Graphics2D g, DungeonMapRoom room, Point2I position)
        {
            if (room == null)
            {
                return;
            }

            // Determine the sprite to draw for the room.
            Sprite sprite = null;

            if (room.IsDiscovered)
            {
                sprite = room.Sprite;
            }
            else if (dungeon.HasMap)
            {
                sprite = GameData.SPR_UI_MAP_UNDISCOVERED_ROOM;
            }

            // Determine extra sprite to draw for the room (treasure, boss, or player).
            Sprite extraSprite = null;

            if (playerRoomLocation == room.Location && playerFloorNumber == room.Floor.FloorNumber &&
                (cursorTimer >= 32 || isChangingFloors || room.Floor != viewFloor))
            {
                extraSprite = GameData.SPR_UI_MAP_PLAYER;
            }
            else if (dungeon.HasCompass)
            {
                if (room.IsBossRoom)
                {
                    extraSprite = GameData.SPR_UI_MAP_BOSS_ROOM;
                }
                else if (room.HasTreasure)
                {
                    extraSprite = GameData.SPR_UI_MAP_TREASURE_ROOM;
                }
            }

            // Draw the two sprites.
            if (sprite != null)
            {
                g.DrawSprite(sprite, GameData.VARIANT_LIGHT, position);
            }
            if (extraSprite != null)
            {
                g.DrawSprite(extraSprite, GameData.VARIANT_LIGHT, position);
            }
        }
예제 #2
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------

        public DungeonMapFloor(DungeonFloor dungeonFloor)
        {
            this.dungeonFloor = dungeonFloor;
            this.floorNumber  = dungeonFloor.FloorNumber;
            this.isDiscovered = dungeonFloor.IsDiscovered;
            this.size         = new Point2I(8, 8);


            // Create rooms.
            rooms       = new DungeonMapRoom[size.X, size.Y];
            isBossFloor = false;

            if (dungeonFloor.Level != null)
            {
                for (int x = 0; x < size.X; x++)
                {
                    for (int y = 0; y < size.Y; y++)
                    {
                        Point2I loc = new Point2I(x, y);
                        if (dungeonFloor.Level.ContainsRoom(loc))
                        {
                            Room room = dungeonFloor.Level.GetRoomAt(loc);
                            if (!room.IsHiddenFromMap)
                            {
                                rooms[x, y] = DungeonMapRoom.Create(room, this);
                                if (rooms[x, y] != null && rooms[x, y].IsBossRoom)
                                {
                                    isBossFloor = true;
                                }
                            }
                        }
                        else
                        {
                            rooms[x, y] = null;
                        }
                    }
                }
            }
        }
예제 #3
0
        //-----------------------------------------------------------------------------
        // Static Methods
        //-----------------------------------------------------------------------------

        public static DungeonMapRoom Create(Room room, DungeonMapFloor floor)
        {
            // Don't show empty rooms.
            if (IsRoomEmpty(room))
            {
                return(null);
            }

            // Create the map room object.
            DungeonMapRoom mapRoom = new DungeonMapRoom()
            {
                room         = room,
                hasTreasure  = room.HasUnopenedTreasure(),
                isDiscovered = room.IsDiscovered,
                isBossRoom   = room.IsBossRoom,
                location     = room.Location,
                sprite       = null,
                floor        = floor,
            };

            // Determine the sprite to draw for this room based on its connections.
            Sprite[] connectedSprites = new Sprite[16] {
                GameData.SPR_UI_MAP_ROOM_NONE,
                GameData.SPR_UI_MAP_ROOM_RIGHT,
                GameData.SPR_UI_MAP_ROOM_UP,
                GameData.SPR_UI_MAP_ROOM_UP_RIGHT,
                GameData.SPR_UI_MAP_ROOM_LEFT,
                GameData.SPR_UI_MAP_ROOM_LEFT_RIGHT,
                GameData.SPR_UI_MAP_ROOM_LEFT_UP,
                GameData.SPR_UI_MAP_ROOM_LEFT_UP_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN,
                GameData.SPR_UI_MAP_ROOM_DOWN_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN_UP,
                GameData.SPR_UI_MAP_ROOM_DOWN_UP_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT_UP,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT_UP_RIGHT,
            };

            // Check for room connections.
            int[] connected = new int[] { 0, 0, 0, 0 };
            for (int y = 0; y < room.Height; y++)
            {
                bool freeOnRight = true;
                bool freeOnLeft  = true;
                for (int i = 0; i < room.LayerCount; i++)
                {
                    TileDataInstance left = room.GetTile(0, y, i);
                    if (left != null && left.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(left.Type))
                    {
                        freeOnLeft = false;
                    }
                    TileDataInstance right = room.GetTile(room.Width - 1, y, i);
                    if (right != null && right.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(right.Type))
                    {
                        freeOnRight = false;
                    }
                    ;
                }
                if (freeOnRight)
                {
                    connected[Directions.Right] = 1;
                }
                if (freeOnLeft)
                {
                    connected[Directions.Left] = 1;
                }
            }
            for (int x = 0; x < room.Width; x++)
            {
                bool freeOnUp   = true;
                bool freeOnDown = true;
                for (int i = 0; i < room.LayerCount; i++)
                {
                    TileDataInstance up   = room.GetTile(x, 0, i);
                    TileDataInstance down = room.GetTile(x, room.Height - 1, i);
                    if (up != null && up.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(up.Type))
                    {
                        freeOnUp = false;
                    }
                    if (down != null && down.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(down.Type))
                    {
                        freeOnDown = false;
                    }
                }
                if (freeOnUp)
                {
                    connected[Directions.Up] = 1;
                }
                if (freeOnDown)
                {
                    connected[Directions.Down] = 1;
                }
            }

            int spiteIndex = (connected[0]) + (connected[1] << 1) + (connected[2] << 2) + (connected[3] << 3);

            mapRoom.sprite = connectedSprites[spiteIndex];

            return(mapRoom);
        }
예제 #4
0
        //-----------------------------------------------------------------------------
        // Static Methods
        //-----------------------------------------------------------------------------
        public static DungeonMapRoom Create(Room room, DungeonMapFloor floor)
        {
            // Don't show empty rooms.
            if (IsRoomEmpty(room))
                return null;

            // Create the map room object.
            DungeonMapRoom mapRoom = new DungeonMapRoom() {
                room			= room,
                hasTreasure		= room.HasUnopenedTreasure(),
                isDiscovered	= room.IsDiscovered,
                isBossRoom		= room.IsBossRoom,
                location		= room.Location,
                sprite			= null,
                floor			= floor,
            };

            // Determine the sprite to draw for this room based on its connections.
            Sprite[] connectedSprites = new Sprite[16] {
                GameData.SPR_UI_MAP_ROOM_NONE,
                GameData.SPR_UI_MAP_ROOM_RIGHT,
                GameData.SPR_UI_MAP_ROOM_UP,
                GameData.SPR_UI_MAP_ROOM_UP_RIGHT,
                GameData.SPR_UI_MAP_ROOM_LEFT,
                GameData.SPR_UI_MAP_ROOM_LEFT_RIGHT,
                GameData.SPR_UI_MAP_ROOM_LEFT_UP,
                GameData.SPR_UI_MAP_ROOM_LEFT_UP_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN,
                GameData.SPR_UI_MAP_ROOM_DOWN_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN_UP,
                GameData.SPR_UI_MAP_ROOM_DOWN_UP_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT_RIGHT,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT_UP,
                GameData.SPR_UI_MAP_ROOM_DOWN_LEFT_UP_RIGHT,
            };

            // Check for room connections.
            int[] connected = new int[] { 0, 0, 0, 0 };
            for (int y = 0; y < room.Height; y++) {
                bool freeOnRight = true;
                bool freeOnLeft = true;
                for (int i = 0; i < room.LayerCount; i++) {
                    TileDataInstance left = room.GetTile(0, y, i);
                    if (left != null && left.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(left.Type))
                        freeOnLeft = false;
                    TileDataInstance right = room.GetTile(room.Width - 1, y, i);
                    if (right != null && right.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(right.Type))
                        freeOnRight = false;;
                }
                if (freeOnRight)
                    connected[Directions.Right] = 1;
                if (freeOnLeft)
                    connected[Directions.Left] = 1;
            }
            for (int x = 0; x < room.Width; x++) {
                bool freeOnUp = true;
                bool freeOnDown = true;
                for (int i = 0; i < room.LayerCount; i++) {
                    TileDataInstance up = room.GetTile(x, 0, i);
                    TileDataInstance down = room.GetTile(x, room.Height - 1, i);
                    if (up != null && up.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(up.Type))
                        freeOnUp = false;
                    if (down != null && down.SolidType != TileSolidType.NotSolid && !typeof(TileDoor).IsAssignableFrom(down.Type))
                        freeOnDown = false;
                }
                if (freeOnUp)
                    connected[Directions.Up] = 1;
                if (freeOnDown)
                    connected[Directions.Down] = 1;
            }

            int spiteIndex = (connected[0]) + (connected[1] << 1) + (connected[2] << 2) + (connected[3] << 3);
            mapRoom.sprite = connectedSprites[spiteIndex];

            return mapRoom;
        }
예제 #5
0
        //-----------------------------------------------------------------------------
        // Map Drawing
        //-----------------------------------------------------------------------------
        private void DrawRoom(Graphics2D g, DungeonMapRoom room, Point2I position)
        {
            if (room == null)
                return;

            // Determine the sprite to draw for the room.
            Sprite sprite = null;
            if (room.IsDiscovered)
                sprite = room.Sprite;
            else if (dungeon.HasMap)
                sprite = GameData.SPR_UI_MAP_UNDISCOVERED_ROOM;

            // Determine extra sprite to draw for the room (treasure, boss, or player).
            Sprite extraSprite = null;
            if (playerRoomLocation == room.Location && playerFloorNumber == room.Floor.FloorNumber &&
                (cursorTimer >= 32 || isChangingFloors || room.Floor != viewFloor))
            {
                extraSprite = GameData.SPR_UI_MAP_PLAYER;
            }
            else if (dungeon.HasCompass) {
                if (room.IsBossRoom)
                    extraSprite = GameData.SPR_UI_MAP_BOSS_ROOM;
                else if (room.HasTreasure)
                    extraSprite = GameData.SPR_UI_MAP_TREASURE_ROOM;
            }

            // Draw the two sprites.
            if (sprite != null)
                g.DrawSprite(sprite, GameData.VARIANT_LIGHT, position);
            if (extraSprite != null)
                g.DrawSprite(extraSprite, GameData.VARIANT_LIGHT, position);
        }