Simulation von Bürgern
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Server.pde 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. String s_map[]; //send this via tcp
  2. int i_citizenTransferC;
  3. void clientCommunication() {
  4. client = server.available();
  5. if (client != null) {
  6. s_fromClient = client.readString();
  7. if (s_fromClient.equals("give citizenC")) {
  8. client.write(str(citizen.length));
  9. }
  10. if (s_fromClient.equals("give citizen")) {
  11. if(i_citizenTransferC >= citizen.length) i_citizenTransferC = 0;
  12. client.write("Name: " + citizen[i_citizenTransferC].s_name + ", Gender: " + citizen[i_citizenTransferC].s_gender + ", Age: " + str(citizen[i_citizenTransferC].i_age) + ", Currently doing: " + citizen[i_citizenTransferC].s_currentAction);
  13. i_citizenTransferC++;
  14. }
  15. if (s_fromClient.contains("give locx")) {
  16. String[] list = split(s_fromClient, ':');
  17. int requestedCitizen = int(list[1]);
  18. client.write(str(citizen[requestedCitizen].f_xPos/i_sMapReso));
  19. }
  20. if (s_fromClient.contains("give locy")) {
  21. String[] list = split(s_fromClient, ':');
  22. int requestedCitizen = int(list[1]);
  23. client.write(str(citizen[requestedCitizen].f_yPos/i_sMapReso));
  24. }
  25. if (s_fromClient.contains("give a")) {
  26. String[] list = split(s_fromClient, ':');
  27. int requestedCitizen = int(list[1]);
  28. client.write(str(citizen[requestedCitizen].f_angle));
  29. }
  30. if (s_fromClient.equals("give mapw")) {
  31. client.write(str(img_houses.width/i_sMapReso));
  32. }
  33. if (s_fromClient.equals("give maph")) {
  34. client.write(str(img_houses.height/i_sMapReso));
  35. }
  36. if (i_mapLevelTransferC >= img_houses.height/i_sMapReso) i_mapLevelTransferC = 0;
  37. if (s_fromClient.equals("give map")) {
  38. client.write(s_map[i_mapLevelTransferC]);
  39. i_mapLevelTransferC++;
  40. }
  41. }
  42. }