示例#1
0
        //离开
        public void MsgLeaveRoom(Player player, ProtocolBase protoBase)
        {
            ProtocolBytes protocol = new ProtocolBytes();

            protocol.AddString("LeaveRoom");
            //条件检测
            if (player.tempData.status != PlayerTempData.Status.Room)
            {
                protocol.AddInt(-1);
                player.Send(protocol);
                Console.WriteLine("MsgLeaveRoom status err" + player.id);
                return;
            }
            protocol.AddInt(0);
            player.Send(protocol);
            Room room = player.tempData.room;

            RoomMgr.instance.LeaveRoom(player);

            if (room != null)
            {
                room.Broadcast(room.GetRoomInfo());
            }
        }
示例#2
0
        //start
        public void MsgStartFight(Player player, ProtocolBase protoBase)
        {
            ProtocolBytes protocol = new ProtocolBytes();

            protocol.AddString("StartFight");

            if (player.tempData.status != PlayerTempData.Status.Room)
            {
                Console.WriteLine("MsgStartFight status err " + player.id);
                protocol.AddInt(-1);
                player.Send(protocol);
                return;
            }

            if (!player.tempData.isOwner)
            {
                Console.WriteLine("MsgStartFight owner err " + player.id);
                protocol.AddInt(-1);
                player.Send(protocol);
                return;
            }

            Room room = player.tempData.room;

            if (!room.CanStart())
            {
                Console.WriteLine("MsgStartFight Canstart err " + player.id);
                protocol.AddInt(-1);
                player.Send(protocol);
                return;
            }

            protocol.AddInt(0);
            player.Send(protocol);
            room.StartFight();
        }
示例#3
0
        //更新信息
        public void MsgUpdateInfo(Player player, ProtocolBase protoBase)
        {
            //获取分数
            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protoBase;
            string        protoname = protocol.GetString(start, ref start);
            float         x         = protocol.GetFloat(start, ref start);
            float         y         = protocol.GetFloat(start, ref start);
            float         z         = protocol.GetFloat(start, ref start);
            int           score     = protocol.GetInt(start, ref start);

            Scene.Scener.instance.UpdateInfo(protoname, x, y, z, score);

            //广播
            ProtocolBytes protocolret = new ProtocolBytes();

            protocolret.AddString("UpdateInfo");
            protocolret.AddString(player.id);
            protocolret.AddFloat(x);
            protocolret.AddFloat(y);
            protocolret.AddFloat(z);
            protocolret.AddInt(score);
            ServNet.instance.Broadcast(protocolret);
        }
 public void MsgHeatBeat(Conn conn, ProtocolBase protoBase)
 {
     conn.lastTickTime = Sys.Getimetamp();
     Console.WriteLine("[更新心跳时间]" + conn.GetAdress());
 }
示例#5
0
 //获得列表
 public void MsgGetRoomList(Player player, ProtocolBase protoBase)
 {
     player.Send(RoomMgr.instance.GetRoomList());
 }
示例#6
0
 //发送协议
 public void Send(ProtocolBase protocol)
 {
     ServNet.instance.Send(this, protocol);
 }
示例#7
0
 //获取列表
 public void MsgGetList(Player player, ProtocolBase protocol)
 {
     Scene.Scener.instance.SendPlayerList(player);
 }