public override void OnCreated(ILoading loading) { //asks the server about who's turn is it right now ClientData.loadData(); TurnData.loadTurnData(); if (ClientData.hostIP != "0.0.0.0") { try { HostConfigData.fetchRemoteData(ClientData.name, ClientData.code, ClientData.hostIP); if (HostConfigData.playerTurnName == ClientData.name && !TurnData.saveFetched) { PseudoMultiplayer.receiveSaveFromServer(); } } catch { ClientData.connectedToHost = false; ClientData.saveData(); } if (HostConfigData.playerTurnName == ClientData.name) { } } }
public void askTurn(UIHelperBase group) { ClientData.loadData(); TurnData.loadTurnData(); try { HostConfigData.fetchRemoteData(ClientData.name, ClientData.code, ClientData.hostIP); } catch (Exception e) { group.AddTextfield("No Response from server!", e.Message, (value) => doNothing()); ClientData.connectedToHost = false; ClientData.saveData(); return; } if (HostConfigData.playerTurnName == ClientData.name) { if (HostConfigData.playerTurnName == ClientData.name && !TurnData.saveFetched) { PseudoMultiplayer.receiveSaveFromServer(); group.AddTextfield("Response from server: ", "Yes it is. An up to date save was retrieved from host into save name: " + ClientData.SAVE_FILE_NAME + "_received.crp", (value) => doNothing()); } else { group.AddTextfield("Response from server: ", "Yes it is.", (value) => doNothing()); } } else if (HostConfigData.playerTurnName == "First turn") { group.AddTextfield("Response from server:", "As it is the first turn it is up to the players to decide.", (value) => doNothing()); } else { group.AddTextfield("Response from server: ", "Nope. It is player " + HostConfigData.playerTurnName + "'s turn.", (value) => doNothing()); } }