Example #1
0
        /// <summary>
        /// 玩家请求获取当前战场快照
        /// </summary>
        internal void HandleRequestSnapshot(Battle battle, Protos.GC2BS_RequestSnapshot request, Protos.BS2GC_RequestSnapshotRet ret)
        {
            FrameSnapshot snapshot = battle.GetSnapshot(request.Frame);

            ret.ReqFrame = request.Frame;
            ret.CurFrame = battle.frame;
            if (snapshot != null)
            {
                ret.Snapshot = snapshot.data;
            }
        }
Example #2
0
        public ErrorCode OnGc2BsRequestSnapShot(NetSessionBase session, Google.Protobuf.IMessage message)
        {
            Protos.GC2BS_RequestSnapshot    request = (Protos.GC2BS_RequestSnapshot)message;
            Protos.BS2GC_RequestSnapshotRet ret     = ProtoCreator.R_GC2BS_RequestSnapshot(request.Opts.Pid);

            BSUser user = BS.instance.userMgr.GetUser(session.id);

            if (user == null)
            {
                ret.Result = Protos.BS2GC_RequestSnapshotRet.Types.EResult.InvalidUser;
            }
            else
            {
                BS.instance.battleMgr.HandleRequestSnapshot(user.battle, request, ret);
            }
            BS.instance.netSessionMgr.Send(session.id, ret);

            return(ErrorCode.Success);
        }