public Client(string name, decimal wallet, RoomKind room) : base(name, wallet) { this.Id = 0; this.EducationLevel = 0; this.RoomToRent = room; }
public RoomChoiceEntity(RoomKind kind, int maxAvailable, int count = 0) { _pcs = new PropertyChangeSupport(this); _bedKind = kind.ToBedKind(); _roomKind = kind; _maxAvailable = maxAvailable; _count = count; }
public static async Task <RoomKind> Update(RoomKind roomKindInDatabase, RoomKind roomKind) { await Database.WriteAsync(realm => { roomKindInDatabase.Name = roomKind.Name; roomKindInDatabase.NumberOfBeds = roomKind.NumberOfBeds; roomKindInDatabase.AmountOfPeople = roomKind.AmountOfPeople; }); return(roomKindInDatabase); }
public ChatRoom GetRoom(uint project, RoomKind kind) { ChatRoom room = null; if (RoomMap.TryGetValue(GetRoomID(project, kind), out room)) { return(room); } return(null); }
public ActionResult Create(RoomKind instance) { if (ModelState.IsValid) { db.RoomKinds.Add(instance); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } FillNavigationProperties(instance); return(View(instance)); }
void RefreshCommand(uint project, RoomKind kind) { uint id = GetRoomID(project, kind); ChatRoom room = null; if (RoomMap.SafeTryGetValue(id, out room)) { RefreshCommand(room); } }
public bool RequestRentRoom(RoomKind price) { bool canPay = false; if (this.RequestMoney(this.CanPayForRoom())) { canPay = true; return canPay; } else { return canPay; } }
public ActionResult DeletePost(int id) { try { RoomKind instance = db.RoomKinds.Find(id); db.RoomKinds.Remove(instance); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch (Exception) { return(RedirectToAction(nameof(DeleteError))); } }
public void LeaveRoom(uint project, RoomKind kind) { // deactivates room, let timer remove object is good once we know user no longer wants it uint id = GetRoomID(project, kind); ChatRoom room = null; if (!RoomMap.SafeTryGetValue(id, out room)) { return; } LeaveRoom(room); }
public void JoinCommand(uint project, RoomKind kind) { uint id = GetRoomID(project, kind); // create if doesnt exist ChatRoom room = null; if (!RoomMap.SafeTryGetValue(id, out room)) { room = new ChatRoom(kind, project); } room.Active = true; room.AddMember(Core.UserID); RoomMap.SafeAdd(id, room); RefreshCommand(room); SendStatus(room); ConnectRoom(room); }
public ChatRoom(RoomKind kind, ulong id, string title) { Debug.Assert(!ChatService.IsCommandRoom(kind)); Kind = kind; RoomID = id; Title = title; Invites = new Dictionary <ulong, Tuple <ChatInvite, List <ushort> > >(); // public rooms are private rooms with static room ids if (Kind == RoomKind.Public) { PublishRoom = true; Kind = RoomKind.Private; } if (Kind == RoomKind.Secret) { Verified = new Dictionary <ulong, bool>(); } }
public static BedKind ToBedKind(this RoomKind kind) { BedKind bedKind = BedKind.Simple; switch (kind) { case RoomKind.Simple: bedKind = BedKind.Simple; break; case RoomKind.Double: bedKind = BedKind.Double; break; case RoomKind.DoubleWithBaby: bedKind = BedKind.DoubleWithBaby; break; default: bedKind = BedKind.Simple; break; } return(bedKind); }
internal static async void SetIsActive(RoomKind roomKind, bool isActive) { await Database.WriteAsync(realm => roomKind.IsActive = isActive); }
public static bool IsCommandRoom(RoomKind kind) { return(kind == RoomKind.Command_High || kind == RoomKind.Command_Low || kind == RoomKind.Live_High || kind == RoomKind.Live_Low); }
private void FillNavigationProperties(RoomKind instance = null) { }
public uint GetRoomID(uint project, RoomKind kind) { return(project + (uint)kind); }
public void Update(OptionChoiceEntity optChoiceEntity) { Predicate <Room> missChoosenOpt = room => room.Options.FindIndex(opt => opt.Id == optChoiceEntity.OptionChoice.Option.Id) == -1; if (optChoiceEntity.Taken) { for (int i = _availableRooms.Count - 1; i >= 0; i--) { if (missChoosenOpt(_availableRooms[i])) { _filteredRooms.Add(_availableRooms[i]); _availableRoomCounts[_availableRooms[i].Kind]--; _availableRooms.RemoveAt(i); } } for (int i = _availableRoomChoiceEntities.Count - 1; i >= 0; i--) { RoomKind roomKind = _availableRoomChoiceEntities[i].RoomKind; if (_availableRoomCounts[roomKind] == 0) { _availableRoomChoiceEntities.RemoveAt(i); } else { _availableRoomChoiceEntities[i].MaxAvailable = _availableRoomCounts[roomKind]; } } } else { HashSet <RoomKind> newlyAvailableRoomKinds = new HashSet <RoomKind>(); HashSet <RoomKind> extraRoomAvailableKinds = new HashSet <RoomKind>(); for (int i = _filteredRooms.Count - 1; i >= 0; i--) { if (missChoosenOpt(_filteredRooms[i])) { _availableRooms.Add(_filteredRooms[i]); _availableRoomCounts[_filteredRooms[i].Kind]++; if (_availableRoomCounts[_filteredRooms[i].Kind] == 1) { newlyAvailableRoomKinds.Add(_filteredRooms[i].Kind); } else { extraRoomAvailableKinds.Add(_filteredRooms[i].Kind); } _filteredRooms.RemoveAt(i); } } foreach (RoomKind kind in newlyAvailableRoomKinds) { RoomChoiceEntity roomChoiceEntity = new Entities.RoomChoiceEntity(kind, _availableRoomCounts[kind], 0); _availableRoomChoiceEntities.Add(roomChoiceEntity); } foreach (RoomKind kind in extraRoomAvailableKinds) { foreach (RoomChoiceEntity roomChoiceEntity in _availableRoomChoiceEntities) { if (roomChoiceEntity.RoomKind.Equals(kind)) { roomChoiceEntity.MaxAvailable = _availableRoomCounts[kind]; break; } } } } }
/// <summary> /// Creates a new room by the given paramters. /// </summary> /// <param name="roomIndex">The room's index which is used to load the room.</param> /// <param name="position">The room's grid position in the level.</param> /// <param name="kind">The kind of the door.</param> public Room(byte roomIndex, Vector2 gridPosition, RoomKind kind) { // Store the parameters. Position = gridPosition * Globals.WindowDimensions; Kind = kind; // Initialize the wall hitboxes. Walls[0] = new Rectangle((Position + new Vector2(0.5f, 0f) * Tile.Size * Globals.Scale).ToPoint(), (new Vector2(Dimensions.X, 1) * Tile.Size * Globals.Scale).ToPoint()); Walls[1] = new Rectangle((Position + new Vector2(0.5f + (Dimensions.X - 1), 0f) * Tile.Size * Globals.Scale).ToPoint(), (new Vector2(1, Dimensions.Y) * Tile.Size * Globals.Scale).ToPoint()); Walls[2] = new Rectangle((Position + new Vector2(0.5f, Dimensions.Y - 1) * Tile.Size * Globals.Scale).ToPoint(), (new Vector2(Dimensions.X, 1) * Tile.Size * Globals.Scale).ToPoint()); Walls[3] = new Rectangle((Position + new Vector2(0.5f, 0f) * Tile.Size * Globals.Scale).ToPoint(), (new Vector2(1, Dimensions.Y) * Tile.Size * Globals.Scale).ToPoint()); // Initialize _topLeftCorner. _topLeftCorner = Position + new Vector2(1, 0.5f) * Tile.Size * Globals.Scale; // Initialize the room texture. if (_roomTexture == null) { // Create the texture. Vector2 textureSize = new Vector2(15, 9) * Tile.TextureSize; _roomTexture = new Texture2D(Globals.Graphics.GraphicsDevice, (int)textureSize.X, (int)textureSize.Y); // Declare the colour data arrays. Color[] ground, wallT, wallR, wallB, wallL, cornerTL, cornerTR, cornerBR, cornerBL; int pixelCount = (int)(Tile.TextureSize.X * Tile.TextureSize.Y); Rectangle sourceRect = new Rectangle(Vector2.Zero.ToPoint(), Tile.TextureSize.ToPoint()); ground = new Color[pixelCount]; wallT = new Color[pixelCount]; wallR = new Color[pixelCount]; wallB = new Color[pixelCount]; wallL = new Color[pixelCount]; cornerTL = new Color[pixelCount]; cornerTR = new Color[pixelCount]; cornerBR = new Color[pixelCount]; cornerBL = new Color[pixelCount]; // Get the colour data of the textures. Globals.Content.Load <Texture2D>("Sprites/Environment/Boden").GetData(0, sourceRect, ground, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/WandT").GetData(0, sourceRect, wallT, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/WandR").GetData(0, sourceRect, wallR, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/WandB").GetData(0, sourceRect, wallB, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/WandL").GetData(0, sourceRect, wallL, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/EckeTL").GetData(0, sourceRect, cornerTL, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/EckeTR").GetData(0, sourceRect, cornerTR, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/EckeBR").GetData(0, sourceRect, cornerBR, 0, pixelCount); Globals.Content.Load <Texture2D>("Sprites/Environment/EckeBL").GetData(0, sourceRect, cornerBL, 0, pixelCount); // Create the texture. Vector2 topLeftTextureCorner = new Vector2(0f) * Tile.TextureSize; Rectangle destinationRect = new Rectangle(topLeftTextureCorner.ToPoint(), Tile.TextureSize.ToPoint()); // The corners. _roomTexture.SetData(0, destinationRect, cornerTL, 0, pixelCount); destinationRect.Location = (topLeftTextureCorner + new Vector2(Dimensions.X - 1, 0) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, cornerTR, 0, pixelCount); destinationRect.Location = (topLeftTextureCorner + (Dimensions - Vector2.One) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, cornerBR, 0, pixelCount); destinationRect.Location = (topLeftTextureCorner + new Vector2(0, Dimensions.Y - 1) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, cornerBL, 0, pixelCount); // The walls. // Top and bottom. for (byte x = 1; x < Dimensions.X - 1; x++) { // Top. destinationRect.Location = (topLeftTextureCorner + new Vector2(x, 0) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, wallT, 0, pixelCount); // Bottom. destinationRect.Location = (topLeftTextureCorner + new Vector2(x, Dimensions.Y - 1) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, wallB, 0, pixelCount); } // Left and right. for (byte y = 1; y < Dimensions.Y - 1; y++) { // Left. destinationRect.Location = (topLeftTextureCorner + new Vector2(0, y) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, wallL, 0, pixelCount); // Right. destinationRect.Location = (topLeftTextureCorner + new Vector2(Dimensions.X - 1, y) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, wallR, 0, pixelCount); } // The ground. for (byte x = 1; x < Dimensions.X - 1; x++) { for (byte y = 1; y < Dimensions.Y - 1; y++) { destinationRect.Location = (topLeftTextureCorner + new Vector2(x, y) * Tile.TextureSize).ToPoint(); _roomTexture.SetData(0, destinationRect, ground, 0, pixelCount); } } } // Set the room sprite. _roomSprite = new Sprite(texture: _roomTexture, position: Position + new Vector2(0.5f, 0) * Tile.Size, origin: Vector2.Zero, scale: Tile.Size / Tile.TextureSize, layerDepth: 1f); // Add the room sprite. _gameObjects.Add(_roomSprite); // Add the room's content. switch (Kind) { case RoomKind.Start: if (Level.LevelIndex == 0) { // Add controls instructions in the centre of the room. Texture2D controlsInstructions = Globals.Content.Load <Texture2D>("Sprites/Misc/ControlsInstructions"); _gameObjects.Add(new Sprite(texture: controlsInstructions, position: Position + (Dimensions / 2 + new Vector2(0.5f, 0)) * Tile.Size, scale: new Vector2(5) * (Tile.Size / controlsInstructions.Bounds.Size.ToVector2()) * Globals.Scale, layerDepth: 0.99999f)); } break; case RoomKind.Normal: // Load the content from a file by using the roomIndex. _gameObjects.AddRange(RoomfileToList(RoomKind.Normal, roomIndex)); break; case RoomKind.Hidden: // Load the content from a file by using the roomIndex. _gameObjects.AddRange(RoomfileToList(RoomKind.Hidden, roomIndex)); break; case RoomKind.Boss: // Load the content from a file by using the roomIndex. _gameObjects.AddRange(RoomfileToList(RoomKind.Boss, roomIndex)); break; } }
public static Task<RoomKind> Update(RoomKind roomKind) { var roomKindInDatabase = GetAndCheckValid(roomKind.Id); return RoomKindDataAccess.Update(roomKindInDatabase, roomKind); }
public MazeRoomSetup(Vector2 gridPos, RoomKind kind) { GridPos = gridPos; Kind = kind; }
/// <summary> /// Converts the .room file of the given <see cref="RoomKind"/> and number to a List of <see cref="GameObject"/>s. /// </summary> /// <param name="roomKind">The given room kind.</param> /// <param name="roomIndex">The given room index</param> /// <returns>A List of all GameObjects, that are specified in the .room file.</returns> private List <GameObject> RoomfileToList(RoomKind roomKind, byte roomIndex) { // The list of GameObjects. List <GameObject> gameObjects = new List <GameObject>(); // Get the lines of the file. string[] lines = File.ReadAllLines($"..\\..\\..\\..\\Content\\Rooms\\{roomKind}\\{roomKind.ToString().ToLower()}_{roomIndex}.room"); // Go through all lines. for (byte y = 0; y < 9; y++) { // Split the line in substrings at every space (' '). string[] splittedLine = lines[y].Split(' '); // Get and add all GameObjects of this line. byte index, metadata; GameObject loadedGameObject; for (byte x = 0; x < 15; x++) { // Reset the loaded game object. loadedGameObject = null; // Get the index and metadata. // If the metadata is defined. if (splittedLine[x].Contains(":")) { // Split the string again. string[] values = splittedLine[x].Split(':'); // Get the index and metadata. index = Byte.Parse(values[0]); metadata = Byte.Parse(values[1]); } // Else the metadata isn't defined. else { // Get the index and set the metadata to 0. index = Byte.Parse(splittedLine[x]); metadata = 0; } // Get the corresponding GameObject. switch (index) { // Nothing. case 0: // Add nothing. break; // Enemy. case 1: switch (metadata) { // Exploder. case 0: loadedGameObject = new Exploder(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Floater. case 1: loadedGameObject = new Floater(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Fly. case 2: loadedGameObject = new Fly(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Flyboss. case 3: loadedGameObject = new Flyboss(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Flytrap. case 4: loadedGameObject = new Flytrap(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Screamer. case 5: loadedGameObject = new Screamer(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; } break; // Environment. case 2: switch (metadata) { // Campfire. case 0: loadedGameObject = new Campfire(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Chest. case 1: loadedGameObject = new Chest(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Hole. case 2: loadedGameObject = new Hole(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Poop. case 3: loadedGameObject = new Poop(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Pot. case 4: loadedGameObject = new Pot(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Rock. case 5: loadedGameObject = new Rock(_topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; } break; // Itemstone. case 3: switch (metadata) { // Bomb. case 0: loadedGameObject = new Itemstone(new PickupBomb(), _topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Coin. case 1: loadedGameObject = new Itemstone(new PickupCoin(), _topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Heart. case 2: loadedGameObject = new Itemstone(new PickupHeart(), _topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Key. case 3: loadedGameObject = new Itemstone(new PickupKey(), _topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Poopsicle. case 4: loadedGameObject = new Itemstone(new Poopsicle(), _topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Shroom. case 5: loadedGameObject = new Itemstone(new Shroom(), _topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; // Syringe. case 6: loadedGameObject = new Itemstone(new Syringe(), _topLeftCorner + new Vector2(x, y) * Tile.Size * Globals.Scale); break; } break; } // Add the GameObject to gameObjects. if (loadedGameObject != null) { gameObjects.Add(loadedGameObject); } } } // Return the GameObject List. return(gameObjects); }
public Room(RoomKind kind) : this() { this.Kind = kind; this.NumberOfBeds = (int)(double)kind / (int)RoomKind.Single; }
public static Task<RoomKind> Add(RoomKind roomKind) => RoomKindDataAccess.Add(roomKind);
void ReceiveInvite(ChatInvite invite, RudpSession session) { // if in global im, only allow if on buddies list if (Core.User.Settings.GlobalIM) { if (!Core.Buddies.BuddyList.SafeContainsKey(session.UserID)) { return; } } if (Core.Buddies.IgnoreList.SafeContainsKey(session.UserID)) { return; } bool showInvite = false; ChatRoom room; if (!RoomMap.TryGetValue(invite.RoomID, out room)) { RoomKind kind = invite.SignedInvite != null ? RoomKind.Secret : RoomKind.Private; room = new ChatRoom(kind, invite.RoomID, invite.Title); room.RoomID = invite.RoomID; room.Kind = kind; room.AddMember(session.UserID); if (invite.Host != null) { room.Host = Utilities.KeytoID(invite.Host); Core.IndexKey(room.Host, ref invite.Host); } RoomMap.SafeAdd(room.RoomID, room); showInvite = true; } // private room if (room.Kind == RoomKind.Secret) { if (!Core.KeyMap.ContainsKey(room.Host)) { return; } byte[] hostKey = Core.KeyMap[room.Host]; // if this is host sending us our verification if (session.UserID == room.Host) { // check that host signed our public key with his private if (!Utilities.CheckSignedData(hostKey, Core.KeyMap[Core.UserID], invite.SignedInvite)) { return; } if (!room.Invites.ContainsKey(Core.UserID)) // would fail if a node's dupe on network sends invite back to itself { room.Invites.Add(Core.UserID, new Tuple <ChatInvite, List <ushort> >(invite, new List <ushort>())); } } // else this is node in room sending us proof of being invited else { if (!Core.KeyMap.ContainsKey(session.UserID)) { return; // key should def be in map, it was added when session was made to sender } // check that host signed remote's key with host's private if (!Utilities.CheckSignedData(hostKey, Core.KeyMap[session.UserID], invite.SignedInvite)) { return; } } // if not verified yet, add them and send back our own verification if (!room.Verified.ContainsKey(session.UserID)) { room.Verified[session.UserID] = true; if (room.Active) { SendInviteProof(room, session); // someone sends us their proof, we send it back in return SendStatus(session); // send status here because now it will include private rooms } } } if (Trust != null && !Trust.TrustMap.SafeContainsKey(session.UserID)) { Trust.Research(session.UserID, 0, false); } if (showInvite) { Core.RunInGuiThread(NewInvite, session.UserID, room); } }