| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using System; |
| | | using TableConfig; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | public class TeamModel : Model, IAfterPlayerDataInitialize, ISwitchAccount, IPlayerLoginOk |
| | | { |
| | | public const int NONE_MISSION = 0; |
| | | public const int CURRENTMAP_MISSION = 1; |
| | | |
| | | bool serverInited = false; |
| | | FriendsModel friendsModel { get { return ModelCenter.Instance.GetModel<FriendsModel>(); } } |
| | | DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } } |
| | | |
| | | public bool autoAcceptApplication { |
| | | get { return (PlayerDatas.Instance.baseData.ExAttr2 / 10) % 10 == 0; } |
| | | set { |
| | | var sendInfo = new CB904_tagCMChangeTeamCheckState(); |
| | | sendInfo.JoinReqCheck = (byte)(value ? 0 : 1); |
| | | sendInfo.InviteCheck = (byte)(autoAcceptInvitation ? 0 : 1); |
| | | GameNetSystem.Instance.SendInfo(sendInfo); |
| | | } |
| | | } |
| | | |
| | | public bool autoAcceptInvitation { |
| | | get { return PlayerDatas.Instance.baseData.ExAttr2 % 10 == 0; } |
| | | set { |
| | | if ((PlayerDatas.Instance.baseData.ExAttr2 % 10 == 0) != value) |
| | | { |
| | | var sendInfo = new CB904_tagCMChangeTeamCheckState(); |
| | | sendInfo.InviteCheck = (byte)(value ? 0 : 1); |
| | | sendInfo.JoinReqCheck = (byte)(autoAcceptApplication ? 0 : 1); |
| | | GameNetSystem.Instance.SendInfo(sendInfo); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public List<TheirTeam> theirTeams = new List<TheirTeam>(); |
| | | public List<TeamInvitation> invitations = new List<TeamInvitation>(); |
| | | public List<TeamApplication> applications = new List<TeamApplication>(); |
| | | public List<TeamInvite> invites = new List<TeamInvite>(); |
| | | public Dictionary<int, List<int>> teammissions = new Dictionary<int, List<int>>(); |
| | | public Dictionary<int, TeamTargetPreference> targetPreferences = new Dictionary<int, TeamTargetPreference>(); |
| | | |
| | | MyTeam m_MyTeam = new MyTeam(); |
| | | public MyTeam myTeam { |
| | | get { return m_MyTeam; } |
| | | private set { m_MyTeam = value; } |
| | | } |
| | | |
| | | TeamMission m_CurrentMission; |
| | | public TeamMission currentMission { |
| | | get { return m_CurrentMission; } |
| | | set { |
| | | if (m_CurrentMission != value) |
| | | { |
| | | m_CurrentMission = value; |
| | | } |
| | | } |
| | | } |
| | | |
| | | TeamMission m_MissionBuf = new TeamMission(CURRENTMAP_MISSION, 0); |
| | | public TeamMission missionBuf { |
| | | get { return m_MissionBuf; } |
| | | set { |
| | | m_MissionBuf = value; |
| | | if (missionLevelLimitChangeEvent != null) |
| | | { |
| | | missionLevelLimitChangeEvent(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | int m_LevelMinBuf = 1; |
| | | public int levelMinBuf { |
| | | get { return m_LevelMinBuf; } |
| | | set { m_LevelMinBuf = value; } |
| | | } |
| | | |
| | | int m_LevelMaxBuf = 1; |
| | | public int levelMaxBuf { |
| | | get { return m_LevelMaxBuf; } |
| | | set { m_LevelMaxBuf = value; } |
| | | } |
| | | |
| | | TeamInviteType m_CurrentInviteType = TeamInviteType.Friend; |
| | | public TeamInviteType currentInviteType { |
| | | get { return m_CurrentInviteType; } |
| | | private set { m_CurrentInviteType = value; } |
| | | } |
| | | |
| | | int m_CurrentSelectedInvitation = 0; |
| | | public int currentSelectedInvitation { |
| | | get { return m_CurrentSelectedInvitation; } |
| | | set { |
| | | if (m_CurrentSelectedInvitation != value) |
| | | { |
| | | m_CurrentSelectedInvitation = value; |
| | | if (selectedInvitationChangeEvent != null) |
| | | { |
| | | selectedInvitationChangeEvent(value); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | Clock m_MatchingClock; |
| | | public DateTime matchingEndTime { get; private set; } |
| | | |
| | | bool m_IsMatching = false; |
| | | public bool isMatching { |
| | | get { return m_IsMatching; } |
| | | set { |
| | | if (m_IsMatching != value) |
| | | { |
| | | m_IsMatching = value; |
| | | |
| | | if (m_IsMatching == false) |
| | | { |
| | | var mapConfig = ConfigManager.Instance.GetTemplate<MapConfig>(myTeam.mission.mapId); |
| | | if (mapConfig != null && (MapType)mapConfig.MapFBType == MapType.MultipleFB) |
| | | { |
| | | if (myTeam.iamCaptainer && myTeam.memberCount >= 4) |
| | | { |
| | | GroupDungeonChallengeProcessor.Instance.GroupChallengeDungeon(myTeam.mission.mapId, myTeam.mission.mapEx, true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (m_MatchingClock != null && m_MatchingClock.isActiveAndEnabled) |
| | | { |
| | | m_MatchingClock.Stop(); |
| | | m_MatchingClock = null; |
| | | } |
| | | |
| | | if (m_IsMatching) |
| | | { |
| | | matchingEndTime = DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond * GeneralConfig.Instance.teamMatchingTimeOut); |
| | | m_MatchingClock = Clock.Create(matchingEndTime, OnMatchingCoolDownEnd); |
| | | } |
| | | |
| | | if (matchingStateChangeEvent != null) |
| | | { |
| | | matchingStateChangeEvent(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | DateTime m_PrepareBeginTime; |
| | | public DateTime prepareBeginTime { |
| | | get { return m_PrepareBeginTime; } |
| | | private set { m_PrepareBeginTime = value; } |
| | | } |
| | | |
| | | TeamPrepare m_TeamPreapare = new TeamPrepare(); |
| | | public TeamPrepare teamPrepare { |
| | | get { return m_TeamPreapare; } |
| | | private set { m_TeamPreapare = value; } |
| | | } |
| | | |
| | | public event Action myTeamRefreshEvent; |
| | | public event Action theirTeamListRefreshEvent; |
| | | public event Action missionLevelLimitChangeEvent; |
| | | public event Action createTeamEvent; |
| | | public event Action exitTeamEvent; |
| | | public event Action<int> teammateLeaveEvent; |
| | | public event Action<int> teammateJoinEvent; |
| | | public event Action<int> teammateOnOffLineEvent; |
| | | public event Action<int> teammateLevelUpEvent; |
| | | public event Action<int> teammateChangeMapEvent; |
| | | public event Action applicationsChangeEvent; |
| | | public event Action<TeamInviteType> teamInvitesUpdateEvent; |
| | | public event Action<int, bool> playerInTeamAnswerEvent; |
| | | public event Action<int> selectedInvitationChangeEvent; |
| | | public event Action invitationsChangeEvent; |
| | | public event Action matchingStateChangeEvent; |
| | | public event Action memberPrepareStateChangeEvent; |
| | | |
| | | Redpoint entranceRedpoint = new Redpoint(27); |
| | | Redpoint applicationRedpoint = new Redpoint(27, 2701); |
| | | Redpoint invitationRedpoint = new Redpoint(28); |
| | | Redpoint memberCountRedpoint = new Redpoint(34); |
| | | |
| | | public override void Init() |
| | | { |
| | | levelMaxBuf = GeneralConfig.Instance.playerMaxLevel; |
| | | ParseTeamMission(); |
| | | DTCB309_tagGCAnswerPlayerShortInfo.OnPlayerShortInfoEvent += OnGetPlayerShortInfo; |
| | | } |
| | | |
| | | public override void UnInit() |
| | | { |
| | | DTCB309_tagGCAnswerPlayerShortInfo.OnPlayerShortInfoEvent -= OnGetPlayerShortInfo; |
| | | } |
| | | |
| | | public void OnAfterPlayerDataInitialize() |
| | | { |
| | | isMatching = false; |
| | | serverInited = false; |
| | | } |
| | | |
| | | public void OnSwitchAccount() |
| | | { |
| | | m_CurrentMission = new TeamMission(CURRENTMAP_MISSION, 0); |
| | | m_MissionBuf = new TeamMission(CURRENTMAP_MISSION, 0); |
| | | m_MyTeam = new MyTeam(); |
| | | targetPreferences.Clear(); |
| | | } |
| | | |
| | | public void RequestQueryTeamList() |
| | | { |
| | | if (currentMission.mapId == CURRENTMAP_MISSION) |
| | | { |
| | | var queryTeam = new C090B_tagCRefreshSceneTeam(); |
| | | GameNetSystem.Instance.SendInfo(queryTeam); |
| | | } |
| | | else |
| | | { |
| | | var query = new CB906_tagCGQueryTagMapTeam(); |
| | | query.TagMapID = (uint)currentMission.mapId; |
| | | query.TagMapEx = (ushort)(currentMission.mapEx == -1 ? 0 : currentMission.mapEx); |
| | | query.IsTagEx = (byte)(currentMission.mapEx == -1 ? 0 : 1); |
| | | query.MatchState = 0; |
| | | GameNetSystem.Instance.SendInfo(query); |
| | | } |
| | | } |
| | | |
| | | public void RequestApplyForJoin(int _playerId) |
| | | { |
| | | var apply = new C0909_tagCRequestJoinTeam(); |
| | | apply.PlayerID = (uint)_playerId; |
| | | GameNetSystem.Instance.SendInfo(apply); |
| | | } |
| | | |
| | | public void RequestCreateTeam(int _mapId, int _lineId, int _levelMin = 1, int _levelMax = 1) |
| | | { |
| | | if (_mapId == 31110) |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<RealmConfig>(PlayerDatas.Instance.baseData.realmLevel); |
| | | if (config.IsBigRealm != 1 || !ModelCenter.Instance.GetModel<RealmModel>().IsDungeonState) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("NOGreatBourn"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | var mapId = _mapId == NONE_MISSION ? 0 : _mapId == CURRENTMAP_MISSION ? PlayerDatas.Instance.baseData.MapID : _mapId; |
| | | var mapEx = _lineId <= 0 ? 0 : _lineId; |
| | | var dungeonId = dungeonModel.DungeonMap(mapId, mapEx); |
| | | |
| | | var limitLevelMin = 0; |
| | | var limitLevelMax = 0; |
| | | |
| | | if (dungeonId != 0) |
| | | { |
| | | var dungeonConfig = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId); |
| | | limitLevelMin = dungeonConfig.LVLimitMin; |
| | | limitLevelMax = dungeonConfig.LVLimitMax; |
| | | } |
| | | else |
| | | { |
| | | limitLevelMin = 1; |
| | | limitLevelMax = GeneralConfig.Instance.playerMaxLevel; |
| | | } |
| | | |
| | | var createTeam = new CB901_tagCGCreateTeam(); |
| | | createTeam.TagMapID = (ushort)_mapId; |
| | | createTeam.TagMapEx = (ushort)(_lineId == -1 ? 0 : _lineId); |
| | | createTeam.ReqMinLV = (ushort)limitLevelMin; |
| | | createTeam.ReqMaxLV = (ushort)limitLevelMax; |
| | | |
| | | GameNetSystem.Instance.SendInfo(createTeam); |
| | | } |
| | | |
| | | public void RequestExitTeam() |
| | | { |
| | | var exitTeam = new C0907_tagCLeaveTeam(); |
| | | GameNetSystem.Instance.SendInfo(exitTeam); |
| | | } |
| | | |
| | | public void RequestKickoutTeam(int _playerId) |
| | | { |
| | | var kickoutTeam = new C0902_tagCLeaderKickPlayer(); |
| | | kickoutTeam.PlayerID = (uint)_playerId; |
| | | GameNetSystem.Instance.SendInfo(kickoutTeam); |
| | | } |
| | | |
| | | public void RequestSetCaptainer(int _playerId) |
| | | { |
| | | var setMemberState = new C0906_tagCTeamChangeMemberState(); |
| | | setMemberState.PlayerID = (uint)_playerId; |
| | | setMemberState.MemberLV = 2; |
| | | GameNetSystem.Instance.SendInfo(setMemberState); |
| | | } |
| | | |
| | | public void RequestInviteJoinTeam(int _playerId) |
| | | { |
| | | if (!myTeam.inTeam) |
| | | { |
| | | RequestCreateTeam(missionBuf.mapId, missionBuf.mapEx, levelMinBuf, levelMaxBuf); |
| | | } |
| | | var joinTeam = new CB902_tagCGInvitePlayerJoinTeam(); |
| | | joinTeam.PlayerID = (uint)_playerId; |
| | | GameNetSystem.Instance.SendInfo(joinTeam); |
| | | |
| | | for (int i = 0; i < invites.Count; i++) |
| | | { |
| | | if (invites[i].playerId == _playerId) |
| | | { |
| | | invites.RemoveAt(i); |
| | | } |
| | | } |
| | | |
| | | if (teamInvitesUpdateEvent != null) |
| | | { |
| | | teamInvitesUpdateEvent(currentInviteType); |
| | | } |
| | | } |
| | | |
| | | public void RequestQueryNearbyPlayers() |
| | | { |
| | | invites.Clear(); |
| | | var nearByPlayer = new CB905_tagCGQueryRecommendNearbyPlayer(); |
| | | GameNetSystem.Instance.SendInfo(nearByPlayer); |
| | | } |
| | | |
| | | public void RequestWorldInvite() |
| | | { |
| | | if (myTeam.iamCaptainer) |
| | | { |
| | | var mapId = 0; |
| | | var lineId = 0; |
| | | if (myTeam.mission.mapId == CURRENTMAP_MISSION || myTeam.mission.mapId == NONE_MISSION) |
| | | { |
| | | mapId = PlayerDatas.Instance.baseData.MapID; |
| | | lineId = 0; |
| | | } |
| | | else |
| | | { |
| | | mapId = myTeam.mission.mapId; |
| | | lineId = myTeam.mission.mapEx; |
| | | } |
| | | |
| | | var dungeonId = dungeonModel.DungeonMap(mapId, lineId); |
| | | var missionName = string.Empty; |
| | | if (dungeonId == 0) |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<MapConfig>(mapId); |
| | | missionName = config.Name; |
| | | } |
| | | else |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId); |
| | | missionName = config.FBName; |
| | | } |
| | | |
| | | var levelRequirement = string.Empty; |
| | | var levelMax = StringUtility.GetLevelString(myTeam.levelMax, GeneralConfig.Instance.greatMasterStartLV); |
| | | if (myTeam.levelMin == myTeam.levelMax) |
| | | { |
| | | levelRequirement = StringUtility.Contact(levelMax); |
| | | } |
| | | else |
| | | { |
| | | var levelMin = StringUtility.GetLevelString(myTeam.levelMin, GeneralConfig.Instance.greatMasterStartLV); |
| | | levelRequirement = StringUtility.Contact(levelMin, "--", levelMax); |
| | | } |
| | | |
| | | var content = Language.Get("WorldInvite", missionName, levelRequirement); |
| | | ChatCtrl.Inst.SendInvite(content); |
| | | |
| | | SysNotifyMgr.Instance.ShowTip("SendWorldMessage"); |
| | | } |
| | | } |
| | | |
| | | public void RequestAmendTeamInfo(TeamMission _mission, int _levelMin, int _levelMax) |
| | | { |
| | | var teamInfo = new CB903_tagCGChangeTeamInfo(); |
| | | |
| | | teamInfo.TagMapID = (ushort)(_mission.mapId == CURRENTMAP_MISSION ? PlayerDatas.Instance.baseData.MapID : _mission.mapId); |
| | | teamInfo.TagMapEx = (ushort)(_mission.mapEx == -1 ? 0 : _mission.mapEx); |
| | | teamInfo.ReqMinLV = (ushort)_levelMin; |
| | | teamInfo.ReqMaxLV = (ushort)_levelMax; |
| | | |
| | | GameNetSystem.Instance.SendInfo(teamInfo); |
| | | } |
| | | |
| | | public void RequestAcceptApplication(int _playerId) |
| | | { |
| | | var answer = new C090A_tagCRequestJoinTeamReply(); |
| | | answer.PlayerID = (uint)_playerId; |
| | | answer.Type = 1; |
| | | |
| | | GameNetSystem.Instance.SendInfo(answer); |
| | | RemoveApplication(_playerId); |
| | | |
| | | RefreshApplicationRedpoint(); |
| | | if (applicationsChangeEvent != null) |
| | | { |
| | | applicationsChangeEvent(); |
| | | } |
| | | } |
| | | |
| | | public void RequestRejectApplication(int _playerId) |
| | | { |
| | | var answer = new C090A_tagCRequestJoinTeamReply(); |
| | | answer.PlayerID = (uint)_playerId; |
| | | answer.Type = 2; |
| | | |
| | | GameNetSystem.Instance.SendInfo(answer); |
| | | RemoveApplication(_playerId); |
| | | |
| | | RefreshApplicationRedpoint(); |
| | | if (applicationsChangeEvent != null) |
| | | { |
| | | applicationsChangeEvent(); |
| | | } |
| | | } |
| | | |
| | | public void RequestAcceptInvitation(int _playerId) |
| | | { |
| | | if (FindInvitation(_playerId)) |
| | | { |
| | | var answer = new C0903_tagCTeamReq(); |
| | | answer.PlayerID = (uint)_playerId; |
| | | answer.Type = 1; |
| | | |
| | | GameNetSystem.Instance.SendInfo(answer); |
| | | RemoveInvitation(_playerId); |
| | | |
| | | RefreshInvitationRedpoint(); |
| | | if (invitationsChangeEvent != null) |
| | | { |
| | | invitationsChangeEvent(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void RequestRejectInvitation(int _playerId) |
| | | { |
| | | var answer = new C0903_tagCTeamReq(); |
| | | answer.PlayerID = (uint)_playerId; |
| | | answer.Type = 0; |
| | | |
| | | GameNetSystem.Instance.SendInfo(answer); |
| | | RemoveInvitation(_playerId); |
| | | |
| | | RefreshInvitationRedpoint(); |
| | | if (invitationsChangeEvent != null) |
| | | { |
| | | invitationsChangeEvent(); |
| | | } |
| | | } |
| | | |
| | | public void ClearInvitations() |
| | | { |
| | | invitations.Clear(); |
| | | RefreshInvitationRedpoint(); |
| | | |
| | | if (invitationsChangeEvent != null) |
| | | { |
| | | invitationsChangeEvent(); |
| | | } |
| | | } |
| | | |
| | | public void RequestQueryPlayerInTeam(int _playerId) |
| | | { |
| | | var query = new CB306_tagCGViewPlayerShortInfo(); |
| | | query.PlayerID = (uint)_playerId; |
| | | |
| | | GameNetSystem.Instance.SendInfo(query); |
| | | } |
| | | |
| | | public void RequestAutoMatchTeam(bool _myTeam) |
| | | { |
| | | if (myTeam.inTeam && !myTeam.iamCaptainer) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("DungeonGroupAutoOnlyLeader"); |
| | | return; |
| | | } |
| | | |
| | | if (_myTeam) |
| | | { |
| | | var mission = myTeam.inTeam ? myTeam.mission : missionBuf; |
| | | var sendInfo = new CB907_tagCGAutoMatchTeam(); |
| | | sendInfo.TagMapID = (uint)(mission.mapId == CURRENTMAP_MISSION || mission.mapId == NONE_MISSION ? 0 : mission.mapId); |
| | | sendInfo.TagMapEx = (ushort)(mission.mapEx == -1 ? 0 : mission.mapEx); |
| | | GameNetSystem.Instance.SendInfo(sendInfo); |
| | | } |
| | | else |
| | | { |
| | | RequestAutoMatchTeam(currentMission); |
| | | } |
| | | } |
| | | |
| | | public void RequestAutoMatchTeam(TeamMission _mission) |
| | | { |
| | | if (myTeam.inTeam && !myTeam.iamCaptainer) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("DungeonGroupAutoOnlyLeader"); |
| | | return; |
| | | } |
| | | |
| | | else if (myTeam.memberCount >= 4) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("AutoMatchingCannotJoinTeam"); |
| | | return; |
| | | } |
| | | |
| | | var minLevel = 1; |
| | | var maxLevel = 1; |
| | | |
| | | if (_mission != myTeam.mission) |
| | | { |
| | | var mapConfig = ConfigManager.Instance.GetTemplate<MapConfig>(PlayerDatas.Instance.baseData.MapID); |
| | | if (_mission.mapId == 0) |
| | | { |
| | | if (mapConfig.MapFBType == (int)MapType.OpenCountry) |
| | | { |
| | | minLevel = 1; |
| | | maxLevel = GeneralConfig.Instance.playerMaxLevel; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var dungeonId = ModelCenter.Instance.GetModel<DungeonModel>().DungeonMap(_mission.mapId, _mission.mapEx); |
| | | var dungeonConfig = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId); |
| | | minLevel = dungeonConfig.LVLimitMin; |
| | | maxLevel = dungeonConfig.LVLimitMax; |
| | | } |
| | | |
| | | missionBuf = _mission; |
| | | RequestAmendTeamInfo(_mission, minLevel, maxLevel); |
| | | } |
| | | else |
| | | { |
| | | minLevel = myTeam.levelMin; |
| | | maxLevel = myTeam.levelMax; |
| | | } |
| | | |
| | | var sendInfo = new CB907_tagCGAutoMatchTeam(); |
| | | sendInfo.TagMapID = (uint)_mission.mapId; |
| | | sendInfo.TagMapEx = (ushort)_mission.mapEx; |
| | | GameNetSystem.Instance.SendInfo(sendInfo); |
| | | } |
| | | |
| | | public void RequestCancelAutoMatchTeam() |
| | | { |
| | | var sendInfo = new CB908_tagCGCancelMatchTeam(); |
| | | GameNetSystem.Instance.SendInfo(sendInfo); |
| | | } |
| | | |
| | | public void ReqeustPrepareEnterDungeon(bool _prepare) |
| | | { |
| | | var sendInfo = new CB909_tagCGTeamMemberPrepare(); |
| | | sendInfo.PrepareState = (byte)(_prepare ? 1 : 2); |
| | | GameNetSystem.Instance.SendInfo(sendInfo); |
| | | } |
| | | |
| | | public void InvitePlayers(TeamInviteType _inviteType) |
| | | { |
| | | currentInviteType = _inviteType; |
| | | switch (_inviteType) |
| | | { |
| | | case TeamInviteType.Friend: |
| | | GetFriendMembers(); |
| | | if (teamInvitesUpdateEvent != null) |
| | | { |
| | | teamInvitesUpdateEvent(_inviteType); |
| | | } |
| | | break; |
| | | case TeamInviteType.Fairy: |
| | | GetFairyMemebers(); |
| | | if (teamInvitesUpdateEvent != null) |
| | | { |
| | | teamInvitesUpdateEvent(_inviteType); |
| | | } |
| | | break; |
| | | case TeamInviteType.NearBy: |
| | | RequestQueryNearbyPlayers(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void GetFriendMembers() |
| | | { |
| | | invites.Clear(); |
| | | var friends = friendsModel.GetFriendInfoDict((byte)GroupType.Friend); |
| | | if (friends != null) |
| | | { |
| | | foreach (var key in friends.Keys) |
| | | { |
| | | var member = friends[key]; |
| | | if (member.OnlineType != 0) |
| | | { |
| | | invites.Add(new TeamInvite(member)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void GetFairyMemebers() |
| | | { |
| | | invites.Clear(); |
| | | if (PlayerDatas.Instance.fairyData.HasFairy && PlayerDatas.Instance.fairyData.fairy != null) |
| | | { |
| | | var myPlayerId = PlayerDatas.Instance.baseData.PlayerID; |
| | | var fairyMembers = PlayerDatas.Instance.fairyData.fairy.Member; |
| | | for (int i = 0; i < fairyMembers.Count; i++) |
| | | { |
| | | var member = fairyMembers[i]; |
| | | if (member.PlayerID != myPlayerId && member.Exattr2 == 0) |
| | | { |
| | | invites.Add(new TeamInvite(member)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void ClearAllApplications() |
| | | { |
| | | applications.Clear(); |
| | | if (applicationsChangeEvent != null) |
| | | { |
| | | applicationsChangeEvent(); |
| | | } |
| | | |
| | | RefreshApplicationRedpoint(); |
| | | } |
| | | |
| | | public void OnGetTheirTeams(HB904_tagGCSceneTeamRefresh _teamInfo) |
| | | { |
| | | theirTeams.Clear(); |
| | | |
| | | for (int i = 0; i < _teamInfo.SceneTeamList.Length; i++) |
| | | { |
| | | theirTeams.Add(new TheirTeam(_teamInfo.SceneTeamList[i])); |
| | | } |
| | | |
| | | theirTeams.Sort( |
| | | (TheirTeam a, TheirTeam b) => |
| | | { |
| | | return a.memberCount < 4 && a.memberCount > b.memberCount ? -1 : 1; |
| | | } |
| | | ); |
| | | |
| | | if (theirTeamListRefreshEvent != null) |
| | | { |
| | | theirTeamListRefreshEvent(); |
| | | } |
| | | } |
| | | |
| | | public void OnGetTheirTeams(HB909_tagGCTagMapTeamList _teamInfo) |
| | | { |
| | | theirTeams.Clear(); |
| | | |
| | | for (int i = 0; i < _teamInfo.TeamList.Length; i++) |
| | | { |
| | | theirTeams.Add(new TheirTeam((int)_teamInfo.TagMapID, _teamInfo.IsTagEx == 1 ? _teamInfo.TagMapEx : -1, _teamInfo.MatchState == 1, _teamInfo.TeamList[i])); |
| | | } |
| | | |
| | | theirTeams.Sort( |
| | | (TheirTeam a, TheirTeam b) => |
| | | { |
| | | return a.memberCount < 4 && a.memberCount > b.memberCount ? -1 : 1; |
| | | } |
| | | ); |
| | | |
| | | if (theirTeamListRefreshEvent != null) |
| | | { |
| | | theirTeamListRefreshEvent(); |
| | | } |
| | | } |
| | | |
| | | public void OnGetNearByPlayers(HB908_tagGCRecommendNearbyPlayerList _playerListInfo) |
| | | { |
| | | invites.Clear(); |
| | | for (int i = 0; i < _playerListInfo.PlayerCount; i++) |
| | | { |
| | | invites.Add(new TeamInvite(_playerListInfo.PlayerList[i])); |
| | | } |
| | | |
| | | if (teamInvitesUpdateEvent != null) |
| | | { |
| | | teamInvitesUpdateEvent(TeamInviteType.NearBy); |
| | | } |
| | | } |
| | | |
| | | public void OnGetPlayerShortInfo(HB309_tagGCAnswerPlayerShortInfo _inTeamInfo) |
| | | { |
| | | if (playerInTeamAnswerEvent != null) |
| | | { |
| | | playerInTeamAnswerEvent((int)_inTeamInfo.PlayerID, _inTeamInfo.IsInTeam == 1); |
| | | } |
| | | } |
| | | |
| | | public void OnTeamClear(H0905_tagTeamClear _serverInfo) |
| | | { |
| | | myTeam.teamId = 0; |
| | | myTeam.ClearMembers(); |
| | | |
| | | if (!myTeam.iamCaptainer) |
| | | { |
| | | ClearAllApplications(); |
| | | } |
| | | |
| | | if (myTeamRefreshEvent != null) |
| | | { |
| | | myTeamRefreshEvent(); |
| | | } |
| | | |
| | | memberCountRedpoint.state = myTeam.memberCount > 0 ? RedPointState.Quantity : RedPointState.None; |
| | | memberCountRedpoint.count = myTeam.memberCount; |
| | | } |
| | | |
| | | public void OnTeammateLeave(H0906_tagPlayerLeaveTeamMsg _leaveTeam) |
| | | { |
| | | if (_leaveTeam.PlayerID == PlayerDatas.Instance.baseData.PlayerID) |
| | | { |
| | | if (!myTeam.iamCaptainer) |
| | | { |
| | | ClearAllApplications(); |
| | | } |
| | | |
| | | myTeam.ClearMembers(); |
| | | if (myTeamRefreshEvent != null) |
| | | { |
| | | myTeamRefreshEvent(); |
| | | } |
| | | |
| | | if (_leaveTeam.Reason == 1) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("TeamKick"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Teammate mate; |
| | | if (myTeam.TryGetMemberByPlayerId((int)_leaveTeam.PlayerID, out mate)) |
| | | { |
| | | switch (_leaveTeam.Reason) |
| | | { |
| | | case 0: |
| | | SysNotifyMgr.Instance.ShowTip("LeaveProcession", mate.mateName); |
| | | break; |
| | | case 1: |
| | | SysNotifyMgr.Instance.ShowTip("LeaveProcession", mate.mateName); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (teammateLeaveEvent != null) |
| | | { |
| | | teammateLeaveEvent((int)_leaveTeam.PlayerID); |
| | | } |
| | | |
| | | memberCountRedpoint.state = myTeam.memberCount > 0 ? RedPointState.Quantity : RedPointState.None; |
| | | memberCountRedpoint.count = myTeam.memberCount; |
| | | } |
| | | |
| | | public void OnTeammateOnOffLine(H0912_tagTeamMemberLoginInfo _loginInfo) |
| | | { |
| | | |
| | | Teammate mate; |
| | | if (myTeam.TryGetMemberByPlayerId((int)_loginInfo.PlayerID, out mate)) |
| | | { |
| | | mate.online = _loginInfo.Type == 1; |
| | | switch (_loginInfo.Type) |
| | | { |
| | | case 0: |
| | | SysNotifyMgr.Instance.ShowTip("XW_JZ_LeaguerOnline", mate.mateName); |
| | | break; |
| | | case 1: |
| | | SysNotifyMgr.Instance.ShowTip("XW_JZ_LeaguerLeaveline", mate.mateName); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (teammateOnOffLineEvent != null) |
| | | { |
| | | teammateOnOffLineEvent((int)_loginInfo.PlayerID); |
| | | } |
| | | } |
| | | |
| | | public void OnTeammateChangeMap(H0913_tagTeamMemberChangeMap _changeMap) |
| | | { |
| | | Teammate mate; |
| | | if (myTeam.TryGetMemberByPlayerId((int)_changeMap.PlayerID, out mate)) |
| | | { |
| | | mate.UpdateMap(_changeMap); |
| | | } |
| | | if (teammateChangeMapEvent != null) |
| | | { |
| | | teammateChangeMapEvent((int)_changeMap.PlayerID); |
| | | } |
| | | } |
| | | |
| | | public void OnGetApplication(HB907_tagGCRequestJoinTeam _serverInfo) |
| | | { |
| | | if (!FindApplication((int)_serverInfo.PlayerID)) |
| | | { |
| | | applications.Insert(0, new TeamApplication(_serverInfo)); |
| | | RefreshApplicationRedpoint(); |
| | | if (applicationsChangeEvent != null) |
| | | { |
| | | applicationsChangeEvent(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void OnGetInvitation(HB901_tagGCInviteJoinTeamInfo _serverInfo) |
| | | { |
| | | for (int i = 0; i < invitations.Count; i++) |
| | | { |
| | | var invitation = invitations[i]; |
| | | if (invitation.playerId == _serverInfo.PlayerID) |
| | | { |
| | | invitations.RemoveAt(i); |
| | | } |
| | | } |
| | | |
| | | invitations.Insert(0, new TeamInvitation(_serverInfo)); |
| | | |
| | | RefreshInvitationRedpoint(); |
| | | if (invitationsChangeEvent != null) |
| | | { |
| | | invitationsChangeEvent(); |
| | | } |
| | | } |
| | | |
| | | public void OnUpdateTeammateInfos(HB902_tagGCTeamMemberInfo _serverInfo) |
| | | { |
| | | var oldInTeam = myTeam.inTeam; |
| | | |
| | | myTeam.teamId = (int)_serverInfo.TeamID; |
| | | myTeam.mission = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx); |
| | | myTeam.levelMin = _serverInfo.ReqMinLV; |
| | | myTeam.levelMax = _serverInfo.ReqMaxLV; |
| | | |
| | | levelMinBuf = _serverInfo.ReqMinLV; |
| | | levelMaxBuf = _serverInfo.ReqMaxLV; |
| | | missionBuf = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx); |
| | | |
| | | var mates = new List<Teammate>(); |
| | | for (int i = 0; i < _serverInfo.MemberList.Length; i++) |
| | | { |
| | | var member = _serverInfo.MemberList[i]; |
| | | mates.Add(new Teammate(member)); |
| | | |
| | | Teammate teammate; |
| | | if (!myTeam.TryGetMemberByPlayerId((int)member.PlayerID, out teammate)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_543685", member.Name); |
| | | } |
| | | } |
| | | |
| | | myTeam.UpdateMembers(mates); |
| | | |
| | | if (!myTeam.iamCaptainer) |
| | | { |
| | | ClearAllApplications(); |
| | | } |
| | | |
| | | if (myTeamRefreshEvent != null) |
| | | { |
| | | myTeamRefreshEvent(); |
| | | } |
| | | |
| | | if (!oldInTeam && myTeam.inTeam) |
| | | { |
| | | if (createTeamEvent != null) |
| | | { |
| | | createTeamEvent(); |
| | | } |
| | | } |
| | | |
| | | if (serverInited) |
| | | { |
| | | if (!oldInTeam && myTeam.inTeam) |
| | | { |
| | | if (!WindowCenter.Instance.CheckOpen("NewBieWin") && !WindowCenter.Instance.CheckOpen("TreasureNewGotWin")) |
| | | { |
| | | if (!WindowCenter.Instance.CheckOpen("MyTeamWin")) |
| | | { |
| | | WindowCenter.Instance.Open<TeamFrameWin>(false, 1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | memberCountRedpoint.state = myTeam.memberCount > 0 ? RedPointState.Quantity : RedPointState.None; |
| | | memberCountRedpoint.count = myTeam.memberCount; |
| | | } |
| | | |
| | | public void OnUpdateTeammission(HB903_tagGCTeamInfoChange _serverInfo) |
| | | { |
| | | myTeam.mission = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx); |
| | | myTeam.levelMin = _serverInfo.ReqMinLV; |
| | | myTeam.levelMax = _serverInfo.ReqMaxLV; |
| | | |
| | | levelMinBuf = _serverInfo.ReqMinLV; |
| | | levelMaxBuf = _serverInfo.ReqMaxLV; |
| | | missionBuf = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx); |
| | | |
| | | if (missionLevelLimitChangeEvent != null) |
| | | { |
| | | missionLevelLimitChangeEvent(); |
| | | } |
| | | } |
| | | |
| | | public void OnUpdateTeammateInfo(HB905_tagGCTeamMemberRefreshProperty _serverInfo) |
| | | { |
| | | switch ((PlayerDataRefresh)_serverInfo.RefreshType) |
| | | { |
| | | case PlayerDataRefresh.LV: |
| | | Teammate mate; |
| | | if (myTeam.TryGetMemberByPlayerId((int)_serverInfo.PlayerID, out mate)) |
| | | { |
| | | mate.level = (int)_serverInfo.Value; |
| | | if (teammateLevelUpEvent != null) |
| | | { |
| | | teammateLevelUpEvent(mate.id); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public void OnUpdateDungeonPrepareState(HB911_tagGCTeamEnterFBPrepare _serverInfo) |
| | | { |
| | | if (!AssetSource.sceneFromEditor && VersionConfig.Get().assetAccess != InstalledAsset.IngoreDownLoad && !AssetVersionUtility.unPriorAssetDownLoadDone) |
| | | { |
| | | ReqeustPrepareEnterDungeon(false); |
| | | return; |
| | | } |
| | | |
| | | teamPrepare.UpdatePrepareState(_serverInfo); |
| | | if (teamPrepare.isError) |
| | | { |
| | | WindowCenter.Instance.Close<TeamPrepareWin>(); |
| | | } |
| | | else |
| | | { |
| | | if (memberPrepareStateChangeEvent != null) |
| | | { |
| | | memberPrepareStateChangeEvent(); |
| | | } |
| | | |
| | | if (teamPrepare.IsReject()) |
| | | { |
| | | WindowCenter.Instance.Close<TeamPrepareWin>(); |
| | | } |
| | | else |
| | | { |
| | | Teammate mate; |
| | | if (myTeam.TryGetMember(0, out mate)) |
| | | { |
| | | if (teamPrepare.OnlyCaptainerPrepared(mate.id)) |
| | | { |
| | | if (!WindowCenter.Instance.CheckOpen<TeamPrepareWin>()) |
| | | { |
| | | prepareBeginTime = DateTime.Now; |
| | | WindowCenter.Instance.Open<TeamPrepareWin>(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public bool IsMissionUnLock(int _mapId, int _mapEx) |
| | | { |
| | | if (_mapId == NONE_MISSION || _mapId == CURRENTMAP_MISSION) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var dungeonId = dungeonModel.DungeonMap(_mapId, _mapEx); |
| | | var dungeonConfig = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId); |
| | | return PlayerDatas.Instance.baseData.LV >= dungeonConfig.LVLimitMin; |
| | | } |
| | | } |
| | | |
| | | private bool FindInvitation(int _playerId) |
| | | { |
| | | for (int i = 0; i < invitations.Count; i++) |
| | | { |
| | | var invitation = invitations[i]; |
| | | if (invitation.playerId == _playerId) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | private bool FindApplication(int _playerId) |
| | | { |
| | | for (int i = 0; i < applications.Count; i++) |
| | | { |
| | | var application = applications[i]; |
| | | if (application.playerId == _playerId) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | private void RemoveInvitation(int _playerId) |
| | | { |
| | | for (int i = 0; i < invitations.Count; i++) |
| | | { |
| | | var invitation = invitations[i]; |
| | | if (invitation.playerId == _playerId) |
| | | { |
| | | invitations.RemoveAt(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void RemoveApplication(int _playerId) |
| | | { |
| | | for (int i = 0; i < applications.Count; i++) |
| | | { |
| | | var application = applications[i]; |
| | | if (application.playerId == _playerId) |
| | | { |
| | | applications.RemoveAt(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void RefreshInvitationRedpoint() |
| | | { |
| | | if (invitations.Count > 1) |
| | | { |
| | | invitationRedpoint.state = RedPointState.Quantity; |
| | | invitationRedpoint.count = invitations.Count; |
| | | } |
| | | else |
| | | { |
| | | invitationRedpoint.state = invitations.Count > 0 ? RedPointState.Simple : RedPointState.None; |
| | | } |
| | | } |
| | | |
| | | private void RefreshApplicationRedpoint() |
| | | { |
| | | if (applications.Count > 1) |
| | | { |
| | | applicationRedpoint.state = RedPointState.Quantity; |
| | | applicationRedpoint.count = invitations.Count; |
| | | } |
| | | else |
| | | { |
| | | applicationRedpoint.state = applications.Count > 0 ? RedPointState.Simple : RedPointState.None; |
| | | } |
| | | } |
| | | |
| | | private void ParseTeamMission() |
| | | { |
| | | teammissions[NONE_MISSION] = new List<int>() { 0 }; |
| | | teammissions[CURRENTMAP_MISSION] = new List<int>() { 0 }; |
| | | |
| | | var allTeamTargets = ConfigManager.Instance.GetAllValues<TeamTargetConfig>(); |
| | | foreach (var config in allTeamTargets) |
| | | { |
| | | List<int> missionGroup; |
| | | var dataMapId = config.DataMapID; |
| | | |
| | | if (!teammissions.TryGetValue(dataMapId, out missionGroup)) |
| | | { |
| | | teammissions[dataMapId] = missionGroup = new List<int>(); |
| | | } |
| | | else |
| | | { |
| | | missionGroup = teammissions[dataMapId]; |
| | | } |
| | | |
| | | missionGroup.AddRange(config.TeamTargetUseLineID); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | | serverInited = true; |
| | | } |
| | | |
| | | private void OnMatchingCoolDownEnd() |
| | | { |
| | | if (isMatching) |
| | | { |
| | | RequestCancelAutoMatchTeam(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | using System;
|
| | | using TableConfig;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | | public class TeamModel : Model, IAfterPlayerDataInitialize, ISwitchAccount, IPlayerLoginOk
|
| | | {
|
| | | public const int NONE_MISSION = 0;
|
| | | public const int CURRENTMAP_MISSION = 1;
|
| | |
|
| | | bool serverInited = false;
|
| | | FriendsModel friendsModel { get { return ModelCenter.Instance.GetModel<FriendsModel>(); } }
|
| | | DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
| | |
|
| | | public bool autoAcceptApplication {
|
| | | get { return (PlayerDatas.Instance.baseData.ExAttr2 / 10) % 10 == 0; }
|
| | | set {
|
| | | var sendInfo = new CB904_tagCMChangeTeamCheckState();
|
| | | sendInfo.JoinReqCheck = (byte)(value ? 0 : 1);
|
| | | sendInfo.InviteCheck = (byte)(autoAcceptInvitation ? 0 : 1);
|
| | | GameNetSystem.Instance.SendInfo(sendInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | public bool autoAcceptInvitation {
|
| | | get { return PlayerDatas.Instance.baseData.ExAttr2 % 10 == 0; }
|
| | | set {
|
| | | if ((PlayerDatas.Instance.baseData.ExAttr2 % 10 == 0) != value)
|
| | | {
|
| | | var sendInfo = new CB904_tagCMChangeTeamCheckState();
|
| | | sendInfo.InviteCheck = (byte)(value ? 0 : 1);
|
| | | sendInfo.JoinReqCheck = (byte)(autoAcceptApplication ? 0 : 1);
|
| | | GameNetSystem.Instance.SendInfo(sendInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public List<TheirTeam> theirTeams = new List<TheirTeam>();
|
| | | public List<TeamInvitation> invitations = new List<TeamInvitation>();
|
| | | public List<TeamApplication> applications = new List<TeamApplication>();
|
| | | public List<TeamInvite> invites = new List<TeamInvite>();
|
| | | public Dictionary<int, List<int>> teammissions = new Dictionary<int, List<int>>();
|
| | | public Dictionary<int, TeamTargetPreference> targetPreferences = new Dictionary<int, TeamTargetPreference>();
|
| | |
|
| | | MyTeam m_MyTeam = new MyTeam();
|
| | | public MyTeam myTeam {
|
| | | get { return m_MyTeam; }
|
| | | private set { m_MyTeam = value; }
|
| | | }
|
| | |
|
| | | TeamMission m_CurrentMission;
|
| | | public TeamMission currentMission {
|
| | | get { return m_CurrentMission; }
|
| | | set {
|
| | | if (m_CurrentMission != value)
|
| | | {
|
| | | m_CurrentMission = value;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | TeamMission m_MissionBuf = new TeamMission(CURRENTMAP_MISSION, 0);
|
| | | public TeamMission missionBuf {
|
| | | get { return m_MissionBuf; }
|
| | | set {
|
| | | m_MissionBuf = value;
|
| | | if (missionLevelLimitChangeEvent != null)
|
| | | {
|
| | | missionLevelLimitChangeEvent();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | int m_LevelMinBuf = 1;
|
| | | public int levelMinBuf {
|
| | | get { return m_LevelMinBuf; }
|
| | | set { m_LevelMinBuf = value; }
|
| | | }
|
| | |
|
| | | int m_LevelMaxBuf = 1;
|
| | | public int levelMaxBuf {
|
| | | get { return m_LevelMaxBuf; }
|
| | | set { m_LevelMaxBuf = value; }
|
| | | }
|
| | |
|
| | | TeamInviteType m_CurrentInviteType = TeamInviteType.Friend;
|
| | | public TeamInviteType currentInviteType {
|
| | | get { return m_CurrentInviteType; }
|
| | | private set { m_CurrentInviteType = value; }
|
| | | }
|
| | |
|
| | | int m_CurrentSelectedInvitation = 0;
|
| | | public int currentSelectedInvitation {
|
| | | get { return m_CurrentSelectedInvitation; }
|
| | | set {
|
| | | if (m_CurrentSelectedInvitation != value)
|
| | | {
|
| | | m_CurrentSelectedInvitation = value;
|
| | | if (selectedInvitationChangeEvent != null)
|
| | | {
|
| | | selectedInvitationChangeEvent(value);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Clock m_MatchingClock;
|
| | | public DateTime matchingEndTime { get; private set; }
|
| | |
|
| | | bool m_IsMatching = false;
|
| | | public bool isMatching {
|
| | | get { return m_IsMatching; }
|
| | | set {
|
| | | if (m_IsMatching != value)
|
| | | {
|
| | | m_IsMatching = value;
|
| | |
|
| | | if (m_IsMatching == false)
|
| | | {
|
| | | var mapConfig = ConfigManager.Instance.GetTemplate<MapConfig>(myTeam.mission.mapId);
|
| | | if (mapConfig != null && (MapType)mapConfig.MapFBType == MapType.MultipleFB)
|
| | | {
|
| | | if (myTeam.iamCaptainer && myTeam.memberCount >= 4)
|
| | | {
|
| | | GroupDungeonChallengeProcessor.Instance.GroupChallengeDungeon(myTeam.mission.mapId, myTeam.mission.mapEx, true);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (m_MatchingClock != null && m_MatchingClock.isActiveAndEnabled)
|
| | | {
|
| | | m_MatchingClock.Stop();
|
| | | m_MatchingClock = null;
|
| | | }
|
| | |
|
| | | if (m_IsMatching)
|
| | | {
|
| | | matchingEndTime = DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond * GeneralConfig.Instance.teamMatchingTimeOut);
|
| | | m_MatchingClock = Clock.Create(matchingEndTime, OnMatchingCoolDownEnd);
|
| | | }
|
| | |
|
| | | if (matchingStateChangeEvent != null)
|
| | | {
|
| | | matchingStateChangeEvent();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | DateTime m_PrepareBeginTime;
|
| | | public DateTime prepareBeginTime {
|
| | | get { return m_PrepareBeginTime; }
|
| | | private set { m_PrepareBeginTime = value; }
|
| | | }
|
| | |
|
| | | TeamPrepare m_TeamPreapare = new TeamPrepare();
|
| | | public TeamPrepare teamPrepare {
|
| | | get { return m_TeamPreapare; }
|
| | | private set { m_TeamPreapare = value; }
|
| | | }
|
| | |
|
| | | public event Action myTeamRefreshEvent;
|
| | | public event Action theirTeamListRefreshEvent;
|
| | | public event Action missionLevelLimitChangeEvent;
|
| | | public event Action createTeamEvent;
|
| | | public event Action exitTeamEvent;
|
| | | public event Action<int> teammateLeaveEvent;
|
| | | public event Action<int> teammateJoinEvent;
|
| | | public event Action<int> teammateOnOffLineEvent;
|
| | | public event Action<int> teammateLevelUpEvent;
|
| | | public event Action<int> teammateChangeMapEvent;
|
| | | public event Action applicationsChangeEvent;
|
| | | public event Action<TeamInviteType> teamInvitesUpdateEvent;
|
| | | public event Action<int, bool> playerInTeamAnswerEvent;
|
| | | public event Action<int> selectedInvitationChangeEvent;
|
| | | public event Action invitationsChangeEvent;
|
| | | public event Action matchingStateChangeEvent;
|
| | | public event Action memberPrepareStateChangeEvent;
|
| | |
|
| | | Redpoint entranceRedpoint = new Redpoint(27);
|
| | | Redpoint applicationRedpoint = new Redpoint(27, 2701);
|
| | | Redpoint invitationRedpoint = new Redpoint(28);
|
| | | Redpoint memberCountRedpoint = new Redpoint(34);
|
| | |
|
| | | public override void Init()
|
| | | {
|
| | | levelMaxBuf = GeneralConfig.Instance.playerMaxLevel;
|
| | | ParseTeamMission();
|
| | | DTCB309_tagGCAnswerPlayerShortInfo.OnPlayerShortInfoEvent += OnGetPlayerShortInfo;
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | | {
|
| | | DTCB309_tagGCAnswerPlayerShortInfo.OnPlayerShortInfoEvent -= OnGetPlayerShortInfo;
|
| | | }
|
| | |
|
| | | public void OnAfterPlayerDataInitialize()
|
| | | {
|
| | | isMatching = false;
|
| | | serverInited = false;
|
| | | }
|
| | |
|
| | | public void OnSwitchAccount()
|
| | | {
|
| | | m_CurrentMission = new TeamMission(CURRENTMAP_MISSION, 0);
|
| | | m_MissionBuf = new TeamMission(CURRENTMAP_MISSION, 0);
|
| | | m_MyTeam = new MyTeam();
|
| | | targetPreferences.Clear();
|
| | | }
|
| | |
|
| | | public void RequestQueryTeamList()
|
| | | {
|
| | | if (currentMission.mapId == CURRENTMAP_MISSION)
|
| | | {
|
| | | var queryTeam = new C090B_tagCRefreshSceneTeam();
|
| | | GameNetSystem.Instance.SendInfo(queryTeam);
|
| | | }
|
| | | else
|
| | | {
|
| | | var query = new CB906_tagCGQueryTagMapTeam();
|
| | | query.TagMapID = (uint)currentMission.mapId;
|
| | | query.TagMapEx = (ushort)(currentMission.mapEx == -1 ? 0 : currentMission.mapEx);
|
| | | query.IsTagEx = (byte)(currentMission.mapEx == -1 ? 0 : 1);
|
| | | query.MatchState = 0;
|
| | | GameNetSystem.Instance.SendInfo(query);
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestApplyForJoin(int _playerId)
|
| | | {
|
| | | var apply = new C0909_tagCRequestJoinTeam();
|
| | | apply.PlayerID = (uint)_playerId;
|
| | | GameNetSystem.Instance.SendInfo(apply);
|
| | | }
|
| | |
|
| | | public void RequestCreateTeam(int _mapId, int _lineId, int _levelMin = 1, int _levelMax = 1)
|
| | | {
|
| | | if (_mapId == 31110)
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<RealmConfig>(PlayerDatas.Instance.baseData.realmLevel);
|
| | | if (config.IsBigRealm != 1 || !ModelCenter.Instance.GetModel<RealmModel>().IsDungeonState)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("NOGreatBourn");
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | var mapId = _mapId == NONE_MISSION ? 0 : _mapId == CURRENTMAP_MISSION ? PlayerDatas.Instance.baseData.MapID : _mapId;
|
| | | var mapEx = _lineId <= 0 ? 0 : _lineId;
|
| | | var dungeonId = dungeonModel.DungeonMap(mapId, mapEx);
|
| | |
|
| | | var limitLevelMin = 0;
|
| | | var limitLevelMax = 0;
|
| | |
|
| | | if (dungeonId != 0)
|
| | | {
|
| | | var dungeonConfig = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId);
|
| | | limitLevelMin = dungeonConfig.LVLimitMin;
|
| | | limitLevelMax = dungeonConfig.LVLimitMax;
|
| | | }
|
| | | else
|
| | | {
|
| | | limitLevelMin = 1;
|
| | | limitLevelMax = GeneralConfig.Instance.playerMaxLevel;
|
| | | }
|
| | |
|
| | | var createTeam = new CB901_tagCGCreateTeam();
|
| | | createTeam.TagMapID = (ushort)_mapId;
|
| | | createTeam.TagMapEx = (ushort)(_lineId == -1 ? 0 : _lineId);
|
| | | createTeam.ReqMinLV = (ushort)limitLevelMin;
|
| | | createTeam.ReqMaxLV = (ushort)limitLevelMax;
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(createTeam);
|
| | | }
|
| | |
|
| | | public void RequestExitTeam()
|
| | | {
|
| | | var exitTeam = new C0907_tagCLeaveTeam();
|
| | | GameNetSystem.Instance.SendInfo(exitTeam);
|
| | | }
|
| | |
|
| | | public void RequestKickoutTeam(int _playerId)
|
| | | {
|
| | | var kickoutTeam = new C0902_tagCLeaderKickPlayer();
|
| | | kickoutTeam.PlayerID = (uint)_playerId;
|
| | | GameNetSystem.Instance.SendInfo(kickoutTeam);
|
| | | }
|
| | |
|
| | | public void RequestSetCaptainer(int _playerId)
|
| | | {
|
| | | var setMemberState = new C0906_tagCTeamChangeMemberState();
|
| | | setMemberState.PlayerID = (uint)_playerId;
|
| | | setMemberState.MemberLV = 2;
|
| | | GameNetSystem.Instance.SendInfo(setMemberState);
|
| | | }
|
| | |
|
| | | public void RequestInviteJoinTeam(int _playerId)
|
| | | {
|
| | | if (!myTeam.inTeam)
|
| | | {
|
| | | RequestCreateTeam(missionBuf.mapId, missionBuf.mapEx, levelMinBuf, levelMaxBuf);
|
| | | }
|
| | | var joinTeam = new CB902_tagCGInvitePlayerJoinTeam();
|
| | | joinTeam.PlayerID = (uint)_playerId;
|
| | | GameNetSystem.Instance.SendInfo(joinTeam);
|
| | |
|
| | | for (int i = 0; i < invites.Count; i++)
|
| | | {
|
| | | if (invites[i].playerId == _playerId)
|
| | | {
|
| | | invites.RemoveAt(i);
|
| | | }
|
| | | }
|
| | |
|
| | | if (teamInvitesUpdateEvent != null)
|
| | | {
|
| | | teamInvitesUpdateEvent(currentInviteType);
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestQueryNearbyPlayers()
|
| | | {
|
| | | invites.Clear();
|
| | | var nearByPlayer = new CB905_tagCGQueryRecommendNearbyPlayer();
|
| | | GameNetSystem.Instance.SendInfo(nearByPlayer);
|
| | | }
|
| | |
|
| | | public void RequestWorldInvite()
|
| | | {
|
| | | if (myTeam.iamCaptainer)
|
| | | {
|
| | | var mapId = 0;
|
| | | var lineId = 0;
|
| | | if (myTeam.mission.mapId == CURRENTMAP_MISSION || myTeam.mission.mapId == NONE_MISSION)
|
| | | {
|
| | | mapId = PlayerDatas.Instance.baseData.MapID;
|
| | | lineId = 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | mapId = myTeam.mission.mapId;
|
| | | lineId = myTeam.mission.mapEx;
|
| | | }
|
| | |
|
| | | var dungeonId = dungeonModel.DungeonMap(mapId, lineId);
|
| | | var missionName = string.Empty;
|
| | | if (dungeonId == 0)
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<MapConfig>(mapId);
|
| | | missionName = config.Name;
|
| | | }
|
| | | else
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId);
|
| | | missionName = config.FBName;
|
| | | }
|
| | |
|
| | | var levelRequirement = string.Empty;
|
| | | var levelMax = StringUtility.GetLevelString(myTeam.levelMax, GeneralConfig.Instance.greatMasterStartLV);
|
| | | if (myTeam.levelMin == myTeam.levelMax)
|
| | | {
|
| | | levelRequirement = StringUtility.Contact(levelMax);
|
| | | }
|
| | | else
|
| | | {
|
| | | var levelMin = StringUtility.GetLevelString(myTeam.levelMin, GeneralConfig.Instance.greatMasterStartLV);
|
| | | levelRequirement = StringUtility.Contact(levelMin, "--", levelMax);
|
| | | }
|
| | |
|
| | | var content = Language.Get("WorldInvite", missionName, levelRequirement);
|
| | | ChatCtrl.Inst.SendInvite(content);
|
| | |
|
| | | SysNotifyMgr.Instance.ShowTip("SendWorldMessage");
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestAmendTeamInfo(TeamMission _mission, int _levelMin, int _levelMax)
|
| | | {
|
| | | var teamInfo = new CB903_tagCGChangeTeamInfo();
|
| | |
|
| | | teamInfo.TagMapID = (ushort)(_mission.mapId == CURRENTMAP_MISSION ? PlayerDatas.Instance.baseData.MapID : _mission.mapId);
|
| | | teamInfo.TagMapEx = (ushort)(_mission.mapEx == -1 ? 0 : _mission.mapEx);
|
| | | teamInfo.ReqMinLV = (ushort)_levelMin;
|
| | | teamInfo.ReqMaxLV = (ushort)_levelMax;
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(teamInfo);
|
| | | }
|
| | |
|
| | | public void RequestAcceptApplication(int _playerId)
|
| | | {
|
| | | var answer = new C090A_tagCRequestJoinTeamReply();
|
| | | answer.PlayerID = (uint)_playerId;
|
| | | answer.Type = 1;
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(answer);
|
| | | RemoveApplication(_playerId);
|
| | |
|
| | | RefreshApplicationRedpoint();
|
| | | if (applicationsChangeEvent != null)
|
| | | {
|
| | | applicationsChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestRejectApplication(int _playerId)
|
| | | {
|
| | | var answer = new C090A_tagCRequestJoinTeamReply();
|
| | | answer.PlayerID = (uint)_playerId;
|
| | | answer.Type = 2;
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(answer);
|
| | | RemoveApplication(_playerId);
|
| | |
|
| | | RefreshApplicationRedpoint();
|
| | | if (applicationsChangeEvent != null)
|
| | | {
|
| | | applicationsChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestAcceptInvitation(int _playerId)
|
| | | {
|
| | | if (FindInvitation(_playerId))
|
| | | {
|
| | | var answer = new C0903_tagCTeamReq();
|
| | | answer.PlayerID = (uint)_playerId;
|
| | | answer.Type = 1;
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(answer);
|
| | | RemoveInvitation(_playerId);
|
| | |
|
| | | RefreshInvitationRedpoint();
|
| | | if (invitationsChangeEvent != null)
|
| | | {
|
| | | invitationsChangeEvent();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestRejectInvitation(int _playerId)
|
| | | {
|
| | | var answer = new C0903_tagCTeamReq();
|
| | | answer.PlayerID = (uint)_playerId;
|
| | | answer.Type = 0;
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(answer);
|
| | | RemoveInvitation(_playerId);
|
| | |
|
| | | RefreshInvitationRedpoint();
|
| | | if (invitationsChangeEvent != null)
|
| | | {
|
| | | invitationsChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void ClearInvitations()
|
| | | {
|
| | | invitations.Clear();
|
| | | RefreshInvitationRedpoint();
|
| | |
|
| | | if (invitationsChangeEvent != null)
|
| | | {
|
| | | invitationsChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestQueryPlayerInTeam(int _playerId)
|
| | | {
|
| | | var query = new CB306_tagCGViewPlayerShortInfo();
|
| | | query.PlayerID = (uint)_playerId;
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(query);
|
| | | }
|
| | |
|
| | | public void RequestAutoMatchTeam(bool _myTeam)
|
| | | {
|
| | | if (myTeam.inTeam && !myTeam.iamCaptainer)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("DungeonGroupAutoOnlyLeader");
|
| | | return;
|
| | | }
|
| | |
|
| | | if (_myTeam)
|
| | | {
|
| | | var mission = myTeam.inTeam ? myTeam.mission : missionBuf;
|
| | | var sendInfo = new CB907_tagCGAutoMatchTeam();
|
| | | sendInfo.TagMapID = (uint)(mission.mapId == CURRENTMAP_MISSION || mission.mapId == NONE_MISSION ? 0 : mission.mapId);
|
| | | sendInfo.TagMapEx = (ushort)(mission.mapEx == -1 ? 0 : mission.mapEx);
|
| | | GameNetSystem.Instance.SendInfo(sendInfo);
|
| | | }
|
| | | else
|
| | | {
|
| | | RequestAutoMatchTeam(currentMission);
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestAutoMatchTeam(TeamMission _mission)
|
| | | {
|
| | | if (myTeam.inTeam && !myTeam.iamCaptainer)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("DungeonGroupAutoOnlyLeader");
|
| | | return;
|
| | | }
|
| | |
|
| | | else if (myTeam.memberCount >= 4)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("AutoMatchingCannotJoinTeam");
|
| | | return;
|
| | | }
|
| | |
|
| | | var minLevel = 1;
|
| | | var maxLevel = 1;
|
| | |
|
| | | if (_mission != myTeam.mission)
|
| | | {
|
| | | var mapConfig = ConfigManager.Instance.GetTemplate<MapConfig>(PlayerDatas.Instance.baseData.MapID);
|
| | | if (_mission.mapId == 0)
|
| | | {
|
| | | if (mapConfig.MapFBType == (int)MapType.OpenCountry)
|
| | | {
|
| | | minLevel = 1;
|
| | | maxLevel = GeneralConfig.Instance.playerMaxLevel;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | var dungeonId = ModelCenter.Instance.GetModel<DungeonModel>().DungeonMap(_mission.mapId, _mission.mapEx);
|
| | | var dungeonConfig = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId);
|
| | | minLevel = dungeonConfig.LVLimitMin;
|
| | | maxLevel = dungeonConfig.LVLimitMax;
|
| | | }
|
| | |
|
| | | missionBuf = _mission;
|
| | | RequestAmendTeamInfo(_mission, minLevel, maxLevel);
|
| | | }
|
| | | else
|
| | | {
|
| | | minLevel = myTeam.levelMin;
|
| | | maxLevel = myTeam.levelMax;
|
| | | }
|
| | |
|
| | | var sendInfo = new CB907_tagCGAutoMatchTeam();
|
| | | sendInfo.TagMapID = (uint)_mission.mapId;
|
| | | sendInfo.TagMapEx = (ushort)_mission.mapEx;
|
| | | GameNetSystem.Instance.SendInfo(sendInfo);
|
| | | }
|
| | |
|
| | | public void RequestCancelAutoMatchTeam()
|
| | | {
|
| | | var sendInfo = new CB908_tagCGCancelMatchTeam();
|
| | | GameNetSystem.Instance.SendInfo(sendInfo);
|
| | | }
|
| | |
|
| | | public void ReqeustPrepareEnterDungeon(bool _prepare)
|
| | | {
|
| | | var sendInfo = new CB909_tagCGTeamMemberPrepare();
|
| | | sendInfo.PrepareState = (byte)(_prepare ? 1 : 2);
|
| | | GameNetSystem.Instance.SendInfo(sendInfo);
|
| | | }
|
| | |
|
| | | public void InvitePlayers(TeamInviteType _inviteType)
|
| | | {
|
| | | currentInviteType = _inviteType;
|
| | | switch (_inviteType)
|
| | | {
|
| | | case TeamInviteType.Friend:
|
| | | GetFriendMembers();
|
| | | if (teamInvitesUpdateEvent != null)
|
| | | {
|
| | | teamInvitesUpdateEvent(_inviteType);
|
| | | }
|
| | | break;
|
| | | case TeamInviteType.Fairy:
|
| | | GetFairyMemebers();
|
| | | if (teamInvitesUpdateEvent != null)
|
| | | {
|
| | | teamInvitesUpdateEvent(_inviteType);
|
| | | }
|
| | | break;
|
| | | case TeamInviteType.NearBy:
|
| | | RequestQueryNearbyPlayers();
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | private void GetFriendMembers()
|
| | | {
|
| | | invites.Clear();
|
| | | var friends = friendsModel.GetFriendInfoDict((byte)GroupType.Friend);
|
| | | if (friends != null)
|
| | | {
|
| | | foreach (var key in friends.Keys)
|
| | | {
|
| | | var member = friends[key];
|
| | | if (member.OnlineType != 0)
|
| | | {
|
| | | invites.Add(new TeamInvite(member));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void GetFairyMemebers()
|
| | | {
|
| | | invites.Clear();
|
| | | if (PlayerDatas.Instance.fairyData.HasFairy && PlayerDatas.Instance.fairyData.fairy != null)
|
| | | {
|
| | | var myPlayerId = PlayerDatas.Instance.baseData.PlayerID;
|
| | | var fairyMembers = PlayerDatas.Instance.fairyData.fairy.Member;
|
| | | for (int i = 0; i < fairyMembers.Count; i++)
|
| | | {
|
| | | var member = fairyMembers[i];
|
| | | if (member.PlayerID != myPlayerId && member.Exattr2 == 0)
|
| | | {
|
| | | invites.Add(new TeamInvite(member));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void ClearAllApplications()
|
| | | {
|
| | | applications.Clear();
|
| | | if (applicationsChangeEvent != null)
|
| | | {
|
| | | applicationsChangeEvent();
|
| | | }
|
| | |
|
| | | RefreshApplicationRedpoint();
|
| | | }
|
| | |
|
| | | public void OnGetTheirTeams(HB904_tagGCSceneTeamRefresh _teamInfo)
|
| | | {
|
| | | theirTeams.Clear();
|
| | |
|
| | | for (int i = 0; i < _teamInfo.SceneTeamList.Length; i++)
|
| | | {
|
| | | theirTeams.Add(new TheirTeam(_teamInfo.SceneTeamList[i]));
|
| | | }
|
| | |
|
| | | theirTeams.Sort(
|
| | | (TheirTeam a, TheirTeam b) =>
|
| | | {
|
| | | return a.memberCount < 4 && a.memberCount > b.memberCount ? -1 : 1;
|
| | | }
|
| | | );
|
| | |
|
| | | if (theirTeamListRefreshEvent != null)
|
| | | {
|
| | | theirTeamListRefreshEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnGetTheirTeams(HB909_tagGCTagMapTeamList _teamInfo)
|
| | | {
|
| | | theirTeams.Clear();
|
| | |
|
| | | for (int i = 0; i < _teamInfo.TeamList.Length; i++)
|
| | | {
|
| | | theirTeams.Add(new TheirTeam((int)_teamInfo.TagMapID, _teamInfo.IsTagEx == 1 ? _teamInfo.TagMapEx : -1, _teamInfo.MatchState == 1, _teamInfo.TeamList[i]));
|
| | | }
|
| | |
|
| | | theirTeams.Sort(
|
| | | (TheirTeam a, TheirTeam b) =>
|
| | | {
|
| | | return a.memberCount < 4 && a.memberCount > b.memberCount ? -1 : 1;
|
| | | }
|
| | | );
|
| | |
|
| | | if (theirTeamListRefreshEvent != null)
|
| | | {
|
| | | theirTeamListRefreshEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnGetNearByPlayers(HB908_tagGCRecommendNearbyPlayerList _playerListInfo)
|
| | | {
|
| | | invites.Clear();
|
| | | for (int i = 0; i < _playerListInfo.PlayerCount; i++)
|
| | | {
|
| | | invites.Add(new TeamInvite(_playerListInfo.PlayerList[i]));
|
| | | }
|
| | |
|
| | | if (teamInvitesUpdateEvent != null)
|
| | | {
|
| | | teamInvitesUpdateEvent(TeamInviteType.NearBy);
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnGetPlayerShortInfo(HB309_tagGCAnswerPlayerShortInfo _inTeamInfo)
|
| | | {
|
| | | if (playerInTeamAnswerEvent != null)
|
| | | {
|
| | | playerInTeamAnswerEvent((int)_inTeamInfo.PlayerID, _inTeamInfo.IsInTeam == 1);
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnTeamClear(H0905_tagTeamClear _serverInfo)
|
| | | {
|
| | | myTeam.teamId = 0;
|
| | | myTeam.ClearMembers();
|
| | |
|
| | | if (!myTeam.iamCaptainer)
|
| | | {
|
| | | ClearAllApplications();
|
| | | }
|
| | |
|
| | | if (myTeamRefreshEvent != null)
|
| | | {
|
| | | myTeamRefreshEvent();
|
| | | }
|
| | |
|
| | | memberCountRedpoint.state = myTeam.memberCount > 0 ? RedPointState.Quantity : RedPointState.None;
|
| | | memberCountRedpoint.count = myTeam.memberCount;
|
| | | }
|
| | |
|
| | | public void OnTeammateLeave(H0906_tagPlayerLeaveTeamMsg _leaveTeam)
|
| | | {
|
| | | if (_leaveTeam.PlayerID == PlayerDatas.Instance.baseData.PlayerID)
|
| | | {
|
| | | if (!myTeam.iamCaptainer)
|
| | | {
|
| | | ClearAllApplications();
|
| | | }
|
| | |
|
| | | myTeam.ClearMembers();
|
| | | if (myTeamRefreshEvent != null)
|
| | | {
|
| | | myTeamRefreshEvent();
|
| | | }
|
| | |
|
| | | if (_leaveTeam.Reason == 1)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("TeamKick");
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | Teammate mate;
|
| | | if (myTeam.TryGetMemberByPlayerId((int)_leaveTeam.PlayerID, out mate))
|
| | | {
|
| | | switch (_leaveTeam.Reason)
|
| | | {
|
| | | case 0:
|
| | | SysNotifyMgr.Instance.ShowTip("LeaveProcession", mate.mateName);
|
| | | break;
|
| | | case 1:
|
| | | SysNotifyMgr.Instance.ShowTip("LeaveProcession", mate.mateName);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (teammateLeaveEvent != null)
|
| | | {
|
| | | teammateLeaveEvent((int)_leaveTeam.PlayerID);
|
| | | }
|
| | |
|
| | | memberCountRedpoint.state = myTeam.memberCount > 0 ? RedPointState.Quantity : RedPointState.None;
|
| | | memberCountRedpoint.count = myTeam.memberCount;
|
| | | }
|
| | |
|
| | | public void OnTeammateOnOffLine(H0912_tagTeamMemberLoginInfo _loginInfo)
|
| | | {
|
| | |
|
| | | Teammate mate;
|
| | | if (myTeam.TryGetMemberByPlayerId((int)_loginInfo.PlayerID, out mate))
|
| | | {
|
| | | mate.online = _loginInfo.Type == 1;
|
| | | switch (_loginInfo.Type)
|
| | | {
|
| | | case 0:
|
| | | SysNotifyMgr.Instance.ShowTip("XW_JZ_LeaguerOnline", mate.mateName);
|
| | | break;
|
| | | case 1:
|
| | | SysNotifyMgr.Instance.ShowTip("XW_JZ_LeaguerLeaveline", mate.mateName);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (teammateOnOffLineEvent != null)
|
| | | {
|
| | | teammateOnOffLineEvent((int)_loginInfo.PlayerID);
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnTeammateChangeMap(H0913_tagTeamMemberChangeMap _changeMap)
|
| | | {
|
| | | Teammate mate;
|
| | | if (myTeam.TryGetMemberByPlayerId((int)_changeMap.PlayerID, out mate))
|
| | | {
|
| | | mate.UpdateMap(_changeMap);
|
| | | }
|
| | | if (teammateChangeMapEvent != null)
|
| | | {
|
| | | teammateChangeMapEvent((int)_changeMap.PlayerID);
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnGetApplication(HB907_tagGCRequestJoinTeam _serverInfo)
|
| | | {
|
| | | if (!FindApplication((int)_serverInfo.PlayerID))
|
| | | {
|
| | | applications.Insert(0, new TeamApplication(_serverInfo));
|
| | | RefreshApplicationRedpoint();
|
| | | if (applicationsChangeEvent != null)
|
| | | {
|
| | | applicationsChangeEvent();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnGetInvitation(HB901_tagGCInviteJoinTeamInfo _serverInfo)
|
| | | {
|
| | | for (int i = 0; i < invitations.Count; i++)
|
| | | {
|
| | | var invitation = invitations[i];
|
| | | if (invitation.playerId == _serverInfo.PlayerID)
|
| | | {
|
| | | invitations.RemoveAt(i);
|
| | | }
|
| | | }
|
| | |
|
| | | invitations.Insert(0, new TeamInvitation(_serverInfo));
|
| | |
|
| | | RefreshInvitationRedpoint();
|
| | | if (invitationsChangeEvent != null)
|
| | | {
|
| | | invitationsChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnUpdateTeammateInfos(HB902_tagGCTeamMemberInfo _serverInfo)
|
| | | {
|
| | | var oldInTeam = myTeam.inTeam;
|
| | |
|
| | | myTeam.teamId = (int)_serverInfo.TeamID;
|
| | | myTeam.mission = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx);
|
| | | myTeam.levelMin = _serverInfo.ReqMinLV;
|
| | | myTeam.levelMax = _serverInfo.ReqMaxLV;
|
| | |
|
| | | levelMinBuf = _serverInfo.ReqMinLV;
|
| | | levelMaxBuf = _serverInfo.ReqMaxLV;
|
| | | missionBuf = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx);
|
| | |
|
| | | var mates = new List<Teammate>();
|
| | | for (int i = 0; i < _serverInfo.MemberList.Length; i++)
|
| | | {
|
| | | var member = _serverInfo.MemberList[i];
|
| | | mates.Add(new Teammate(member));
|
| | |
|
| | | Teammate teammate;
|
| | | if (!myTeam.TryGetMemberByPlayerId((int)member.PlayerID, out teammate))
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_543685", member.Name);
|
| | | }
|
| | | }
|
| | |
|
| | | myTeam.UpdateMembers(mates);
|
| | |
|
| | | if (!myTeam.iamCaptainer)
|
| | | {
|
| | | ClearAllApplications();
|
| | | }
|
| | |
|
| | | if (myTeamRefreshEvent != null)
|
| | | {
|
| | | myTeamRefreshEvent();
|
| | | }
|
| | |
|
| | | if (!oldInTeam && myTeam.inTeam)
|
| | | {
|
| | | if (createTeamEvent != null)
|
| | | {
|
| | | createTeamEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | if (serverInited)
|
| | | {
|
| | | if (!oldInTeam && myTeam.inTeam)
|
| | | {
|
| | | if (!WindowCenter.Instance.CheckOpen("NewBieWin") && !WindowCenter.Instance.CheckOpen("TreasureNewGotWin"))
|
| | | {
|
| | | if (!WindowCenter.Instance.CheckOpen("MyTeamWin"))
|
| | | {
|
| | | WindowCenter.Instance.Open<TeamFrameWin>(false, 1);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | memberCountRedpoint.state = myTeam.memberCount > 0 ? RedPointState.Quantity : RedPointState.None;
|
| | | memberCountRedpoint.count = myTeam.memberCount;
|
| | | }
|
| | |
|
| | | public void OnUpdateTeammission(HB903_tagGCTeamInfoChange _serverInfo)
|
| | | {
|
| | | myTeam.mission = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx);
|
| | | myTeam.levelMin = _serverInfo.ReqMinLV;
|
| | | myTeam.levelMax = _serverInfo.ReqMaxLV;
|
| | |
|
| | | levelMinBuf = _serverInfo.ReqMinLV;
|
| | | levelMaxBuf = _serverInfo.ReqMaxLV;
|
| | | missionBuf = new TeamMission((int)_serverInfo.TagMapID, (int)_serverInfo.TagMapEx);
|
| | |
|
| | | if (missionLevelLimitChangeEvent != null)
|
| | | {
|
| | | missionLevelLimitChangeEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnUpdateTeammateInfo(HB905_tagGCTeamMemberRefreshProperty _serverInfo)
|
| | | {
|
| | | switch ((PlayerDataRefresh)_serverInfo.RefreshType)
|
| | | {
|
| | | case PlayerDataRefresh.LV:
|
| | | Teammate mate;
|
| | | if (myTeam.TryGetMemberByPlayerId((int)_serverInfo.PlayerID, out mate))
|
| | | {
|
| | | mate.level = (int)_serverInfo.Value;
|
| | | if (teammateLevelUpEvent != null)
|
| | | {
|
| | | teammateLevelUpEvent(mate.id);
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnUpdateDungeonPrepareState(HB911_tagGCTeamEnterFBPrepare _serverInfo)
|
| | | {
|
| | | if (!AssetSource.sceneFromEditor && VersionConfig.Get().assetAccess != InstalledAsset.IngoreDownLoad && !AssetVersionUtility.unPriorAssetDownLoadDone)
|
| | | {
|
| | | ReqeustPrepareEnterDungeon(false);
|
| | | return;
|
| | | }
|
| | |
|
| | | teamPrepare.UpdatePrepareState(_serverInfo);
|
| | | if (teamPrepare.isError)
|
| | | {
|
| | | WindowCenter.Instance.Close<TeamPrepareWin>();
|
| | | }
|
| | | else
|
| | | {
|
| | | if (memberPrepareStateChangeEvent != null)
|
| | | {
|
| | | memberPrepareStateChangeEvent();
|
| | | }
|
| | |
|
| | | if (teamPrepare.IsReject())
|
| | | {
|
| | | WindowCenter.Instance.Close<TeamPrepareWin>();
|
| | | }
|
| | | else
|
| | | {
|
| | | Teammate mate;
|
| | | if (myTeam.TryGetMember(0, out mate))
|
| | | {
|
| | | if (teamPrepare.OnlyCaptainerPrepared(mate.id))
|
| | | {
|
| | | if (!WindowCenter.Instance.CheckOpen<TeamPrepareWin>())
|
| | | {
|
| | | prepareBeginTime = DateTime.Now;
|
| | | WindowCenter.Instance.Open<TeamPrepareWin>();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | public bool IsMissionUnLock(int _mapId, int _mapEx)
|
| | | {
|
| | | if (_mapId == NONE_MISSION || _mapId == CURRENTMAP_MISSION)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | else
|
| | | {
|
| | | var dungeonId = dungeonModel.DungeonMap(_mapId, _mapEx);
|
| | | var dungeonConfig = ConfigManager.Instance.GetTemplate<DungeonConfig>(dungeonId);
|
| | | return PlayerDatas.Instance.baseData.LV >= dungeonConfig.LVLimitMin;
|
| | | }
|
| | | }
|
| | |
|
| | | private bool FindInvitation(int _playerId)
|
| | | {
|
| | | for (int i = 0; i < invitations.Count; i++)
|
| | | {
|
| | | var invitation = invitations[i];
|
| | | if (invitation.playerId == _playerId)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | private bool FindApplication(int _playerId)
|
| | | {
|
| | | for (int i = 0; i < applications.Count; i++)
|
| | | {
|
| | | var application = applications[i];
|
| | | if (application.playerId == _playerId)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | private void RemoveInvitation(int _playerId)
|
| | | {
|
| | | for (int i = 0; i < invitations.Count; i++)
|
| | | {
|
| | | var invitation = invitations[i];
|
| | | if (invitation.playerId == _playerId)
|
| | | {
|
| | | invitations.RemoveAt(i);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void RemoveApplication(int _playerId)
|
| | | {
|
| | | for (int i = 0; i < applications.Count; i++)
|
| | | {
|
| | | var application = applications[i];
|
| | | if (application.playerId == _playerId)
|
| | | {
|
| | | applications.RemoveAt(i);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshInvitationRedpoint()
|
| | | {
|
| | | if (invitations.Count > 1)
|
| | | {
|
| | | invitationRedpoint.state = RedPointState.Quantity;
|
| | | invitationRedpoint.count = invitations.Count;
|
| | | }
|
| | | else
|
| | | {
|
| | | invitationRedpoint.state = invitations.Count > 0 ? RedPointState.Simple : RedPointState.None;
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshApplicationRedpoint()
|
| | | {
|
| | | if (applications.Count > 1)
|
| | | {
|
| | | applicationRedpoint.state = RedPointState.Quantity;
|
| | | applicationRedpoint.count = invitations.Count;
|
| | | }
|
| | | else
|
| | | {
|
| | | applicationRedpoint.state = applications.Count > 0 ? RedPointState.Simple : RedPointState.None;
|
| | | }
|
| | | }
|
| | |
|
| | | private void ParseTeamMission()
|
| | | {
|
| | | teammissions[NONE_MISSION] = new List<int>() { 0 };
|
| | | teammissions[CURRENTMAP_MISSION] = new List<int>() { 0 };
|
| | |
|
| | | var allTeamTargets = ConfigManager.Instance.GetAllValues<TeamTargetConfig>();
|
| | | foreach (var config in allTeamTargets)
|
| | | {
|
| | | List<int> missionGroup;
|
| | | var dataMapId = config.DataMapID;
|
| | |
|
| | | if (!teammissions.TryGetValue(dataMapId, out missionGroup))
|
| | | {
|
| | | teammissions[dataMapId] = missionGroup = new List<int>();
|
| | | }
|
| | | else
|
| | | {
|
| | | missionGroup = teammissions[dataMapId];
|
| | | }
|
| | |
|
| | | missionGroup.AddRange(config.TeamTargetUseLineID);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | serverInited = true;
|
| | | }
|
| | |
|
| | | private void OnMatchingCoolDownEnd()
|
| | | {
|
| | | if (isMatching)
|
| | | {
|
| | | RequestCancelAutoMatchTeam();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|