コード例 #1
0
        public void AddRoom(MapRoom room)
        {
            room.RoomID           = GetNextFreeRoomID();
            RoomDict[room.RoomID] = room;

            for (int x = room.Origin.X; x < room.End.X; x++)
            {
                for (int y = room.Origin.Y; y < room.End.Y; y++)
                {
                    HitGrid[x + GridSize / 2, y + GridSize / 2] = room.RoomID;
                }
            }
        }
コード例 #2
0
        public static MapGrid StartingMap()
        {
            MapGrid grid = new MapGrid();

            MapRoom[] newRooms = new MapRoom[]
            {
                new MapRoom(new Point2(-4, -2), new Point2(3, 4)),
                new MapRoom(new Point2(0, 0), new Point2(2, 2)),
                new MapRoom(new Point2(-1, 0), new Point2(1, 1)),
                new MapRoom(new Point2(1, -3), new Point2(1, 3)),
                new MapRoom(new Point2(2, -4), new Point2(3, 3))
            };
            foreach (MapRoom room in newRooms)
            {
                grid.AddRoom(room);
            }
            return(grid);
        }
コード例 #3
0
        public void RemoveRoom(MapRoom room)
        {
            RoomDict.Remove(room.RoomID);

            for (int x = room.Origin.X; x < room.End.X; x++)
            {
                for (int y = room.Origin.Y; y < room.End.Y; y++)
                {
                    int gx = x + GridSize / 2;
                    int gy = y + GridSize / 2;
                    if (HitGrid[gx, gy] == room.RoomID)
                    {
                        // Dont clear it if it has someone elses roomID, in case rooms are added and removed out of order.
                        HitGrid[gx, gy] = 0;
                    }
                }
            }
        }