lvjincheng 4 vuotta sitten
vanhempi
sitoutus
11d239958a
1 muutettua tiedostoa jossa 5 lisäystä ja 15 poistoa
  1. 5 15
      Assets/BowArrow/Scripts/Manager/GameMode/PKGameMode_OnlinePK.cs

+ 5 - 15
Assets/BowArrow/Scripts/Manager/GameMode/PKGameMode_OnlinePK.cs

@@ -18,16 +18,12 @@ public class PKGameMode_OnlinePK : GameMode {
     public PKGameMode_OnlinePK(GameMgr gameMgr) : base(gameMgr) {
         GlobalData.pkMatchType = PKMatchType.OnlinePK;
 
-        bool hasSocketPlayer = false;
-        if (GameObject.Find("SocketPlayer") == null) {
-            PKMatchingView.MoniMatchForTestInGameScene(() => {
-                myPlayerIndex = GlobalData.playerIndexInRoom;
-                ToInitGameView(); 
-            });
-        } else {
-            hasSocketPlayer = true;
+        socketPlayer = SocketPlayer.NewInstance();
+        socketPlayer.onRoomReadyComplete = () => {
             myPlayerIndex = GlobalData.playerIndexInRoom;
-        }
+            ToInitGameView();
+        };
+        socketPlayer.onReceivePKGameData = onReceivePKGameData;
 
         gameLogic.InitAppearPlayerIndexes();
         gameLogic.SetCurrentPlayerIndexToNext();
@@ -35,16 +31,10 @@ public class PKGameMode_OnlinePK : GameMode {
         //记录可射击的靶子
         targetBody = GameObject.Find("GameArea/TargetObject/TargetBody").GetComponent<TargetBody>();
         GameObject.FindObjectOfType<ArmBow>().validTargets.Add(targetBody);
-        if (hasSocketPlayer) {
-            ToInitGameView();
-        }
         //禁止动作-相机和手臂
         BanBowReady();
 
         AutoSwitchBanUserControlBow();
-
-        socketPlayer = GameObject.Find("SocketPlayer").GetComponent<SocketPlayer>();
-        socketPlayer.onReceivePKGameData = onReceivePKGameData;
     }
     
     void ToInitGameView() {