/// <summary> /// Add new room to rooms /// </summary> /// <param name="room">The room to be added</param> public void AddRoom(IRoom room) { //check nulls if (room == null || string.IsNullOrEmpty(room.RoomID)) { throw new ArgumentNullException(nameof(room)); } //check rooms for duplicate value if (Rooms.ContainsKey(room.RoomID)) { return; } //add room Rooms.Add(room.RoomID, room); //notify listeners RoomStateChanged?.Invoke(new RoomArgs(room, RoomActionType.CREATE)); if (room is ILobby lobby) { if (openLobbies.ContainsKey(lobby.GameType)) { openLobbies[lobby.GameType]++; } else { openLobbies.Add(lobby.GameType, 1); } } }
public void addRoom(Room room) { if (!Rooms.ContainsKey(room.ID)) { this.Rooms.Add(room.ID, room); } }
public void DeleteDevice(string room, string device) { if (Rooms.ContainsKey(room.ToLower())) { Rooms[room.ToLower()].DeleteDevice(device); } }
public void AddDevice(string room, Device device) { if (Rooms.ContainsKey(room.ToLower())) { Rooms[room.ToLower()].AddDevice(device); } }
public void DeleteRoom(string room) { if (Rooms.ContainsKey(room.ToLower())) { Rooms.Remove(room.ToLower()); } }
public void AddRoom(Room room) { if (!Rooms.ContainsKey(room.NameId)) { Rooms.Add(room.NameId, room); } }
public override void OnRoomListUpdate(List <RoomInfo> roomList) { base.OnRoomListUpdate(roomList); foreach (RoomInfo info in roomList) { if (!info.IsVisible || info.RemovedFromList) { if (Rooms.ContainsKey(info.Name)) { Rooms.Remove(info.Name); } } else if (Rooms.ContainsKey(info.Name)) { Rooms[info.Name] = info; } else { Rooms.Add(info.Name, info); } } OnRoomsChanged?.Invoke(); }
public Room GetRoom(string room) { if (Rooms.ContainsKey(room.ToLower())) { return(Rooms[room.ToLower()]); } throw new Exception("Такой комнаты не существует!"); }
private static bool ParseRooms(string line) { if (!(line.Contains(' '))) { return(false); } var roomsItems = line.Split(' '); if (roomsItems.Length != 3) { throw new Exceptions.MapException($"Wrong arguments \"{line}\""); } var name = roomsItems[0]; if (name[0] == 'L') { throw new Exceptions.MapException($"Wrong room name \"{name}\""); } if (Rooms.ContainsKey(name)) { throw new Exceptions.MapException($"Duplicated room name \"{name}\""); } if (!int.TryParse(roomsItems[1], out var x)) { throw new Exceptions.MapException($"Wrong coordinate x at room \"{line}\""); } if (!int.TryParse(roomsItems[2], out var y)) { throw new Exceptions.MapException($"Wrong coordinate y at room \"{line}\""); } var room = new Room(name, x, y); if (StartFlag) { if (StartRoom != null) { throw new Exceptions.MapException($"Duplicated start room"); } StartRoom = room; room.IsStart = true; StartFlag = false; } else if (EndFlag) { if (EndRoom != null) { throw new Exceptions.MapException($"Duplicated end room"); } EndRoom = room; room.IsEnd = true; EndFlag = false; } Rooms.Add(name, room); return(true); }
private Room getRoom(string roomNr) { if (!Rooms.ContainsKey(roomNr)) { Rooms.Add(roomNr, new Room()); } return(Rooms[roomNr]); }
public static void InitializePatients() { List <Patient> patientList = HospitalDB.FetchPatients(); foreach (Patient patient in patientList) { // Assigning Patient's Doctors List <String> doctorsIDs = HospitalDB.FetchPatientDoctors(patient.ID); foreach (String doctorID in doctorsIDs) { patient.assignDoctor((Doctor)Employees[doctorID]); ((Doctor)Employees[doctorID]).addPatient(patient); } if (patient.GetType() == typeof(ResidentPatient)) { // Fetching Patient's Department String departmentID = HospitalDB.FetchPersonDepartment(patient.ID); if (Departments.ContainsKey(departmentID)) { ((ResidentPatient)patient).Department = Departments[departmentID]; Departments[departmentID].Patients.Add(patient.ID, patient); } // Fetching Patient's Room from Database String roomID = HospitalDB.FetchPatientRoom(patient.ID); if (Rooms.ContainsKey(roomID)) { Rooms[roomID].addPatient(patient); ((ResidentPatient)patient).Room = Rooms[roomID]; // Assigning Patients to Nurses in the Same Room foreach (Nurse nurse in Rooms[roomID].Nurses.Values) { nurse.addPatient(patient); } } // Fetching Patient's Medicine from Database List <Medicine> medicineList = HospitalDB.FetchMedicine(patient.ID); foreach (Medicine medicine in medicineList) { ((ResidentPatient)patient).addMedicine(new Medicine { ID = medicine.ID, Name = medicine.Name, StartingDate = medicine.StartingDate, EndingDate = medicine.EndingDate }); } } Patients.Add(patient.ID, patient); } }
/// <summary> /// Check if a room name is a valid room /// </summary> /// <param name="roomName"></param> /// <returns></returns> public bool IsValidRoom(string roomName) { if (String.IsNullOrEmpty(roomName)) { return(false); } return(Rooms.ContainsKey(roomName)); }
public List <Item> GetRoomItems(Point coords) { if (!Rooms.ContainsKey(coords.ToString())) { return(null); } return(Rooms[coords.ToString()].Items); }
public void RemoveRoomItems(Point coords) { if (!Rooms.ContainsKey(coords.ToString())) { return; } Rooms[coords.ToString()].Items.Clear(); }
public bool CreateRoom(SharedSessionRoom room) { if (Rooms.ContainsKey(room.Id)) { return(false); } Rooms.Add(room.Id, room); WriteLine($"User '{room.Owner.Username}' created shared session '{room.Id}'", ConsoleColor.DarkCyan); return(true); }
public void RemoveRoom(SharedSessionRoom room, string reason = "") { if (!Rooms.ContainsKey(room.Id)) { return; } Rooms.Remove(room.Id); if (!string.IsNullOrWhiteSpace(reason)) { WriteLine($"Removed shared session '{room.Id}'. Reason: {reason}", ConsoleColor.DarkCyan); } }
private void XMPP_Presence(XmlElement element) { if (element.Attributes.GetNamedItem("to").Value == JID) { string[] frm = element.Attributes.GetNamedItem("from").Value.Split('/'); string roomId = frm[0]; string userId = frm[1]; string type = getValue(element.Attributes.GetNamedItem("type")); if (Rooms.ContainsKey(frm [0])) { Room room = Rooms [roomId]; User user; if (type == "available" || type == null) { if (room.Users.ContainsKey(userId)) { user = room.Users[userId]; } else { room.UserJoined(userId, user = new User(userId)); } //room.SendMessage("Willkommen test", user); foreach (XmlElement el in element.ChildNodes) { if (el.Name == "x" && el.FirstChild.Name == "item") { string affiliation = getValue(el.FirstChild.Attributes.GetNamedItem("admin")); string role = getValue(el.FirstChild.Attributes.GetNamedItem("role")); string premium = getValue(el.FirstChild.Attributes.GetNamedItem("premium")); string staff = getValue(el.FirstChild.Attributes.GetNamedItem("staff")); string color = getValue(el.FirstChild.Attributes.GetNamedItem("color")); user.Affiliation = affiliation ?? user.Affiliation; user.Role = role ?? user.Role; user.Premium = premium == null ? user.Premium : bool.Parse(premium); user.Staff = staff == null ? user.Staff : bool.Parse(staff); user.Color = color == null ? user.Color : System.Drawing.Color.FromArgb(Convert.ToInt32("ff" + color.Substring(1), 16)); } } } else if (type == "unavailable") { room.UserLeft(userId); } } } }
/// <summary> /// Add room to the map of loaded rooms /// </summary> public void AddRoom(Room room) { if (room == null) { return; } if (Rooms.ContainsKey(room.Data.Id)) { return; } Rooms.TryAdd(room.Data.Id, room); }
/// <summary> /// Remove room /// </summary> /// <param name="roomId">The id of the room to be removed</param> public void RemoveRoom(string roomId) { //check nulls if (string.IsNullOrEmpty(roomId)) { throw new ArgumentNullException(nameof(roomId)); } //check whether the room exists if (!Rooms.ContainsKey(roomId)) { return; } //notify listeners of the deleted room RoomStateChanged?.Invoke(new RoomArgs(Rooms[roomId], RoomActionType.DELETE)); if (Rooms[roomId] is ILobby lobby) { if (openLobbies.ContainsKey(lobby.GameType)) { openLobbies[lobby.GameType]--; if (openLobbies[lobby.GameType] < 3) { var generatedId = IdGenerator.CreateID(4); Lobby newLobby = new Lobby( generatedId, "Automatically created room", lobby.GameType, Array.Empty <IPlayer>(), lobby.MinPlayersNeededToStart, lobby.MaxPlayersNeededToStart); Rooms.Add(newLobby.RoomID, newLobby); RoomStateChanged?.Invoke(new RoomArgs(newLobby, RoomActionType.CREATE)); AddRoom(new ChatRoom(generatedId + "-TABLECHAT", "Automatically created chatRoom", null)); } } } //remove room Rooms.Remove(roomId); }
/// <summary> /// Remove player from rooms and playerRooms /// </summary> /// <param name="player">The player to be removed from the room</param> /// <param name="roomId">The id of the room which the player should be removed from</param> /// <returns>Whether the player was successfully removed from the room</returns> public async Task <bool> RemovePlayer(IPlayer player, string roomId) { //check null values if (player == null) { throw new ArgumentNullException(nameof(player)); } if (string.IsNullOrEmpty(roomId)) { throw new ArgumentNullException(nameof(roomId)); } if (Rooms.ContainsKey(roomId)) { //make sure the player is in the room if (Rooms[roomId].Players.Contains(player)) { //remove both bindings from the player to the room PlayerRooms[player].Remove(Rooms[roomId]); Rooms[roomId].Players.Remove(player); //TODO Find a better way to handle this /*//check whether the room is now empty and delete if that's the case * if (Rooms[roomId].Players.Count < 1) * { * if (Rooms[roomId] is IChatRoom) * return true; * * //invoke event to notify listeners of the deleted room * RoomStateChanged?.Invoke(new RoomArgs(Rooms[roomId], RoomActionType.DELETE)); * * //remove the room * RemoveRoom(roomId); * return true; * }*/ //invoke event to notify listeners of the updated room RoomStateChanged?.Invoke(new RoomArgs(Rooms[roomId], RoomActionType.UPDATE)); return(true); } } return(false); }
/// <summary> /// Add a player to a specific lobby /// Also getting added to playerrooms for fast lookup /// </summary> /// <param name="player">The player to add to the room</param> /// <param name="roomId">The id of the room to add the player to</param> /// <returns>Whether the player was successfully added to the room</returns> public async Task <bool> AddPlayer(IPlayer player, string roomId) { //check nulls if (player == null || player.PlayerId.Equals(0) || string.IsNullOrEmpty(player.Name)) { throw new ArgumentNullException(nameof(player)); } if (string.IsNullOrEmpty(roomId)) { throw new ArgumentNullException(nameof(roomId)); } //make sure the room exists and that the player can join if (Rooms.ContainsKey(roomId) && Rooms[roomId].PlayerCanJoinRoom(player)) { //add the player to the room Rooms[roomId].Players.Add(player); //add the room to the player rooms map if (PlayerRooms.ContainsKey(player)) { PlayerRooms[player].Add(Rooms[roomId]); } else { PlayerRooms.Add(player, new List <IRoom>() { Rooms[roomId] }); } //invoke event to notify listerners of the new state of the room RoomStateChanged?.Invoke(new RoomArgs(Rooms[roomId], RoomActionType.UPDATE)); //return with a successfull player insert return(true); } return(false); }
private void XMPP_Message(XmlElement element) { if (element.Attributes.GetNamedItem("to").Value == JID) { string frm = element.Attributes.GetNamedItem("from").Value; string key = frm.Split('/') [0]; if (Rooms.ContainsKey(key)) { Room r = Rooms [key]; string user = frm.Substring(key.Length + 1), message = ""; DateTime stamp = DateTime.Now; foreach (XmlElement el in element.ChildNodes) { if (el.Name == "body") { message = el.InnerXml; } else if (el.Name == "delay") { string stmp = el.Attributes.GetNamedItem("stamp").Value; stamp = DateTime.Parse(stmp); } } if (MessageReceived != null) { User userObj = null; if (r.Users.ContainsKey(user)) { userObj = r.Users [user]; MessageReceived(r, new MessageReceivedEventArgs(r.Users [user], message, stamp)); //TODO: stamp } else { MessageReceived(r, new MessageReceivedEventArgs(user, message, stamp)); } } } } }
public void CreateRoom(GameOptions options) { if (!Rooms.ContainsKey(options.name)) { RoomOptions roomOptions = new RoomOptions(); roomOptions.IsVisible = true; roomOptions.IsOpen = true; roomOptions.Plugins = new string[] { "MineSweepers" + options.plugin }; roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "plugin", "MineSweepers" + options.plugin }, { "hight", options.hight }, { "width", options.width }, { "maxPlayers", options.numOfPlayers }, { "mineRate", options.mineRate }, { "firstSafe", options.firstSafe }, { "endOnExpload", options.endOnExpload }, { "joinAfter", options.JoinAfterStart } }; roomOptions.CustomRoomPropertiesForLobby = new string[] { "plugin", "hight", "width", "mineRate", "maxPlayers", "joinAfter" }; roomOptions.MaxPlayers = (byte)options.numOfPlayers; TypedLobby lobby = new TypedLobby("Main", LobbyType.SqlLobby); PhotonNetwork.CreateRoom(options.name, roomOptions, lobby); } }
public bool Exists(string id) { return(Rooms.ContainsKey(id)); }
// Generates the level from a multi-dimensional array public void CreateBoard(char[,] map) { MAX_ROW = map.GetLength(0); MAX_COL = map.GetLength(1); Node.Walls = new HashSet <Location>(); Node.Pits = new HashSet <Location>(); for (int i = 0; i < MAX_ROW; i++) { for (int j = 0; j < MAX_COL; j++) { Location loc = new Location(i, j); char symbol = map[i, j]; GameObject tile; tile = Instantiate(tilePrefab, loc.ToVector(), Quaternion.identity); tile.transform.SetParent(TileHolder.transform); TileProperties tileProperties = tile.GetComponent <TileProperties>(); if (symbol == '+') { Node.Walls.Add(loc); tileProperties.Type = Item.Wall; } else if (symbol == '-') { Node.Pits.Add(loc); tileProperties.Type = Item.Pit; } else { tileProperties.Type = Item.Floor; FloorTiles.Add(loc, tile); } if (char.ToLower(symbol) >= 'a' && char.ToLower(symbol) <= 'z') { char lwrSymbol = char.ToLower(symbol); if (!Rooms.ContainsKey(lwrSymbol)) { Rooms.Add(lwrSymbol, new Room(lwrSymbol)); } Rooms[lwrSymbol].UnexploredTiles.Add(loc); Util.SetColor(FloorTiles[loc], Color.gray); } else if (symbol == '0') { Cat = new CatAgent(symbol, loc); } else if (symbol >= '1' && symbol <= '9') { Children.Add(symbol, new ChildAgent(symbol, loc)); } else if (symbol == '&') { Obstacles[loc] = new Obstacle(loc); GameObject prefab = objectPrefabs[0]; GameObject go; go = Instantiate(prefab, loc.ToVector(), Quaternion.identity); go.transform.SetParent(ObjectHolder.transform); ObjectPieces.Add(loc, go); } if (symbol >= 'A' && symbol <= 'Z') { Foods[loc] = new Food(loc); GameObject go; go = Instantiate(foodPrefab, loc.ToVector(), Quaternion.identity); go.transform.SetParent(ObjectHolder.transform); ObjectPieces.Add(loc, go); } } } foreach (Room r in Rooms.Values) { foreach (Location loc in r.UnexploredTiles) { HashSet <Location> neighbors = new HashSet <Location>() { new Location(loc.Row + 1, loc.Col), new Location(loc.Row - 1, loc.Col), new Location(loc.Row, loc.Col + 1), new Location(loc.Row, loc.Col - 1) }; foreach (Location neighbor in neighbors) { if (!Node.Walls.Contains(neighbor) && !Obstacles.ContainsKey(neighbor) && !r.UnexploredTiles.Contains(neighbor)) { r.Entrances.Add(loc); } } } } }
private bool RoomExist(Point coords) { return(Rooms.ContainsKey(coords.ToString())); }
protected ASystem(CrestronControlSystem controlSystem) : base(controlSystem, Assembly.GetExecutingAssembly()) { Debug.WriteInfo("System.ctor()", "Started"); BootStatus = "Loading System Type \"" + GetType().Name + "\""; BootProgressPercent = 5; SoftwareUpdate.SoftwareUpdate.UpdateShouldLoad += LoadUpdate; CrestronConsole.AddNewConsoleCommand(parameters => { if (parameters.Trim() == "?") { CrestronConsole.ConsoleCommandResponse( "Start running a test script. Options here are as follows:\r\n" + " count - set the number of times the script should loop and change sources\r\n" + " number - set the number to dial if the codec is selected\r\n" + "for example: \"TestScriptStart count 10 number 1234"); return; } var args = new Dictionary <string, string>(); try { var matches = Regex.Matches(parameters, @"(?:(\w+)\s+(\w+))"); foreach (Match match in matches) { args[match.Groups[1].Value] = match.Groups[2].Value; } } catch (Exception e) { CrestronConsole.ConsoleCommandResponse("Error parsing args, {0}", e.Message); return; } try { TestScriptStart(args); } catch (Exception e) { CrestronConsole.ConsoleCommandResponse("Error: {0}", e.Message); } }, "TestScriptStart", "Start a test script", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(parameters => TestScriptStop(), "TestScriptStop", "Stop running the test script", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(parameters => { try { var id = uint.Parse(parameters); Rooms[1].Source = id == 0 ? null : Sources[id]; CrestronConsole.ConsoleCommandResponse("Selected source \"{0}\" in Room \"{1}\"", Sources[id], Rooms[1].Name); } catch (Exception e) { CrestronConsole.ConsoleCommandResponse("Error: {0}", e.Message); } }, "Source", "Select a source by ID for the first room", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(parameters => { try { foreach (var source in Sources) { CrestronConsole.ConsoleCommandResponse("Source {0}: {1}", source.Id, source.Name); } } catch (Exception e) { CrestronConsole.ConsoleCommandResponse("Error: {0}", e.Message); } }, "ListSources", "List sources by IDs", ConsoleAccessLevelEnum.AccessOperator); StartWebApp(9001); if (ConfigManager.Config.SystemType == SystemType.NotConfigured) { return; } var config = ConfigManager.Config; Debug.WriteInfo("System.ctor()", "Config loaded"); #region System Switcher BootStatus = "Loading switcher configuration"; BootProgressPercent = 6; if (config.SwitcherType != SystemSwitcherType.NotInstalled) { try { switch (config.SwitcherType) { case SystemSwitcherType.BigDmFrame: Switcher = new BigDmSwitcher(controlSystem as ControlSystem, config.SwitcherConfig); Switcher.InputStatusChanged += LocalSwitcherOnInputStatusChanged; break; case SystemSwitcherType.DmFrame: Switcher = new DmSwitcher(controlSystem as ControlSystem, config.SwitcherConfig); Switcher.InputStatusChanged += LocalSwitcherOnInputStatusChanged; break; } } catch (Exception e) { CloudLog.Exception(e, "Error loading System Video Switcher"); } } #endregion var controllers = config.OneBeyondAddresses.ToDictionary(address => address.Key, address => new OneBeyond(address.Value, address.Key)); _oneBeyondControllers = new ReadOnlyDictionary <uint, OneBeyond>(controllers); #region DSP BootStatus = "Loading dsp configuration"; BootProgressPercent = 7; if (config.DspConfig != null && config.DspConfig.Enabled) { Dsp = new QsysCore(new[] { config.DspConfig.DeviceAddressString }, config.DspConfig.Name, config.DspConfig.Username, config.DspConfig.Password); Dsp.HasIntitialized += DspOnHasIntitialized; } #endregion #region Rooms BootStatus = "Loading Room Configs"; BootProgressPercent = 10; foreach (var roomConfig in config.Rooms .Where(r => r.Enabled) .OrderBy(r => r.Id)) { Debug.WriteInfo("System.ctor()", "Setting up {0} room \"{1}\"", config.SystemType, roomConfig.Name); try { var room = (ARoom)Assembly.GetExecutingAssembly() .GetType(roomConfig.RoomType) .GetConstructor(new CType[] { GetType(), typeof(RoomConfig) }) .Invoke(new object[] { this, roomConfig }); WebApp.AddXpanelLink(string.Format("/dashboard/app/xpanel/xpanel?room={0}", room.Id), room.Name); } catch (Exception e) { CloudLog.Exception(e, "Failed to load room type \"{0}\"", roomConfig.RoomType); } } #endregion #region Global Sources if (config.GlobalSources != null) { foreach (var sourceConfig in config.GlobalSources .Where(s => s.Enabled) .OrderBy(s => s.Id)) { Debug.WriteInfo("System.ctor()", "Setting up global source \"{0}\", {1}", sourceConfig.Name, sourceConfig.SourceType); switch (sourceConfig.SourceType) { case SourceType.AppleTV: var appleTV = new AppleTV(controlSystem.IROutputPorts[sourceConfig.DeviceAddressNumber]); new GenericSource(this, sourceConfig, appleTV); break; case SourceType.PC: new PCSource(this, sourceConfig); break; default: new GenericSource(this, sourceConfig); break; } } } #endregion #region User Interfaces BootStatus = "Loading UI Controllers"; BootProgressPercent = 15; #if DEBUG Debug.WriteInfo("Setting up User Interfaces", "Count = {0}", config.UserInterfaces.Count(ui => ui.Enabled)); Debug.WriteInfo(JToken.FromObject(config.UserInterfaces).ToString(Formatting.Indented)); #endif foreach (var uiConfig in config.UserInterfaces.Where(ui => ui.Enabled)) { try { Debug.WriteInfo("System.ctor()", "Setting up UIController \"{0}\", {1} 0x{2:X2}", uiConfig.Name, uiConfig.DeviceType, uiConfig.DeviceAddressNumber); if (uiConfig.UIControllerType == UIControllerType.RemoteMpc) { var isc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(uiConfig.DeviceAddressNumber, uiConfig.DeviceAddressString, controlSystem); var mpcUi = new MpcUIController(this, isc, Rooms.ContainsKey(uiConfig.DefaultRoom) ? Rooms[uiConfig.DefaultRoom] : null); mpcUi.Register(); continue; } var uiAssembly = Assembly.LoadFrom(@"Crestron.SimplSharpPro.UI.dll"); var type = uiAssembly.GetType("Crestron.SimplSharpPro.UI." + uiConfig.DeviceType); BasicTriListWithSmartObject panel; var ctor = type.GetConstructor(new CType[] { typeof(UInt32), typeof(ControlSystem) }); panel = (BasicTriListWithSmartObject) ctor.Invoke(new object[] { uiConfig.DeviceAddressNumber, controlSystem }); var app = panel as CrestronApp; if (app != null && !string.IsNullOrEmpty(uiConfig.DeviceAddressString)) { app.ParameterProjectName.Value = uiConfig.DeviceAddressString; } if (panel != null) { panel.Description = uiConfig.Name; } UIController ui = null; RoomBase defaultRoom; switch (uiConfig.UIControllerType) { case UIControllerType.TechPanel: defaultRoom = Rooms.ContainsKey(uiConfig.DefaultRoom) ? Rooms[uiConfig.DefaultRoom] : null; ui = new RoomUIController(this, panel, defaultRoom, true); break; case UIControllerType.UserPanel: defaultRoom = Rooms.ContainsKey(uiConfig.DefaultRoom) ? Rooms[uiConfig.DefaultRoom] : null; ui = new RoomUIController(this, panel, defaultRoom, false); break; } foreach (var room in uiConfig.AllowedRoomIds) { ui.AddRoomToAllowedRooms(Rooms[room]); } if (ui != null) { ui.Register(); } } catch (Exception e) { CloudLog.Exception(e, "Error loading UI device {0} 0x{1:X2}", uiConfig.DeviceType, uiConfig.DeviceAddressNumber); } } UIControllers.SetupCustomTime(Serials.Time); UIControllers.SetupCustomDate(Serials.Date); #endregion if (this is FireAlarmMonitorSystem) { return; } var fireInterfaceAddress = ConfigManager.GetCustomValue("FireAlarmInterfaceAddress") as string; if (string.IsNullOrEmpty(fireInterfaceAddress)) { return; } _fireAlarmListener = new FireAlarmListener(fireInterfaceAddress); _fireAlarmListener.StatusChanged += FireAlarmListenerOnStatusChanged; }
public void Run() { Room currentRoom = elevator; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Clear(); Console.WriteLine($"|{" ",-30}Another day at the Brooklyn Nine-Nine.\n\n\n" + $"{" ",-20}You, Detective Rosa Diaz, are getting ready for another day of work,\n" + $"{" ",-24}when you suddenly remember that it is the day before Halloween.\n" + $"{" ",-30}On top of making fun of Boyle's costume,\n" + $"{" ",-21}you are also going to have escape dealing with Jake's heist plans.\n" + $"{" ",-40}Welcome to Halloween Heist\n" + $"{" ",-45}Hide and Seek\n\n"); Console.WriteLine($"{" ",-30}You can use these words and letters to play the game..."); Console.WriteLine($"{" ",-33}'go' / 'head' / 'leave' / 'exit' + room name: Go to an adjacent room."); Console.WriteLine(" "); Console.WriteLine($"{" ",-27}'m' / 'map': Allows you to see the map of the precinct."); Console.WriteLine($"{" ",-35}'q' / 'quit': Quits the game."); ImTheMap(); Console.ReadKey(); Console.WriteLine(currentRoom.Name.ToUpper()); Console.WriteLine(currentRoom.Description); bool foundPeralta = false; int count = 0; while (!foundPeralta) { string command = Console.ReadLine().ToLower(); if (command.Contains("go") || command.Contains("head") || command.Contains("leave") || command.Contains("exit")) { Console.WriteLine(currentRoom.Name.ToUpper()); Console.WriteLine(currentRoom.Description); Console.Clear(); bool foundExit = false; foreach (string exit in currentRoom.Exits) { string currentOccupant = GetRandomNpcs(); if (command.Contains(exit) && Rooms.ContainsKey(exit)) { currentRoom = Rooms[exit]; if (count == 0) { Console.WriteLine("0900"); } else if (count == 1) { Console.WriteLine("1100"); } else if (count == 2) { Console.WriteLine("1300"); } else if (count == 3) { Console.WriteLine("1500"); } else if (count == 4) { Console.WriteLine("1700"); YouWonTheGame(); Console.ReadKey(); foundPeralta = true; } Console.WriteLine(currentRoom.Name.ToUpper()); Console.WriteLine(currentRoom.Description); Console.WriteLine($"{" ",-5} In {currentRoom.Name.ToUpper()} you see {currentOccupant}.\n" + $"\n" + $"{" ",-20} What would you like to do?"); if (currentOccupant.Contains(Jake.Name)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" Doesn't matter what you want to do! \n" + " Jake found you before you could go home for the day. Better luck next year.\n" + " For now, you need to help plan Jake's stupid heist.\n\n\n\n"); YouLostTheGame(); Console.WriteLine(" Created By\n\n" + " Marley & David"); Console.ReadKey(); foundPeralta = true; } foundExit = true; count++; break; } } if (!foundExit) { Console.WriteLine("Last time I checked I can't teleport. Try asking me to go somewhere I can actually get to."); } } else if (command.Contains("help") || command.Contains("h")) { Console.WriteLine(" 'go' / 'head' / 'leave' / 'exit' + room name : Go to an adjacent room."); Console.WriteLine(" "); Console.WriteLine(" 'm' / 'map': Allows you to see the map of the precinct."); Console.WriteLine(" "); Console.WriteLine(" 'q' / 'quit': Quits the game."); Console.WriteLine(" "); Console.ReadKey(); return; } else if (command.Contains("map") || command.Contains("m")) { ImTheMap(); } else if (command.Contains("quit") || command.Contains("q")) { Console.ForegroundColor = ConsoleColor.Magenta; YouLostTheGame(); Console.ReadKey(); foundPeralta = true; } else { Console.WriteLine("I hate small talk."); } } }
private void InitCommands() { //Commands[""] = (soc, args) => { }; //Recived when a client first connects. //this checks to see if they can and adds them to the #root channel. Commands["connect"] = (soc, args) => { String newNick = args[0]; if (Rooms["#root"].HasUser(newNick)) { soc.Send(Util.StoB(Errors.NickExists)); soc.Shutdown(SocketShutdown.Both); soc.Close(); } else { User tempUser = new User(soc, newNick); Rooms["#root"].AddUser(tempUser); } }; //Recived when a user whats a list of connected users to a channel. Commands["nicklist"] = (soc, args) => { String room = args[0]; if (Rooms.ContainsKey(room)) { soc.Send(Util.StoB("nicks " + room + " " + Rooms[room].GetAllNicks())); } else { soc.Send(Util.StoB(Errors.NoChan)); } }; //Recived when a user whants all rooms on the server Commands["roomlist"] = (soc, args) => { String rooms = ""; int i = 0; foreach (Room r in Rooms.Values) { rooms += r.Name + (++i < Rooms.Values.Count ? ", " : ""); } soc.Send(Util.StoB("said #root #root " + rooms)); }; //Recived when a user is tring to join a room. //Will create a room if it doesnt exist. Commands["join"] = (soc, args) => { String nick = args[0]; String roomName = args[1]; if (Rooms["#root"].HasUser(nick)) { User tarUser = Rooms["#root"].ConnectedUsers[nick]; if (Rooms.ContainsKey(roomName)) { Rooms[roomName].AddUser(tarUser); } else { Rooms[roomName] = new Room(roomName); Rooms[roomName].AddUser(tarUser); } } else { soc.Send(Util.StoB(Errors.NoUser)); } }; //Recived when a user is trying to leave a room. //Will terminate the connection if the user leaves #root Commands["leave"] = (soc, args) => { String nick = args[0]; String roomName = args[1]; if (roomName == "#root") { if (Rooms["#root"].HasUser(nick)) { Rooms["#root"].GetUser(nick).LeaveAllRooms(); soc.Shutdown(SocketShutdown.Both); soc.Close(); } else { soc.Send(Util.StoB(Errors.NoUser)); } } else { if (Rooms.ContainsKey(roomName)) { if (Rooms[roomName].HasUser(nick)) { Rooms[roomName].RemoveUser(nick); } else { soc.Send(Util.StoB(Errors.NoUser)); } } else { soc.Send(Util.StoB(Errors.NoChan)); } } }; //Recived when a user sends a message Commands["say"] = (soc, args) => { String target = args[0]; String src = args[1]; String msg = ""; for (int i = 2; i < args.Length; i++) { msg += (args[i] + " "); } if (target.StartsWith("#")) { if (Rooms.ContainsKey(target)) { Rooms[target].Say(src, msg); } else { soc.Send(Util.StoB(Errors.NoChan)); } } }; Commands["ping"] = (soc, args) => { soc.Send(Util.StoB("pong")); }; }
public SharedSessionRoom GetRoom(Guid guid) { return(Rooms.ContainsKey(guid) ? Rooms[guid] : null); }