Exemple #1
0
        //获取客户端位置请求的处理的代码
        public void OnAddBombReceived(Client peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            //接收位置并保持起来
            byte[] bytes = (byte[])DictTool.GetValue <byte, object>(operationRequest.Parameters, 1);
            ProtoData.AddBombC2S addBombC2S = BinSerializer.DeSerialize <ProtoData.AddBombC2S>(bytes);

            ProtoData.AddBombS2CEvt addBombS2CEvt = new ProtoData.AddBombS2CEvt();
            addBombS2CEvt.username = peer.playerData.username;
            addBombS2CEvt.bombType = addBombC2S.bombType;
            addBombS2CEvt.bombId   = BombMgr.Instance.GetBombId();
            addBombS2CEvt.startX   = addBombC2S.startX;
            addBombS2CEvt.startY   = addBombC2S.startY;
            addBombS2CEvt.startZ   = addBombC2S.startZ;
            addBombS2CEvt.endX     = addBombC2S.endX;
            addBombS2CEvt.endY     = addBombC2S.endY;
            addBombS2CEvt.endZ     = addBombC2S.endZ;

            byte[] bytes2 = BinSerializer.Serialize(addBombS2CEvt);
            foreach (Client tempPeer in ClientMgr.Instance.BattlePeerList)
            {
                if (!string.IsNullOrEmpty(tempPeer.playerData.username))
                {
                    EventData ed = new EventData((byte)MessageCode.AddBomb);
                    Dictionary <byte, object> data = new Dictionary <byte, object>();
                    data.Add(1, bytes2);                    // 把新进来的用户名传递给其它客户端
                    ed.Parameters = data;
                    tempPeer.SendEvent(ed, sendParameters); // 发送事件
                }
            }

            BombData bombData = new BombData();

            bombData.username     = peer.playerData.username;
            bombData.nickName     = peer.playerData.nickname;
            bombData.bombId       = addBombS2CEvt.bombId;
            bombData.damageRange  = addBombC2S.damageRange;
            bombData.durationTime = addBombC2S.durationTime;
            bombData.endX         = addBombS2CEvt.endX;
            bombData.endY         = addBombS2CEvt.endY;
            bombData.endZ         = addBombS2CEvt.endZ;

            ServerMgr.Instance.bombUpdate.AddBomb(bombData);
        }
Exemple #2
0
        //发起炸弹信息请求
        public void SendAddBombRequest(BombData bombData)
        {
            ProtoData.AddBombC2S addBombC2S = new ProtoData.AddBombC2S();
            addBombC2S.bombType     = (int)bombData.type;
            addBombC2S.durationTime = bombData.durationTime;
            addBombC2S.damageRange  = bombData.damageRange;
            addBombC2S.startX       = bombData.startPos.x;
            addBombC2S.startY       = bombData.startPos.y;
            addBombC2S.startZ       = bombData.startPos.z;
            addBombC2S.endX         = bombData.endPos.x;
            addBombC2S.endY         = bombData.endPos.y;
            addBombC2S.endZ         = bombData.endPos.z;
            byte[] bytes = BinSerializer.Serialize(addBombC2S);

            Dictionary <byte, object> data = new Dictionary <byte, object>();

            data.Add(1, bytes);

            PhotonEngine.Peer.OpCustom((byte)MessageCode.AddBomb, data, true);//把添加炸弹信息传递给服务器
        }