|
|
@@ -20,6 +20,10 @@ public class SocketPlayer : JC.SocketIO.SocketIOClient
|
|
|
base.OnDestroy();
|
|
|
}
|
|
|
void DestroySelf() {
|
|
|
+ if (willTryAgain) {
|
|
|
+ willTryAgain = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (gameObject) Destroy(gameObject);
|
|
|
}
|
|
|
|
|
|
@@ -98,10 +102,15 @@ public class SocketPlayer : JC.SocketIO.SocketIOClient
|
|
|
//上传游戏数据
|
|
|
public void UploadPKGameData(string key, object data) {
|
|
|
if (!isValid) return;
|
|
|
- call("UploadPKGameData", key, data);
|
|
|
+ call("UploadPKGameData", repeatID.ToString() + key, data);
|
|
|
}
|
|
|
public Action<string, string> onReceivePKGameData;
|
|
|
public void OnReceivePKGameData(string key, string data) {
|
|
|
+ if (key.StartsWith(repeatID_str)) {
|
|
|
+ key = key.Substring(repeatID_str.Length);
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
onReceivePKGameData?.Invoke(key, data);
|
|
|
}
|
|
|
//创建好友PK房间
|
|
|
@@ -116,4 +125,21 @@ public class SocketPlayer : JC.SocketIO.SocketIOClient
|
|
|
public void JoinFriendPKRoom(int roomID) {
|
|
|
call("JoinFriendPKRoom", roomID);
|
|
|
}
|
|
|
+ //再来一次
|
|
|
+ bool willTryAgain = false;
|
|
|
+ int repeatID = 0;
|
|
|
+ string repeatID_str = "0";
|
|
|
+ public void TryAgain(string sceneName) {
|
|
|
+ willTryAgain = true;
|
|
|
+ repeatID++;
|
|
|
+ repeatID_str = repeatID.ToString();
|
|
|
+ call("TryAgain", repeatID_str, sceneName);
|
|
|
+ }
|
|
|
+ public void OnTryAgain(string repeatID_s, string sceneName) {
|
|
|
+ if (repeatID_str == repeatID_s) return;
|
|
|
+ repeatID = int.Parse(repeatID_s);
|
|
|
+ repeatID_str = repeatID_s;
|
|
|
+ willTryAgain = true;
|
|
|
+ SceneManager.LoadScene(sceneName, LoadSceneMode.Single);
|
|
|
+ }
|
|
|
}
|