public ViewStats(ClientController clientCon, ClientState clientState) { _clientCon = clientCon; _clientState = clientState; InitializeComponent(); triples.Columns.Add(new DataGridTextColumn { Header = "Origin", Binding = new Binding("Origin") }); triples.Columns.Add(new DataGridTextColumn { Header = "Destination", Binding = new Binding("Destination") }); triples.Columns.Add(new DataGridTextColumn { Header = "Priority", Binding = new Binding("Priority") }); criticalRoutes.Columns.Add(new DataGridTextColumn { Header = "Origin", Binding = new Binding("Origin") }); criticalRoutes.Columns.Add(new DataGridTextColumn { Header = "Destination", Binding = new Binding("Destination") }); criticalRoutes.Columns.Add(new DataGridTextColumn { Header = "Priority", Binding = new Binding("Priority") }); lastDate = DateTime.UtcNow; firstDate = _clientState.FirstEvent; var numDays = lastDate.Day - firstDate.Day; dateSlider.Maximum = numDays; dateSlider.IsEnabled = true; firstDayLabel.Content = firstDate.ToShortDateString(); lastDayLabel.Content = lastDate.ToShortDateString(); _clientCon.StatsReceived += new ClientController.StatisticsReceivedDelegate(Stats_Recieved); }
public RequestDelivery(ClientController clientCon, ClientState clientState) { InitializeComponent(); var state = new CurrentState(); var routeService = new RouteService(state); _pathFinder = new PathFinder(routeService); _clientState = clientState; _pathfindService = new DeliveryService(state, _pathFinder); _clientController = clientCon; foreach (var routeNode in clientState.GetAllRouteNodes()) { ComboBoxItem cbi = new ComboBoxItem(); if (routeNode is DistributionCentre) cbi.Content = ((DistributionCentre)routeNode).Name; else if (routeNode is InternationalPort) cbi.Content = routeNode.Country.Name; cbi.Tag = routeNode.ID; this.origin.Items.Add(cbi); ComboBoxItem cbi2 = new ComboBoxItem(); if (routeNode is DistributionCentre) cbi2.Content = ((DistributionCentre)routeNode).Name; else if (routeNode is InternationalPort) cbi2.Content = routeNode.Country.Name; cbi2.Tag = routeNode.ID; this.destination.Items.Add(cbi2); } _clientController.OptionsReceived += new ClientController.DeliveryOptionsDelegate(DeliveryOptions_Returned); _clientController.DeliveryOK+= new ClientController.DeliveryConfirmedDelegate(DeliveryConfirmed); }
internal ClientVideo(ClientState pState) { InitializeComponent(); this._state = pState; this._state.dUpdateVideo = this.UpdateVideo; this.Text = this._state.Nickname + " : " + this.Text; }
internal ClientChatClipboard(ClientState pState) { InitializeComponent(); this._state = pState; // Reference to delegates this._state.dUpdateClipboard = this.UpdateClipboardData; this._state.dUpdateHistory = this.UpdateHistory; this.Text = this._state.Nickname + " : " + this.Text; }
public Home() { InitializeComponent(); SetUpHome(); // initialise the state _clientState = new ClientState(); _clientCon = new ClientController(_clientState); _clientCon.Updated += new ClientController.StateUpdatedDelegate(clientController_Updated); }
public Home(ClientState state) { InitializeComponent(); SetUpHome(); _clientState = state; _clientCon = new ClientController(_clientState); _clientCon.Updated += new ClientController.StateUpdatedDelegate(clientController_Updated); ReloadAll(); }
private void OnStateChanged(ClientState state) { UnityEngine.Debug.Log("State: " + state); switch (state) { case ClientState.Disconnected: PhotonServer.CallConnect(); break; case ClientState.PeerCreated: break; case ClientState.Authenticating: _sceneDescription.UI.MenuUI.gameObject.SetActive(false); break; case ClientState.Authenticated: break; case ClientState.JoinedLobby: //PhotonServer.ConnectToRandomRoom(); break; case ClientState.DisconnectingFromMasterserver: break; case ClientState.ConnectingToGameserver: break; case ClientState.ConnectedToGameserver: break; case ClientState.Joining: break; case ClientState.Joined: break; case ClientState.Leaving: break; case ClientState.DisconnectingFromGameserver: break; case ClientState.ConnectingToMasterserver: break; case ClientState.Disconnecting: break; case ClientState.ConnectedToMasterserver: PhotonServer.ConnectToRandomRoom(); break; case ClientState.ConnectingToNameServer: break; case ClientState.ConnectedToNameServer: break; case ClientState.DisconnectingFromNameServer: break; } }
void client_PacketReceived(object sender, PacketReceivedEventArgs data) { if (data.Protocol == ProtocolType.Tcp) { switch (data.Packet.PacketType) { case PacketType.Connect: switch (data.Packet.Content) { case "FULL": MessageBox.Show("The Server you were trying to join is full.", "Server full"); clientState = ClientState.Disconnected; break; case "UNAVAILABLE": MessageBox.Show("The chosen Nickname is already in use.", "Nickname unavailable"); clientState = ClientState.Disconnected; break; default: string[] players = data.Packet.Content.Split('|'); foreach (string player in players) { AddPlayer(player); } clientState = ClientState.Connected; SetStatus("Connected"); break; } break; case PacketType.PowerUp: dataGridPlayers.Invoke(new MethodInvoker(() => { MessageBox.Show(data.Packet.Content); })); break; case PacketType.Race: string[] packetPart = data.Packet.Content.Split('|'); gameClient.SetupRace(Int32.Parse(packetPart[0]), Int32.Parse(packetPart[1])); break; case PacketType.Join: AddPlayer(data.Packet.Content); break; case PacketType.Disconnect: if (data.Packet.Content == participant.Nickname) { client.Disconnect(); participants.Clear(); UpdateList(); clientState = ClientState.Disconnected; SetStatus("Not Connected"); MessageBox.Show("You were disconnected by the server","Disconnected"); } else { RemovePlayer(data.Packet.Content); } break; } } else if (data.Protocol == ProtocolType.Udp) { string[] responseParts = data.Packet.Content.Split('|'); Library.Settings.Unserialize(responseParts[0]); /*bool updateList = false; if (responseParts.Count() - 1 != playerCount) { // New player, add it to the list updateList = true; playerCount = responseParts.Count() - 1; foreach (string responsePlayer in responseParts.Skip(1)) { string[] playerPart = responsePlayer.Split(';'); var existingPlayer = from p in participants where p.Nickname == playerPart[0] select p; if (existingPlayer == null || existingPlayer.Count() == 0) { participants.Add(new Participant() { Nickname = playerPart[0], X = float.Parse(playerPart[1]), Y = float.Parse(playerPart[2]), Z = float.Parse(playerPart[3]), SpeedX = float.Parse(playerPart[4]), SpeedY = float.Parse(playerPart[5]), SpeedZ = float.Parse(playerPart[6]), VectorX1 = float.Parse(playerPart[7]), VectorY1 = float.Parse(playerPart[8]), VectorZ1 = float.Parse(playerPart[9]), VectorX2 = float.Parse(playerPart[10]), VectorY2 = float.Parse(playerPart[11]), VectorZ2 = float.Parse(playerPart[12]), PowerUpType = int.Parse(playerPart[13]), PowerUpWhiteBricks = int.Parse(playerPart[14]) }); } else { participant.X = float.Parse(playerPart[1]); participant.Y = float.Parse(playerPart[2]); participant.Z = float.Parse(playerPart[3]); participant.SpeedX = float.Parse(playerPart[4]); participant.SpeedY = float.Parse(playerPart[5]); participant.SpeedZ = float.Parse(playerPart[6]); participant.VectorX1 = float.Parse(playerPart[7]); participant.VectorY1 = float.Parse(playerPart[8]); participant.VectorZ1 = float.Parse(playerPart[9]); participant.VectorX2 = float.Parse(playerPart[10]); participant.VectorY2 = float.Parse(playerPart[11]); participant.VectorZ2 = float.Parse(playerPart[12]); participant.PowerUpType = int.Parse(playerPart[13]); participant.PowerUpWhiteBricks = int.Parse(playerPart[14]); } } } else {*/ foreach (string responsePlayer in responseParts.Skip(1)) { string[] playerPart = responsePlayer.Split(';'); var foundPlayers = from p in participants where p.Nickname == playerPart[0] select p; if (foundPlayers != null && foundPlayers.Count() == 1) { Participant foundPlayer = foundPlayers.First(); foundPlayer.X = float.Parse(playerPart[1]); foundPlayer.Y = float.Parse(playerPart[2]); foundPlayer.Z = float.Parse(playerPart[3]); foundPlayer.SpeedX = float.Parse(playerPart[4]); foundPlayer.SpeedY = float.Parse(playerPart[5]); foundPlayer.SpeedZ = float.Parse(playerPart[6]); foundPlayer.VectorX1 = float.Parse(playerPart[7]); foundPlayer.VectorY1 = float.Parse(playerPart[8]); foundPlayer.VectorZ1 = float.Parse(playerPart[9]); foundPlayer.VectorX2 = float.Parse(playerPart[10]); foundPlayer.VectorY2 = float.Parse(playerPart[11]); foundPlayer.VectorZ2 = float.Parse(playerPart[12]); foundPlayer.PowerUpType = int.Parse(playerPart[13]); foundPlayer.PowerUpWhiteBricks = int.Parse(playerPart[14]); } } //} /*if (updateList) { dataGridPlayers.Invoke(new MethodInvoker(() => { dataGridPlayers.DataSource = participants.ToList(); dataGridPlayers.Columns[1].Visible = false; dataGridPlayers.Columns[2].Visible = false; })); }*/ foreach (Participant enemy in participants.Where(p => p.Nickname != participant.Nickname)) { /*if (powerUpsUsed[i] != enemy.PowerUpsUsed) { powerUpsUsed[i] = enemy.PowerUpsUsed; //gameClient.UsePowerUp(enemy.PowerUpType, enemy.PowerUpWhiteBricks, i + 1); }*/ gameClient.Opponents[0].X = enemy.X; gameClient.Opponents[0].Y = enemy.Y; gameClient.Opponents[0].Z = enemy.Z; gameClient.Opponents[0].SpeedX = enemy.SpeedX; gameClient.Opponents[0].SpeedY = enemy.SpeedY; gameClient.Opponents[0].SpeedZ = enemy.SpeedZ; gameClient.Opponents[0].VectorX1 = enemy.VectorX1; gameClient.Opponents[0].VectorY1 = enemy.VectorY1; //opponents[0].VectorZ1 = enemy.VectorZ1; gameClient.Opponents[0].VectorX2 = enemy.VectorX2; gameClient.Opponents[0].VectorY2 = enemy.VectorY2; //opponents[0].VectorZ2 = enemy.VectorZ2; //if (GetActiveWindowTitle() == "LEGO Racers") //{ // g.DrawString("Knoest:\nX: " + enemy.X + "\nY: " + enemy.Y + "\nZ: " + enemy.Z, font, brush, new PointF(20, 20)); //} break; } } }
private void ClientForm_Load(object sender, EventArgs e) { try { engineInitialized = false; sentLastUsedPowerUp = true; powerUpsUsed = new int[5]; for (int i = 0; i < 5; i++) { powerUpsUsed[i] = 0; } gameClient = GameClientFactory.GetGameClient(gameProcess); gameClient.Initialized += gameClient_Initialized; participants = new List<Participant>(); // Set the amount of players to zero playerCount = 0; // Create a new Player object that is going to hold the local Player information participant = new Participant() { Nickname = "Player" }; if (!Toolbox.IsAdministrator()) { throw new Win32Exception(); } for (int i = 0; i < dataGridPlayers.Columns.Count; i++) { dataGridPlayers.Columns[i].Visible = false; } mainModule = gameProcess.MainModule; memoryManager = new MemoryManager(gameProcess); //codeInjector = new CodeInjector(memoryManager); SetStatus("Not Connected"); clientState = ClientState.Disconnected; // Creates and starts a new thread that will be responsible for updating the client thread = new Thread(UpdateClient); thread.Start(); } catch (Win32Exception) { // The Client was (probably) not started with Administrator rights MessageBox.Show("Error while finding LEGO Racers process. Please restart the application with Administrator rights.", "Error"); Close(); } catch (Exception exc) { // An unknown error occured ErrorHandler.ShowDialog("Failed to initialize", "The Client failed to initialize.", exc); Close(); } }
public static void Connected() { state = ClientState.Online; gameForm.Invoke(new Action<Form>(x => x.Show()), gameForm); Context.MainForm = gameForm; regForm.Invoke(new Action<Form>(x => x.Hide()), regForm); }
public static void Disconnected() { state = ClientState.Offline; var old = Context.MainForm; Context.MainForm = regForm; Context.MainForm.Invoke(new Action<Form>(x => x.Show()), regForm); old.Invoke(new Action<Form>(x => x.Hide()), old); }
public static void StartGame(StartGameMessage message) { state = ClientState.Gaming; gameForm.ReDraw(message.you, message.enemy, message.turn); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); state = ClientState.Offline; serverManager = new ServerManager(); regForm = new RegForm(); gameForm = new GameForm(); var i = gameForm.Handle; Context = new ApplicationContext(regForm); Application.Run(Context); }
public static void SendGame(SearchMessage message) { state = ClientState.Waiting; serverManager.SendMessage(message); }
private void connectToolStripMenuItem_Click(object sender, EventArgs e) { if (clientState == ClientState.Disconnected) { try { using (ConnectForm connectForm = new ConnectForm()) { // THIS IS CONFIRMED TO WORK! //float playerBase = codeInjector.ReadFloat(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(0x004C67BC) + 0x60) + 0xA8) + 0x114) + 0x40) + 0x130); //Console.WriteLine(playerBase); connectForm.ShowDialog(); participant.Nickname = connectForm.Nickname; client = new Client(); client.PacketReceived += client_PacketReceived; client.Connect(IPAddress.Parse(connectForm.Server), 3031, 3030); client.Send(ProtocolType.Tcp, new Packet() { PacketType = PacketType.Connect, Content = connectForm.Nickname }); clientState = ClientState.Connecting; /*if (connectForm.Server != null && connectForm.Nickname != null) { ipEndPoint = new IPEndPoint(IPAddress.Parse(connectForm.Server), 3030); tcpClient.Connect(new IPEndPoint(IPAddress.Parse(connectForm.Server), 3031)); stream = tcpClient.GetStream(); Packet packet = new Packet() { PacketType = PacketType.Connect, Content = connectForm.Nickname }; stream.Write(packet.ToBytes(), 0, packet.Length); listenerThread.Start(); /* client = new UdpClient(); client.Connect(ipEndPoint); Packet packet = SendPacket(new Packet() { PacketType = PacketType.Nickname, Content = connectForm.Nickname }); if (packet.PacketType != PacketType.Nickname || packet.Content != "OK") { MessageBox.Show("An error occured during the handshake with the Server. A response was received, but the Server rejected your request. Please try again.", "Error while handshaking"); } else { participants = new List<Participant>(); playerCount = 0; participant.Nickname = connectForm.Nickname; clientState = ClientState.Connected; SetStatus("Connected (" + connectForm.Server + ")"); } }*/ } } catch (Exception exc) { ErrorHandler.ShowDialog("Connect dialog failed to load", "The connect dialog failed to load.", exc); } } else { MessageBox.Show("Disconnect from the current game to connect to a new game.","Already connected"); } }
public ClientController(ClientState state) { this.state = state; Network.Instance.DataReady += new Network.DataReadyDelegate(OnReceived); Network.Instance.LoginComplete += new Network.LoginCompleteDelegate(OnLogin); }
private void disconnectToolStripMenuItem_Click(object sender, EventArgs e) { if (clientState == ClientState.Connected) { client.Send(ProtocolType.Tcp, new Packet() { PacketType = PacketType.Disconnect, Content = participant.Nickname }); client.Disconnect(); participants.Clear(); UpdateList(); clientState = ClientState.Disconnected; SetStatus("Not Connected"); } }
public void initialize(int port, string id) { ClientState = new ClientState(port, id); Console.Title = "Client " + id; //atach a debugger - we should add some parameter to enable/disable this! if (Boolean.Parse(Properties.Resources.RUN_IN_DEBUG_MODE) && !Debugger.IsAttached) { Debugger.Launch(); } }