Sfoglia il codice sorgente

socket标记gameover

lvjincheng 4 anni fa
parent
commit
3da3fed96d

+ 3 - 0
Assets/BowArrow/Scenes/GameChallengeScene/HunterGameSettleView.cs

@@ -42,6 +42,9 @@ public class HunterGameSettleView : MonoBehaviour
                 UserPlayer.ins.call("rankComp.uploadGameScore", GameMgr.gameType, score);
             } catch (System.Exception e) { Debug.LogError(e.Message); }
         }
+        if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
+            if (SocketPlayer.ins) SocketPlayer.ins.isGameOver = true;
+        }
     }
 
     void CheckOpenNextLevelBtn(ChallengeGameMode gameMode, string gameRes) {

+ 0 - 3
Assets/BowArrow/Scripts/Manager/GameMode/PKGameMode_OnlinePK.cs

@@ -168,9 +168,6 @@ public class PKGameMode_OnlinePK : GameMode {
         }
         upload2();
         gameDisplay.Update(this);
-        if (this.gameLogic.gameEnd) {
-            socketPlayer.canBackHome = false;
-        }
     }
     Dictionary<int, ArrowSync> arrowSyncMap = new Dictionary<int, ArrowSync>();
     void upload1() {

+ 5 - 2
Assets/BowArrow/Scripts/Network/SocketPlayer.cs

@@ -55,12 +55,11 @@ public class SocketPlayer : JC.SocketIO.SocketIOClient
         Debug.Log("onReload");
     }
     public Action onDestroy_;
-    [NonSerialized] public bool canBackHome = true;
     public override void onDestroy()
     {
         Debug.Log("onDestroy");
         onDestroy_?.Invoke();
-        if (canBackHome && UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.StartsWith("Game") && !openInGameScene) {
+        if (!isGameOver && UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.StartsWith("Game") && !openInGameScene) {
             PopupMgr.ins.ShowBGTip("某方退出或掉线,联机游戏终止!");
             SceneManager.LoadScene("Home", LoadSceneMode.Single);
         }
@@ -125,11 +124,14 @@ public class SocketPlayer : JC.SocketIO.SocketIOClient
     public void JoinFriendPKRoom(int roomID) {
         call("JoinFriendPKRoom", roomID);
     }
+    //游戏结束标记
+    [NonSerialized] public bool isGameOver = false;
     //再来一次
     bool willTryAgain = false;
     int repeatID = 0;
     string repeatID_str = "0";
     public void TryAgain(string sceneName) {
+        isGameOver = false;
         willTryAgain = true;
         repeatID++;
         repeatID_str = repeatID.ToString();
@@ -140,6 +142,7 @@ public class SocketPlayer : JC.SocketIO.SocketIOClient
         repeatID = int.Parse(repeatID_s);
         repeatID_str = repeatID_s;
         willTryAgain = true;
+        isGameOver = false;
         SceneManager.LoadScene(sceneName, LoadSceneMode.Single);
     }
 }

+ 3 - 0
Assets/BowArrow/Scripts/View/PKGameSettleView.cs

@@ -50,6 +50,9 @@ public class PKGameSettleView : MonoBehaviour
                 UserPlayer.ins.call("rankComp.uploadGameScore", GameMgr.gameType, score);
             } catch (System.Exception e) { Debug.LogError(e.Message); }
         }
+        if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
+            if (SocketPlayer.ins) SocketPlayer.ins.isGameOver = true;
+        }
     }
 
     public void GoHome() {