void SendLocalPlayerData() { UnitBase localPlayer = PlayerController.Instance.localPlayer; if (localPlayer) { // send data at least once in two seconds if (PlayerController.Instance.HasCommand() || Time.time - lastTimestamp > 0.1) { localPlayer.ValidatePlayerData(); PlayerUpdateMsg puMsg = new PlayerUpdateMsg(clientId, localPlayer.GetPlayerData(), PlayerController.Instance.PopCommands()); SendToServer(JsonUtility.ToJson(puMsg)); } } }
void SendLocalPlayerData() { UnitBase localPlayer = PlayerController.Instance.localPlayer; if (localPlayer) { // send data at least once in a second if (PlayerController.Instance.IsDirtyFlag || (Time.time - lastTimestamp > 2.0)) { PlayerUpdateMsg puMsg = new PlayerUpdateMsg(localPlayer.GetPlayerData()); SendToServer(JsonUtility.ToJson(puMsg)); PlayerController.Instance.ClearDirtyFlag(); } } }