Procházet zdrojové kódy

关卡SocketPlayer初始化

lvjincheng před 4 roky
rodič
revize
7dc52d2953

+ 3 - 8
Assets/BowArrow/Scripts/Manager/GameMode/RabbitHuntGameMode_OnlinePK.cs

@@ -169,16 +169,11 @@ public class RabbitHuntGameMode_OnlinePK : RabbitHuntGameMode, ChallengeGameMode
         public bool gameEnd = false;
 
         public void InitSocketPlayer(Action successCallback) {
-            if (GameObject.Find("SocketPlayer") == null) {
-                PKMatchingView.MoniMatchForTestInGameScene(() => {
-                    myPlayerIndex = GlobalData.playerIndexInRoom;
-                    if (successCallback != null) successCallback();
-                });
-            } else {
+            socketPlayer = SocketPlayer.NewInstance();
+            socketPlayer.onRoomReadyComplete = () => {
                 myPlayerIndex = GlobalData.playerIndexInRoom;
                 if (successCallback != null) successCallback();
-            }
-            socketPlayer = GameObject.Find("SocketPlayer").GetComponent<SocketPlayer>();
+            };
             socketPlayer.onReceivePKGameData = onReceivePKGameData;
             AutoSwitchBanUserControlBow();
             JC.Unity.CoroutineStarter.Start(CheckAndUpload());

+ 3 - 8
Assets/BowArrow/Scripts/Manager/GameMode/YejiHuntGameMode_OnlinePK.cs

@@ -170,16 +170,11 @@ public class YejiHuntGameMode_OnlinePK : YejiHuntGameMode, ChallengeGameModeLoca
         public bool gameEnd = false;
 
         public void InitSocketPlayer(Action successCallback) {
-            if (GameObject.Find("SocketPlayer") == null) {
-                PKMatchingView.MoniMatchForTestInGameScene(() => {
-                    myPlayerIndex = GlobalData.playerIndexInRoom;
-                    if (successCallback != null) successCallback();
-                });
-            } else {
+            socketPlayer = SocketPlayer.NewInstance();
+            socketPlayer.onRoomReadyComplete = () => {
                 myPlayerIndex = GlobalData.playerIndexInRoom;
                 if (successCallback != null) successCallback();
-            }
-            socketPlayer = GameObject.Find("SocketPlayer").GetComponent<SocketPlayer>();
+            };
             socketPlayer.onReceivePKGameData = onReceivePKGameData;
             AutoSwitchBanUserControlBow();
             JC.Unity.CoroutineStarter.Start(CheckAndUpload());