Forráskód Böngészése

好友PK邀请前端场景合法校验

lvjincheng 4 éve
szülő
commit
fb16544602

+ 6 - 2
Assets/BowArrow/Scripts/Network/UserPlayer.cs

@@ -100,14 +100,18 @@ public class UserPlayer : JCEntity
         string pkTypeName = pkTypeNames[roomType];
         string tip = $"好友邀请你参加{pkTypeName}PK";
         System.Action cb = delegate() {
-            if (SceneManager.GetActiveScene().name == "Home") {
+            if (!PKMatchingView.ins && SceneManager.GetActiveScene().name == "Home") {
                 PKMatchingView view = PKMatchingView.Create();
                 view.isFriendPKInvitee = true;
                 view.targetJoinRoomID = roomID;
                 GlobalData.pkMatchType = PKMatchType.OnlinePK;
                 GlobalData.matchRoomType = roomType;
+            } else if (PKMatchingView.ins) {
+                PopupMgr.ins.ShowTip("当前正处于匹配状态,无法接受好友PK邀请!");
             }
         };
-        PopupMgr.ins.ShowPKInviteNotice(avatarID, nickname, tip, cb);
+        if (!PKMatchingView.ins && SceneManager.GetActiveScene().name == "Home") {
+            PopupMgr.ins.ShowPKInviteNotice(avatarID, nickname, tip, cb);
+        }
     }
 }

+ 10 - 0
Assets/BowArrow/Scripts/View/PKMatchingView.cs

@@ -26,6 +26,16 @@ public class PKMatchingView : MonoBehaviour
         return o.GetComponent<PKMatchingView>();
     }
 
+    public static PKMatchingView ins;
+
+    public void Awake() {
+        ins = this;
+    }
+
+    public void OnDestroy() {
+        if (ins == this) ins = null;
+    }
+
     void Start()
     {
         Sprite avatar = RoleMgr.GetAvatar(LoginMgr.myUserInfo.avatarID);