private void HandleSelectCharacterRequest(string username, PacketBase p) { CharacterSelectedPacket packet = (CharacterSelectedPacket)p; // If player is already added to the game world, we don't want to add another. Ignore this request. if (_pcs.ContainsKey(username)) { _logger.Info($"Player {username} is already added to the game world. Ignoring request."); return; } string path = _pathService.ServerVaultDirectory + username + "/" + packet.PCGlobalID + ".pcf"; if (!File.Exists(path)) { _logger.Error($"PC file '{packet.PCGlobalID}.pcf' does not exist for username {username}. Cannot select character. Ignoring request."); return; } PCData pcData = _dataService.Load <PCData>(path); Entity player = _entityFactory.Create <Player, PCData>(pcData); _pcs.Add(username, player); ScriptGroup scripts = _gameModule.GetComponent <ScriptGroup>(); string script = scripts[ScriptEvent.OnModulePlayerEnter]; _scriptService.QueueScript(script, _gameModule); CharacterAddedToWorldPacket response = new CharacterAddedToWorldPacket(); _networkService.SendMessage(PacketDeliveryMethod.ReliableUnordered, response, username); }
private void SaveWorkingRoomData() { // 가라데이터 // 나중에 PlayerPrefs로 저장된 Json 문자열로 대신한다. GamePlayData gameData = new GamePlayData(); gameData.bitCoin = "100"; gameData.money = "1000000"; gameData.listRoom = new List <WorkingRoomData> (); WorkingRoomData roomData = new WorkingRoomData(); roomData.idx = 0; roomData.level = 0; roomData.listPc = new List <PCData> (); PCData pcData = new PCData(); pcData.idx = 0; pcData.level = 2; pcData.type = 0; pcData.gauge = 0.5f; roomData.listPc.Add(pcData); gameData.listRoom.Add(roomData); string saveData = JsonUtility.ToJson(gameData, true); Debug.Log(saveData); PlayerPrefs.SetString("playerinfo", saveData); }
private void OnCreateCharacterRequest(string username, PacketBase p) { // TODO: Validate + sanitize packet CreateCharacterPacket packet = (CreateCharacterPacket)p; PCData pcData = new PCData { LastName = packet.LastName, FirstName = packet.FirstName }; string path = _pathService.ServerVaultDirectory + username + "/" + pcData.GlobalID + ".pcf"; _dataService.Save(pcData, path); CharacterCreatedPacket response = new CharacterCreatedPacket { Description = pcData.Description, LastName = pcData.LastName, FirstName = pcData.FirstName, Level = pcData.Level, GlobalID = pcData.GlobalID }; _networkService.SendMessage(PacketDeliveryMethod.ReliableUnordered, response, username); }
private static Dictionary <string, LinkModel> getLinkModel(string ip, out PCData pcdata, out double memCount) { NetTcpBinding binging = new NetTcpBinding(); binging.MaxBufferPoolSize = 524288; binging.MaxBufferSize = 2147483647; binging.MaxReceivedMessageSize = 2147483647; binging.MaxConnections = 1000; binging.ListenBacklog = 200; binging.OpenTimeout = TimeSpan.Parse("00:10:00"); binging.ReceiveTimeout = TimeSpan.Parse("00:10:00"); binging.TransferMode = TransferMode.Buffered; binging.Security.Mode = SecurityMode.None; binging.SendTimeout = TimeSpan.Parse("00:10:00"); binging.ReaderQuotas.MaxDepth = 64; binging.ReaderQuotas.MaxStringContentLength = 2147483647; binging.ReaderQuotas.MaxArrayLength = 16384; binging.ReaderQuotas.MaxBytesPerRead = 4096; binging.ReaderQuotas.MaxNameTableCharCount = 16384; binging.ReliableSession.Ordered = true; binging.ReliableSession.Enabled = false; binging.ReliableSession.InactivityTimeout = TimeSpan.Parse("00:10:00"); Dictionary <string, LinkModel> modellist = new Dictionary <string, LinkModel>(); using (MonitorClient client = MonitorClient.Instance) { IMonitorControl proxy = client.getProxy(ip, binging); modellist = proxy.GetMonitorInfo(out pcdata, out memCount); } return(modellist); }
private void button1_Click(object sender, EventArgs e) { this.Close(); PCData main = new PCData(); main.Show(); }
//Gets and sends PCData to a socket static void writeSocket(NetworkStream ns) { while (true) { AllPrograms = Mixer.Mixer.GetAllPrograms(); List <ProgramData> program = new List <ProgramData>(); for (int k = 0; k < GlobalPCData.Programs.Count; k++) { for (int i = 0; i < AllPrograms.Count; i++) { if (GlobalPCData.Programs[k].PID == AllPrograms[i].PID) { program.Add(GlobalPCData.Programs[k]); } } } GlobalPCData.Programs = program; PCData PCdata = GetPCData(); PCdata = FixNames(PCdata); //Converts PCdata to a byte array Byte[] data = SerializeToByteArray(PCdata); SendBytes(data, ns); Thread.Sleep(2000); } }
public static GameTargetPlatform Init() { pc = new PCData(); mobile = new MobileData(); console = new ConsoleData(); web = new WebData(); return(GetCurrent()); }
public PCData Save() { PCData data = new PCData(); data.IP = IP; data.gate = subnet.defaultGateway; data.mask = subnet.mask; data.watched = watched; return(data); }
public void Load(PCData data) { IP = data.IP; subnet.LoadFreshConfig(data.IP, data.mask, data.gate); watched = data.watched; //if we are being watched, add a task watcher if (watched) { gameObject.GetComponent <TaskWatcher>().active = true; } }
//Converts a name from it's "real" name to it's user friendly name private static PCData FixNames(PCData PCdata) { for (int i = 0; i < DefaultDeviceNames.Count; i++) { if (PCdata.defaultDevice.Name == DefaultDeviceNames[i].RealName) { PCdata.defaultDevice.Name = DefaultDeviceNames[i].FriendlyName; } } return(PCdata); }
private PCData SetMuteMaster(PCData pcdata) { if (pcdata.defaultDevice.IsMute == true) { for (int i = 0; i < pcdata.Programs.Count; i++) { pcdata.Programs[i].IsMute = true; } } SetMute("DefaultDevice", pcdata.defaultDevice.IsMute); return(pcdata); }
//Gets PCData and returns it private static PCData GetPCData() { PCData data = new PCData(); data.defaultDevice = Mixer.Mixer.GetPCDataDefaultDevice(); List <int> PIDList = GetPIDList(); PIDList = RemoveDuplicates(PIDList); data.Programs = Mixer.Mixer.GetPCDataPrograms(PIDList[0], PIDList[1], PIDList[2], AllPrograms); return(data); }
public static PCTransferObject Load(PCData data) { PCTransferObject pcTO = new PCTransferObject { FirstName = data.FirstName, LastName = data.LastName, GlobalID = data.GlobalID, Level = data.Level, Description = data.Description }; return(pcTO); }
public void Copy(PCData from) { currentHP = from.currentHP; maxHP = from.maxHP; for(int i = 0; i < Abilities.Length; i++) { Abilities[i] = from.Abilities[i]; } continueSceneIndex = from.continueSceneIndex; x = from.x; y = from.y; z = from.z; }
private void readSocket(NetworkStream Networkstream, string ip) { while (true) { byte[] readMsgData = { 0 }; try { byte[] readMsgLen = new byte[4]; Networkstream.Read(readMsgLen, 0, 4); int dataLen = BitConverter.ToInt32(readMsgLen, 0); readMsgData = new byte[dataLen]; if (dataLen > 0) { try { if (Networkstream.CanRead) { byte[] myReadBuffer = new byte[1024]; MemoryStream ms = new MemoryStream(); int numberOfBytesRead = 0; do { numberOfBytesRead = Networkstream.Read(myReadBuffer, 0, myReadBuffer.Length); ms.Write(myReadBuffer, 0, myReadBuffer.Length); }while (Networkstream.DataAvailable && ms.Length < dataLen); PCData data = Serialize.DeserializeFromByteArray <PCData>(ms.GetBuffer()); ProcessData(data); } else { Console.WriteLine("Sorry. You cannot read from this NetworkStream."); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } } catch (System.IO.IOException) { StartServer(ip); //Catch Exception and restart the server } catch (Exception e) { Console.WriteLine(e.ToString()); } } }
private void ProcessData(PCData pcdata) { SetText(this, this.DefaultDevice, pcdata.defaultDevice.Name); SetVolumeLevel(this, this.DefaultDeviceVolume, pcdata.defaultDevice.Volume); pcdata = SetMuteMaster(pcdata); for (int i = 0; i < pcdata.Programs.Count; i++) { SetProgramImage(i, pcdata); SetProgramMute(i, pcdata); SetProgramVolume(i, pcdata); SetProgramName(i, pcdata); } }
private void SetProgramName(int i, PCData pcdata) { if (i == 0) { SetText(this, this.Program1, pcdata.Programs[i].Name); } else if (i == 1) { SetText(this, this.Program2, pcdata.Programs[i].Name); } else if (i == 2) { SetText(this, this.Program3, pcdata.Programs[i].Name); } }
private void SetProgramMute(int i, PCData pcdata) { if (i == 0) { SetMute("Program1", pcdata.Programs[i].IsMute); } else if (i == 1) { SetMute("Program2", pcdata.Programs[i].IsMute); } else if (i == 2) { SetMute("Program3", pcdata.Programs[i].IsMute); } }
private void SetProgramVolume(int i, PCData pcdata) { if (i == 0) { SetVolumeLevel(this, this.Program1Volume, pcdata.Programs[i].Volume); } else if (i == 1) { SetVolumeLevel(this, this.Program2Volume, pcdata.Programs[i].Volume); } else if (i == 2) { SetVolumeLevel(this, this.Program3Volume, pcdata.Programs[i].Volume); } }
private void HandleConnected(NetIncomingMessage message) { string username = _connectionToUsername[message.SenderConnection]; int serverNameLength = _settingsService.ServerName.Length > 32 ? 32 : _settingsService.ServerName.Length; int announcementLength = _settingsService.Announcement.Length > 255 ? 255 : _settingsService.Announcement.Length; ConnectedToServerPacket response = new ConnectedToServerPacket { ServerName = _settingsService.ServerName.Substring(0, serverNameLength), AllowCharacterDeletion = _settingsService.AllowCharacterDeletion, Announcement = _settingsService.Announcement.Substring(0, announcementLength), Category = _settingsService.GameCategory, CurrentPlayers = _usernameToConnection.Count, MaxPlayers = _settingsService.MaxPlayers, PVP = _settingsService.PVPType, RequiredResourcePacks = _moduleService.GetLoadedModuleData().ResourcePacks }; string directoryPath = _pathService.ServerVaultDirectory + "/" + username + "/"; if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } string[] files = Directory.GetFiles(_pathService.ServerVaultDirectory + "/" + username + "/", "*.pcf"); foreach (string pcFile in files) { PCData pc = _dataService.Load <PCData>(pcFile); PCTransferObject pcTO = PCTransferObject.Load(pc); response.PCs.Add(pcTO); } SendMessage(PacketDeliveryMethod.ReliableUnordered, response, username); OnPlayerConnected?.Invoke(username); }
private void SetProgramImage(int i, PCData pcdata) { if (pcdata.Programs[i].Name == null) { //Display blank audio device } if (pcdata.Programs[i].Name == "System Sounds") { pcdata.Programs[i].Icon = Properties.Resources.SystemSoundsIcon; } if (i == 0) { Program1Icon.Image = pcdata.Programs[i].Icon; } else if (i == 1) { Program2Icon.Image = pcdata.Programs[i].Icon; } else if (i == 2) { Program3Icon.Image = pcdata.Programs[i].Icon; } }
public void SetState(PCData pcData) { eState = (ePCState)pcData.state; if (listImg == null) { listImg = new List <Image> (); listImg.Add(GetComponent <Image> ()); if (transform.childCount == 0) { eType = ePCType.eBasic; } else { for (int i = 0; i < transform.childCount; i++) { listImg.Add(transform.GetChild(i).GetComponent <Image> ()); } if (transform.childCount == 1) { eType = ePCType.ePro; } else { eType = ePCType.eSuper; } } } switch (eState) { case ePCState.eNone: for (int i = 0; i < listImg.Count; i++) { listImg [i].color = new Color(0, 0, 0, 0.55f); } break; case ePCState.eMining: for (int i = 0; i < listImg.Count; i++) { listImg [i].color = Color.white; } break; case ePCState.eEnoughCoin: for (int i = 0; i < listImg.Count; i++) { listImg [i].color = Color.white; } break; case ePCState.eBreak: for (int i = 0; i < listImg.Count; i++) { listImg [i].color = Color.white; } break; } }
/// <summary> /// Loads data. /// </summary> private void Load() { // try to load data from server if (!LoadRemote()) { // load data from local environment config file LoadLocal(); } LogHelper.LogDebug("ColorPageCost " + ColorPageCost.ToString()); LogHelper.LogDebug("BlackAndWhitePageCost " + BlackAndWhitePageCost.ToString()); if (BlackAndWhitePageCost <= 0) { BlackAndWhitePageCost = 1; } if (ColorPageCost <= 0) { ColorPageCost = 2; } // check data and save if ((UserPCs != null && UserPCs.Count > 0) && (Printers != null && Printers.Count > 0)) { Save(); } // check if (UserPCs == null || UserPCs.Count < 1) { UserPCs = new PCData() { new PCDataEntry { Name = "frontdesk1-pc", Margin = new Thickness(678, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "apiserver-pc", Margin = new Thickness(698, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "frontdesk2-pc", Margin = new Thickness(728, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "conference", Margin = new Thickness(66, 110, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "backdesk-pc", Margin = new Thickness(90, 200, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "printerleft-pc", Margin = new Thickness(760, 146, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "printerright-pc", Margin = new Thickness(696, 146, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle01-pc", Margin = new Thickness(628, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle02-pc", Margin = new Thickness(571, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle03-pc", Margin = new Thickness(514, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle04-pc", Margin = new Thickness(457, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle05-pc", Margin = new Thickness(400, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle06-pc", Margin = new Thickness(343, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle07-pc", Margin = new Thickness(286, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle08-pc", Margin = new Thickness(229, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle09-pc", Margin = new Thickness(172, 18, 0, 0), MapPosition = MapPosition.Top }, new PCDataEntry { Name = "cubicle10-pc", Margin = new Thickness(576, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle11-pc", Margin = new Thickness(526, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle12-pc", Margin = new Thickness(470, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle13-pc", Margin = new Thickness(418, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle14-pc", Margin = new Thickness(366, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle15-pc", Margin = new Thickness(314, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle16-pc", Margin = new Thickness(272, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle17-pc", Margin = new Thickness(210, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle18-pc", Margin = new Thickness(158, 172, 0, 0), MapPosition = MapPosition.Side }, new PCDataEntry { Name = "cubicle19-pc", Margin = new Thickness(176, 318, 0, 0), MapPosition = MapPosition.Bottom }, new PCDataEntry { Name = "cubicle20-pc", Margin = new Thickness(232, 318, 0, 0), MapPosition = MapPosition.Bottom }, new PCDataEntry { Name = "cubicle21-pc", Margin = new Thickness(288, 318, 0, 0), MapPosition = MapPosition.Bottom }, new PCDataEntry { Name = "cubicle22-pc", Margin = new Thickness(344, 318, 0, 0), MapPosition = MapPosition.Bottom }, new PCDataEntry { Name = "cubicle23-pc", Margin = new Thickness(400, 318, 0, 0), MapPosition = MapPosition.Bottom }, }; } // check valid printer destinations if (Printers == null || Printers.Count < 1) { // load defaults Printers = new PrinterData() { new PrinterDataEntry() { Name = "backprinter", InternalName = "backprinter", MarginGlow = new Thickness(207.5, 226, 0, 0), MarginLabel = new Thickness(141, 245, 0, 0), ExcludedPCNames = new List <string>() { "backdesk-pc", "frontdesk1-pc", "frontdesk2-pc", "apiserver-pc" } }, // COLOR PRINTER $.75 CENTS PER PAGE new PrinterDataEntry() { Name = "COLOR PRINTER $.75 CENTS PER PAGE", InternalName = "colorprinter", MarginGlow = new Thickness(761, 190, 0, 0), MarginLabel = new Thickness(695, 212, 0, 0), ExcludedPCNames = new List <string>() { "printerleft-pc", "printerright-pc", "frontdesk1-pc", "frontdesk2-pc", "apiserver-pc" } }, // BLACK & WHITE $.25 CENTS PER PAGE new PrinterDataEntry() { Name = "BLACK & WHITE $.25 CENTS PER PAGE", InternalName = "black-whiteprinter", MarginGlow = new Thickness(787.5, 190, 0, 0), MarginLabel = new Thickness(720, 212, 0, 0), ExcludedPCNames = new List <string>() { "printerleft-pc", "printerright-pc", "frontdesk1-pc", "frontdesk2-pc", "apiserver-pc" } }, new PrinterDataEntry() { Name = "cubicle01_printer", InternalName = "cubicle01_printer", MarginGlow = new Thickness(685, 68.5, 0, 0), MarginLabel = new Thickness(618, 92, 0, 0), DoNotShowFootsteps = true }, new PrinterDataEntry() { Name = "cubicle02_printer", InternalName = "cubicle02_printer", MarginGlow = new Thickness(629.5, 68.5, 0, 0), MarginLabel = new Thickness(563, 92, 0, 0), DoNotShowFootsteps = true }, new PrinterDataEntry() { Name = "cubicle05_printer", InternalName = "cubicle05_printer", MarginGlow = new Thickness(464.5, 69, 0, 0), MarginLabel = new Thickness(398, 92, 0, 0), DoNotShowFootsteps = true }, }; } /* * LogHelper.Log("Environment Data Printers"); * foreach (var item in Printers) * LogHelper.Log(item.ToString()); * * LogHelper.Log("Environment Data UserPCs"); * foreach (var item in UserPCs) * LogHelper.Log(item.ToString());*/ //Save(); }