コード例 #1
0
        public void CollectRooms(RoomCollection rooms, string strMySid)
        {
            var RoomCollection = ConnectionHelper.DB.GetCollection <RoomEntity>("RoomEntity");
            var UserCollection = ConnectionHelper.DB.GetCollection <UserEntity>("UserEntity");
            var FindRoomsQuery = Query <RoomEntity> .EQ(r => r.UserSid, strMySid);

            var FindedRooms = RoomCollection.Find(FindRoomsQuery);

            foreach (RoomEntity r in FindedRooms)
            {
                IList <string> ActiveMemberNickNames = new List <string>();

                foreach (string strUserSid in r.ActiveMemberSids)
                {
                    if (strMySid == strUserSid)
                    {
                        continue;
                    }
                    var FindUserQuery = Query <UserEntity> .EQ(u => u.Sid, strUserSid);

                    var FindedUser = UserCollection.FindOne(FindUserQuery);
                    if (null != FindedUser)
                    {
                        ActiveMemberNickNames.Add(FindedUser.NickName);
                    }
                }

                rooms.Add(new Room(r.Sid, ActiveMemberNickNames, r.UnReadMsgCount, r.LastMsgSummary, r.LastMsgDate, r.ThumbnailPath, rooms));
            }
        }
コード例 #2
0
        private void AddRoomCommandExecute(object o)
        {
            var rnd  = new Random();
            var room = new Room(rnd.Next(0, 100), rnd.Next(50, 200), (RoomType)rnd.Next(0, 4),
                                (RoomSubtype)rnd.Next(0, 3), rnd.Next(20, 80));

            _hotel.AddRoom(room);
            RoomCollection.Add(new RoomModel(room));
            RoomCollectionView.Refresh();
        }
コード例 #3
0
    public void Test()
    {
        Room r1 = new Room();

        r1.UserId = 1;
        r1.Name   = "Room One";
        Room r2 = new Room();

        r2.UserId = 2;
        r2.Name   = "Room Two";
        RoomCollection roomCollection = new RoomCollection();

        roomCollection.Add(r1);
        roomCollection.Add(r2);
        foreach (int roomId in roomCollection.Keys)
        {
            Console.WriteLine("Room number: {0} - Room name: {1}", roomId, roomCollection[roomId]);
        }
    }
コード例 #4
0
        public void Refresh()
        {
            RoomCollection.Clear();
            foreach (var room in _hotel.GetAllRoomsWithBookings())
            {
                RoomCollection.Add(new RoomModel(room));
            }

            SortRoomsSelectedType = SortRoomsTypes[0];
            ShownDateTime         = DateTime.Now.Date;
        }
コード例 #5
0
ファイル: RoomParser.cs プロジェクト: Weava/U_SatanicPanic
        public static void ClaimRooms(this Region region)
        {
            //Elevation cells are grouped into their own room to prevent complications
            while (region.GetCells().Where(x => x.type == CellType.Elevation).Any(x => !x.claimedByRoom))
            {
                var elevationGroups = region.GetCells().Where(x => x.type == CellType.Elevation)
                                      .GroupBy(g => new Vector2(g.position.x, g.position.y));

                foreach (var elevationGroup in elevationGroups)
                {
                    var room = new Room();
                    if (!ClaimRoom(elevationGroup.ToList(), ref room))
                    {
                        continue;
                    }
                    room.regionId = region.id;
                    RoomCollection.Add(room);
                }
            }

            //Until all cells are claimed by a room
            while (region.GetCells().Any(x => !x.claimedByRoom))
            {
                var cellsLeftToClaim = region.GetCells().Where(x => !x.claimedByRoom).ToList();
                var rootCell         = cellsLeftToClaim[Random.Range(0, cellsLeftToClaim.Count)];
                var claimSize        = region.greedyClaiming ? region.maximumRoomSize : Random.Range(1, region.maximumRoomSize + 1);

                var projection = ProjectRoom(rootCell, ref cellsLeftToClaim, Random.Range(1, region.maximumRoomSize + 1), region.claimChance, region.roomClaimingStrategy);
                if (projection.Any())
                {
                    var room = new Room();
                    if (!ClaimRoom(projection, ref room))
                    {
                        continue;
                    }
                    room.regionId = region.id;
                    RoomCollection.Add(room);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// !!!!!!!!!
        /// id is team's id
        /// name is team's. if not null, creat, else get a specified team
        /// MarsPeer is one peer;
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="peer"></param>
        /// <returns></returns>
        public virtual Team GetTeamById(string id, string name, MarsPeer peer) //creat new......
        {
            Team team = null;                                                  //

            lock (this.SyncRoot)
            {
                if (id == null || Rooms.TryGetValue(id, out team) == false)
                {
                    if (name != null)
                    {
                        team          = new Team();
                        team.teamId   = (MinTeamID++).ToString();//Guid.NewGuid().ToString();
                        team.teamName = name;
                        team.peers    = new List <MarsPeer>();
                        Rooms.Add(team.teamId, team);
                    }
                }
                if (team.peers.Contains(peer) == false)
                {
                    team.peers.Add(peer);
                }
            }
            return(team);
        }
コード例 #7
0
        protected override void ProcessResource(RoomCollection aRooms)
        {
            var files = GetXmlFiles(Directories.Rooms);

            if (files.Any())
            {
                OnCategoryProcessing(ResourceTypes.Rooms);
                var previous = SetCurrentDirectory(Directories.Rooms);

                foreach (var file in files)
                {
                    var document = LoadXml(file);

                    if (document != null)
                    {
                        var room = new Room()
                        {
                            Name                        = GetElement(document, "Name").Value,
                            ID                          = GetElementValue <int>(document, "ID"),
                            RoomCaption                 = GetElement(document, "RoomCaption").Value,
                            Width                       = GetElementValue <int>(document, "Width"),
                            Height                      = GetElementValue <int>(document, "Height"),
                            SnapX                       = GetElementValue <int>(document, "SnapX"),
                            SnapY                       = GetElementValue <int>(document, "SnapY"),
                            Speed                       = GetElementValue <int>(document, "Speed"),
                            CreationCode                = GetElement(document, "CreationCode").Value,
                            IsometricGrid               = GetElementValue <bool>(document, "IsometricGrid"),
                            Persistent                  = GetElementValue <bool>(document, "Persistent"),
                            ViewsEnabled                = GetElementValue <bool>(document, "ViewsEnabled"),
                            DrawBackgroundColor         = GetElementValue <bool>(document, "DrawBackgroundColor"),
                            BackgroundColor             = Drawing.ColorTranslator.FromHtml(GetElement(document, "BackgroundColor").Value),
                            RememberRoomSettings        = GetElementValue <bool>(document, "RememberRoomSettings"),
                            RoomEditorTab               = GetElementValue <RoomEditorTabs>(document, "RoomEditorTab"),
                            RoomEditorWidth             = GetElementValue <int>(document, "RoomEditorWidth"),
                            RoomEditorHeight            = GetElementValue <int>(document, "RoomEditorHeight"),
                            ShowGrid                    = GetElementValue <bool>(document, "ShowGrid"),
                            ShowObjects                 = GetElementValue <bool>(document, "ShowObjects"),
                            ShowTiles                   = GetElementValue <bool>(document, "ShowTiles"),
                            ShowBackgrounds             = GetElementValue <bool>(document, "ShowBackgrounds"),
                            ShowForegrounds             = GetElementValue <bool>(document, "ShowForegrounds"),
                            ShowViews                   = GetElementValue <bool>(document, "ShowViews"),
                            DeleteObjectsOutsideOfRoom  = GetElementValue <bool>(document, "DeleteObjectsOutsideOfRoom"),
                            DeleteTilesOutsideOfRoom    = GetElementValue <bool>(document, "DeleteTilesOutsideOfRoom"),
                            HorizontalScrollbarPosition = GetElementValue <int>(document, "HorizontalScrollbarPosition"),
                            VerticalScrollbarPosition   = GetElementValue <int>(document, "VerticalScrollbarPosition")
                        };

                        room.Backgrounds.AddRange(from element in document.Element("Backgrounds").Elements("Background")
                                                  select new Room.Background()
                        {
                            BackgroundIndex = GetElementValue <int>(element, "BackgroundIndex"),
                            X = GetElementValue <int>(element, "X"),
                            Y = GetElementValue <int>(element, "Y"),
                            HorizontalSpeed  = GetElementValue <int>(element, "HorizontalSpeed"),
                            VerticalSpeed    = GetElementValue <int>(element, "VerticalSpeed"),
                            Visible          = GetElementValue <bool>(element, "Visible"),
                            ForegroundImage  = GetElementValue <bool>(element, "ForegroundImage"),
                            TileHorizontally = GetElementValue <bool>(element, "TileHorizontally"),
                            TileVertically   = GetElementValue <bool>(element, "TileVertically"),
                            Stretch          = GetElementValue <bool>(element, "Stretch")
                        });

                        room.Views.AddRange(from element in document.Element("Views").Elements("View")
                                            select new Room.View()
                        {
                            Visible        = GetElementValue <bool>(element, "Visible"),
                            FollowedObject = GetElementValue <int>(element, "FollowedObject"), // ?
                            X                 = GetElementValue <int>(element, "X"),
                            Y                 = GetElementValue <int>(element, "Y"),
                            Width             = GetElementValue <int>(element, "Width"),
                            Height            = GetElementValue <int>(element, "Height"),
                            PortX             = GetElementValue <int>(element, "PortX"),
                            PortY             = GetElementValue <int>(element, "PortY"),
                            PortWidth         = GetElementValue <int>(element, "PortWidth"),
                            PortHeight        = GetElementValue <int>(element, "PortHeight"),
                            HorizontalBorder  = GetElementValue <int>(element, "HorizontalBorder"),
                            VerticalBorder    = GetElementValue <int>(element, "VerticalBorder"),
                            HorizontalSpacing = GetElementValue <int>(element, "HorizontalSpacing"),
                            VerticalSpacing   = GetElementValue <int>(element, "VerticalSpacing")
                        });

                        room.Instances.AddRange(from element in document.Element("Instances").Elements("Instance")
                                                select new Room.Instance()
                        {
                            ID           = GetElementValue <int>(element, "ID"),
                            ObjectIndex  = GetElementValue <int>(element, "ObjectIndex"),
                            X            = GetElementValue <int>(element, "X"),
                            Y            = GetElementValue <int>(element, "Y"),
                            Locked       = GetElementValue <bool>(element, "Locked"),
                            CreationCode = GetElement(element, "CreationCode").Value
                        });

                        room.Tiles.AddRange(from element in document.Element("Tiles").Elements("Tile")
                                            select new Room.Tile()
                        {
                            ID = GetElementValue <int>(element, "ID"),
                            BackgroundIndex = GetElementValue <int>(element, "BackgroundIndex"),
                            X      = GetElementValue <int>(element, "X"),
                            Y      = GetElementValue <int>(element, "Y"),
                            TileX  = GetElementValue <int>(element, "TileX"),
                            TileY  = GetElementValue <int>(element, "TileY"),
                            Width  = GetElementValue <int>(element, "Width"),
                            Height = GetElementValue <int>(element, "Height"),
                            Depth  = GetElementValue <int>(element, "Depth"),
                            Locked = GetElementValue <bool>(element, "Locked")
                        });

                        aRooms.Add(room);
                    }

                    OnAbortProcessingCallback();
                }

                if (aRooms.Any())
                {
                    aRooms.LastInstanceID = aRooms.Max(room => {
                        if (room.Instances.Any())
                        {
                            return(room.Instances.Max(instance => instance.ID));
                        }
                        else
                        {
                            return(99999);
                        }
                    }) + 1;

                    aRooms.LastTileID = aRooms.Max(room => {
                        if (room.Tiles.Any())
                        {
                            return(room.Tiles.Max(tile => tile.ID));
                        }
                        else
                        {
                            return(999999);
                        }
                    }) + 1;
                }

                OnCategoryProcessed(ResourceTypes.Rooms);
                SetCurrentDirectory(previous);
            }
        }
コード例 #8
0
ファイル: Rooms.cs プロジェクト: memsyi/GameSaveSystem
        static Rooms()
        {
            rooms.Add(new Room("intro", "Outside Cave Entrance", @"You stand at the entrance of a cave. Everyone says it's haunted, but you obviously don't believe them...wait, is that crying?",
                               new RoomAction("Enter the cave", gameState => gameState.ChangeRoom("inside-cave1")),
                               new RoomAction("Go home", gameState => gameState.ChangeRoom("early-home"))
                               ));

            rooms.Add(new Room("inside-cave1", "Inside Cave Entrance", @"You stand in a small opening, just inside the cave. It seems to be getting dark outside already, so maybe you should just head home.

There is a path to the north and a path to the east. The exit is behind you.",
                               new RoomAction("Go north", gameState => gameState.ChangeRoom("pit1")),
                               new RoomAction("Go east", gameState => gameState.ChangeRoom("hallway1")),
                               new RoomAction("Go home", gameState => gameState.ChangeRoom("early-home"))
                               ));

            rooms.Add(new Room("pit1", "Dark Room", @"You stand in a small room which is completely dark. The crying appears to have become quieter here, but you can still hear it. There seems to be a cold draft coming from somewhere in the room.

There is a path to the north and path to the south.",
                               new RoomAction("Go north", gameState => gameState.ChangeRoom("pit1-death")),
                               new RoomAction("Go back", gameState => gameState.ChangeRoom("inside-cave1")),
                               new RoomAction("Use Flashlight", gameState => gameState.ChangeRoom("pit1-lit"), gameState => gameState.StateValueExists("hallway1-visited") ? (bool)gameState.GetStateValue("hallway1-visited") : false)
                               ));

            rooms.Add(new Room("pit1-death", "Dark Room", @"As you take a step forward, you feel yourself being pushed. You realise where that draft was coming from: there was a large hole in room.

You look up only to see the outline of a small child as you fall into the darkness of the pit.",
                               new RoomAction("Start over", gameState => gameState.StartGame("inside-cave1"))
                               )
            {
                CanSave = false,
            });

            rooms.Add(new Room("pit1-lit", "Pit Room", @"There is a large pit blocking the way to the north exit. You use the flashlight to peer into the pit, but all you can see is a large red pit at the bottom.",
                               new RoomAction("Go back", gameState => gameState.ChangeRoom("pit1-death2"))
                               )
            {
                CanSave = false,
            });

            rooms.Add(new Room("pit1-death2", "Dark Room", @"You turn to leave and find yourself impeded by black figure about the size of a child. Startled you take a step back and find yourself falling. The last thing you hear is a child's giggle.",
                               new RoomAction("Start over", gameState => gameState.StartGame("inside-cave1"))
                               )
            {
                CanSave = false,
            });

            rooms.Add(new Room("hallway1", "Dark Hallway", @"You walk down the dark hallway, tripping over something. You feel around and find a flashlight.

You can continue down the hallway or head back the way you came.",
                               new RoomAction("Continue", gameState => gameState.ChangeRoom("bone-room")),
                               new RoomAction("Head back", gameState => gameState.ChangeRoom("inside-cave1")),
                               new RoomAction("Use Flashlight", gameState => gameState.ChangeRoom("hallway1-lit"))
                               ));

            rooms.Add(new Room("hallway1-lit", "Hallway", @"You look around with the flashlight you just found. You see nothing as you peer behind you, but as your gaze returns to the hallway ahead, you see what appears to be a lot of bones. Standing on top of them, you see the dark outline of a child.",
                               new RoomAction("Escape", gameState => gameState.ChangeRoom("hallway1-death"))
                               )
            {
                RoomActionsOnly = true
            });

            rooms.Add(new Room("hallway1-death", "Hallway", @"You turn to run, but it's too late. Whatever that thing was tackles you to the ground. The last thing you hear is the giggle of a small child.",
                               new RoomAction("Start over", gameState => gameState.StartGame("inside-cave1"))
                               )
            {
                CanSave = false,
            });

            rooms.Add(new Room("bone-room", "Dark Room", @"The crying seems to be getting quieter, but you're sure it's coming from this direction. You hear a small crunch as you walk into the room and then crying stops all together...replaced with the giggling of a small child. It's the last sound you hear as you feel a sharp pain in your back and fall to the floor.",
                               new RoomAction("Start over", gameState => gameState.StartGame("inside-cave1"))
                               )
            {
                CanSave = false,
            });

            rooms.Add(new Room("early-home", "Home", @"You decide the best choice is to just leave it alone and head home. You may never know what adventure you missed out on, but maybe that's for the best.",
                               new RoomAction("Start over", gameState => gameState.ChangeRoom("intro"))
                               ));
        }
コード例 #9
0
 public void AddRoom(RoomModel room)
 {
     RoomCollection.Add(room);
 }