Example #1
0
        public void CreateGroup(CreateGroupPara para, Action <ResponseEvent> callback)
        {
            GroupPlayerInfo playerInfo = new GroupPlayerInfo
            {
                Id   = RequestHeader.PlayerId,
                Name = para.PlayerInfo.Name,
                CustomGroupPlayerProfile = para.PlayerInfo.CustomGroupPlayerProfile,
                CustomGroupPlayerStatus  = para.PlayerInfo.CustomGroupPlayerStatus
            };

            CreateGroupReq createGroupReq = new CreateGroupReq
            {
                GroupName        = para.GroupName,
                GroupType        = para.GroupType,
                MaxPlayers       = para.MaxPlayers,
                CustomProperties = para.CustomProperties,
                IsForbidJoin     = para.IsForbidJoin,
                IsPersistent     = para.IsPersistent,
                PlayerInfo       = playerInfo,
            };

            Action <ResponseEvent> cb = eve =>
            {
                this.GroupUtil.SaveGroupInfo(eve, ((CreateGroupRsp)eve.Data)?.GroupInfo);
                callback?.Invoke(eve);
            };

            Core.Group.CreateGroup(createGroupReq, cb);
        }
Example #2
0
        public void JoinGroup(JoinGroupPara para, Action <ResponseEvent> callback)
        {
            GroupPlayerInfo playerInfo = new GroupPlayerInfo
            {
                Id   = RequestHeader.PlayerId,
                Name = para.PlayerInfo.Name,
                CustomGroupPlayerProfile = para.PlayerInfo.CustomGroupPlayerProfile,
                CustomGroupPlayerStatus  = para.PlayerInfo.CustomGroupPlayerStatus
            };

            JoinGroupReq joinGroupReq = new JoinGroupReq
            {
                GroupId    = this.GroupInfo.Id,
                PlayerInfo = playerInfo,
            };

            Action <ResponseEvent> cb = eve =>
            {
                this.GroupUtil.SaveGroupInfo(eve, ((JoinGroupRsp)eve.Data)?.GroupInfo);
                callback?.Invoke(eve);
            };

            Core.Group.JoinGroup(joinGroupReq, cb);
        }
Example #3
0
        public void TriggerNetWorkBroadcast(ChangePlayerNetworkStateBst bst, string bstSeq)
        {
            if (this._group?.GroupInfo?.Id + "" == "")
            {
                return;
            }

            Action <GroupInfo, string> action = (groupInfo, seq) =>
            {
                if (groupInfo == null)
                {
                    return;
                }

                if (groupInfo.Id != this._group?.GroupInfo?.Id)
                {
                    return;
                }

                GroupPlayerInfo groupPlayerInfo = null;

                foreach (var playerInfo in groupInfo.GroupPlayerList)
                {
                    if (((GroupPlayerInfo)playerInfo).Id == bst.ChangePlayerId)
                    {
                        groupPlayerInfo = (GroupPlayerInfo)playerInfo;
                    }
                }

                if (groupPlayerInfo == null)
                {
                    return;
                }

                if (groupPlayerInfo.CommonGroupNetworkState != bst.NetworkState)
                {
                    return;
                }

                ChangeGroupPlayerNetworkStateBst stateBst = new ChangeGroupPlayerNetworkStateBst
                {
                    ChangePlayerId = bst.ChangePlayerId,
                    NetworkState   = bst.NetworkState,
                    GroupInfo      = groupInfo
                };

                BroadcastEvent eve = new BroadcastEvent(stateBst, bstSeq + "_" + seq);

                this._group?.OnChangeGroupPlayerNetworkState(eve);
            };

            this._group?.GetGroupDetail(eve =>
            {
                if (eve.Code != ErrCode.EcOk || eve.Data == null)
                {
                    return;
                }

                var rsp       = (GetGroupByGroupIdRsp)eve.Data;
                var groupInfo = rsp.GroupInfo;

                action?.Invoke(groupInfo, eve.Seq);
            });
        }