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 override void OnLevelLoaded(LoadMode mode) { //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "OnLevelLoaded()"); TurnData.loadTurnData(); ClientData.loadData(); //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, ClientData.hostIP + "turnDuration: " + HostConfigData.turnDuration + " turn: " +HostConfigData.turn + " player name: " + HostConfigData.playerTurnName ); if (ClientData.hostIP == "0.0.0.0") { PMThreading.PMActive = false; return; } HostConfigData.fetchRemoteData(ClientData.name, ClientData.code, ClientData.hostIP); if (HostConfigData.playerTurnName == ClientData.name || HostConfigData.turn == 0) { //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "PMActive == true"); PMThreading.PMActive = true; } else { //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "PMActive == false"); PMThreading.PMActive = false; } }
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()); } }