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