12345678910111213141516171819202122232425262728293031323334353637383940414243 |
-
- String s_map[]; //send this via tcp
- int i_citizenTransferC;
- void clientCommunication() {
- client = server.available();
- if (client != null) {
- s_fromClient = client.readString();
- if (s_fromClient.equals("give citizenC")) {
- client.write(str(citizen.length));
- }
- if (s_fromClient.equals("give citizen")) {
- if(i_citizenTransferC >= citizen.length) i_citizenTransferC = 0;
- 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);
- i_citizenTransferC++;
- }
- if (s_fromClient.contains("give locx")) {
- String[] list = split(s_fromClient, ':');
- int requestedCitizen = int(list[1]);
- client.write(str(citizen[requestedCitizen].f_xPos/i_sMapReso));
- }
- if (s_fromClient.contains("give locy")) {
- String[] list = split(s_fromClient, ':');
- int requestedCitizen = int(list[1]);
- client.write(str(citizen[requestedCitizen].f_yPos/i_sMapReso));
- }
- if (s_fromClient.contains("give a")) {
- String[] list = split(s_fromClient, ':');
- int requestedCitizen = int(list[1]);
- client.write(str(citizen[requestedCitizen].f_angle));
- }
- if (s_fromClient.equals("give mapw")) {
- client.write(str(img_houses.width/i_sMapReso));
- }
- if (s_fromClient.equals("give maph")) {
- client.write(str(img_houses.height/i_sMapReso));
- }
- if (i_mapLevelTransferC >= img_houses.height/i_sMapReso) i_mapLevelTransferC = 0;
- if (s_fromClient.equals("give map")) {
- client.write(s_map[i_mapLevelTransferC]);
- i_mapLevelTransferC++;
- }
- }
- }
|