|
|
@@ -1,4 +1,5 @@
|
|
|
using System.Collections.Generic;
|
|
|
+using UnityEngine;
|
|
|
|
|
|
|
|
|
public class PKComp : Singleton<PKComp>
|
|
|
@@ -12,9 +13,9 @@ public class PKComp : Singleton<PKComp>
|
|
|
UserPlayer.ins.call("pkComp.cancelRandomMatch", LoginMgr.myUserInfo.id);
|
|
|
}
|
|
|
|
|
|
- public void inviteFriendGamePK(int targetID) {
|
|
|
+ public void inviteFriendGamePK(int targetID, string inviterViewUUID) {
|
|
|
MatchPlayerInfo playerInfo = CreateMyMatchPlayerInfo();
|
|
|
- UserPlayer.ins.call("pkComp.inviteFriendGamePK", playerInfo, GlobalData.matchGameType, targetID);
|
|
|
+ UserPlayer.ins.call("pkComp.inviteFriendGamePK", playerInfo, GlobalData.matchGameType, targetID, inviterViewUUID);
|
|
|
}
|
|
|
|
|
|
public void acceptFriendGamePK(string roomKey) {
|
|
|
@@ -22,12 +23,16 @@ public class PKComp : Singleton<PKComp>
|
|
|
UserPlayer.ins.call("pkComp.acceptFriendGamePK", playerInfo, roomKey);
|
|
|
}
|
|
|
|
|
|
- public void inviteOtherTryAgainGamePK() {
|
|
|
+ public void inviteOtherTryAgainGamePK(string inviterViewUUID) {
|
|
|
//get other info
|
|
|
int otherIndex = (GlobalData.playerIndexInRoom + 1) % 2;
|
|
|
MatchPlayerInfo ohterInfo = GlobalData.matchPlayerInfos[otherIndex];
|
|
|
MatchPlayerInfo playerInfo = CreateMyMatchPlayerInfo();
|
|
|
- UserPlayer.ins.call("pkComp.inviteOtherTryAgainGamePK", playerInfo, GlobalData.matchGameType, ohterInfo.playerID);
|
|
|
+ UserPlayer.ins.call("pkComp.inviteOtherTryAgainGamePK", playerInfo, GlobalData.matchGameType, ohterInfo.playerID, inviterViewUUID);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void rejectPKInvite(string roomKey) {
|
|
|
+ UserPlayer.ins.call("pkComp.rejectPKInvite", roomKey);
|
|
|
}
|
|
|
|
|
|
public void acceptOtherTryAgainGamePK(string roomKey) {
|
|
|
@@ -65,8 +70,11 @@ public class PKComp : Singleton<PKComp>
|
|
|
PopupMgr.ins.ShowTip("当前正处于匹配状态,无法接受好友PK邀请!");
|
|
|
}
|
|
|
};
|
|
|
+ System.Action cbCancel = delegate() {
|
|
|
+ rejectPKInvite(roomKey);
|
|
|
+ };
|
|
|
if (CanShowFriendInviteOrMatch()) {
|
|
|
- PopupMgr.ins.ShowPKInviteNotice(matchPlayerInfo.avatarID, matchPlayerInfo.nickname, tip, cb);
|
|
|
+ PopupMgr.ins.ShowPKInviteNotice(matchPlayerInfo.avatarID, matchPlayerInfo.nickname, tip, cb, cbCancel, cbCancel);
|
|
|
}
|
|
|
}
|
|
|
public void onInviteOtherTryAgainGamePK(MatchPlayerInfo matchPlayerInfo, int gameType, string roomKey) {
|
|
|
@@ -84,11 +92,22 @@ public class PKComp : Singleton<PKComp>
|
|
|
PopupMgr.ins.ShowTip("目前状态下,无法接受该邀请!");
|
|
|
}
|
|
|
};
|
|
|
+ System.Action cbCancel = delegate() {
|
|
|
+ rejectPKInvite(roomKey);
|
|
|
+ };
|
|
|
if (CanShowTryAgainInviteOrMatch(matchPlayerInfo)) {
|
|
|
- PopupMgr.ins.ShowPKInviteNotice(matchPlayerInfo.avatarID, matchPlayerInfo.nickname, tip, cb);
|
|
|
+ PopupMgr.ins.ShowPKInviteNotice(matchPlayerInfo.avatarID, matchPlayerInfo.nickname, tip, cb, cbCancel, cbCancel);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void onRejectPKInvite(string inviterViewUUID) {
|
|
|
+ PopupMgr.ins.ShowTip("对方拒绝了你的邀请");
|
|
|
+ PKMatchingView view = PKMatchingView.ins;
|
|
|
+ if (!view) return;
|
|
|
+ if (view.viewUUID != inviterViewUUID) return;
|
|
|
+ view.eventOnRejectPKInvite?.Invoke();
|
|
|
+ }
|
|
|
+
|
|
|
//内部方法
|
|
|
private string GetPKTypeName(int gameType) {
|
|
|
string pkTypeName = null;
|