Exemplo n.º 1
0
        public void MsgUpdateRot(Player player, ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;
            string        name  = proto.GetString(start, ref start);
            float         x     = proto.GetFloat(start, ref start);
            float         y     = proto.GetFloat(start, ref start);
            float         z     = proto.GetFloat(start, ref start);

            float w = proto.GetFloat(start, ref start);
            //广播
            ProtocolBytes protocolRet = new ProtocolBytes();

            protocolRet.AddString("UpdateRot");
            protocolRet.AddString(player.id);
            protocolRet.AddFloat(x);
            protocolRet.AddFloat(y);
            protocolRet.AddFloat(z);
            protocolRet.AddFloat(w);
            ServNet.getInstance().Broadcast(protocolRet);
        }
Exemplo n.º 2
0
        //设置名字
        public void MsgEditName(Player player, ProtocolBase protocolBase)
        {
            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protocolBase;
            string        protoName = protocol.GetString(start, ref start);
            string        Cname     = protocol.GetString(start, ref start);

            //处理
            player.data.name = Cname;
            protocol         = new ProtocolBytes();
            protocol.AddString("EditName");
            if (DataMgr.instance.SavePlayer(player))
            {
                protocol.AddInt(0);
            }
            else
            {
                protocol.AddInt(-1);
            }
            player.Send(protocol);
        }
Exemplo n.º 3
0
        //创建房间
        public void MsgCreateRoom(Player player, ProtocolBase protoBase)
        {
            int           start     = 0;
            ProtocolBytes protocol  = new ProtocolBytes();
            string        protoName = protocol.GetString(start, ref start);

            //Room.instance.roomname = protocol.GetString(start, ref start);
            protocol.AddString("CreateRoom");
            //条件检测
            if (player.tempData.status != PlayerTempData.Status.None)
            {
                Console.WriteLine("MsgCreateRoom Fail " + player.username);
                protocol.AddInt(-1);
                player.Send(protocol);
                return;
            }
            RoomMgr.instance.CreateRoom(player);
            protocol.AddInt(0);
            player.Send(protocol);
            player.tempData.team = 1;
            Console.WriteLine("MsgCreateRoom Ok " + player.username);
        }
Exemplo n.º 4
0
        //同步玩家单元
        public void MsgUpdateUnitInfo(Player player, ProtocolBase protoBase)
        {
            //获取数值
            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protoBase;
            string        protoName = protocol.GetString(start, ref start);
            float         posX      = protocol.GetFloat(start, ref start);
            float         posY      = protocol.GetFloat(start, ref start);
            float         posZ      = protocol.GetFloat(start, ref start);
            float         rotX      = protocol.GetFloat(start, ref start);
            float         rotY      = protocol.GetFloat(start, ref start);
            float         rotZ      = protocol.GetFloat(start, ref start);

            //获取房间
            if (player.tempData.status != PlayerTempData.Status.Fight)
            {
                return;
            }
            Room room = player.tempData.room;

            //作弊校验 略
            player.tempData.posX           = posX;
            player.tempData.posY           = posY;
            player.tempData.posZ           = posZ;
            player.tempData.lastUpdateTime = Sys.GetTimeStamp();
            //广播
            ProtocolBytes protocolRet = new ProtocolBytes();

            protocolRet.AddString("UpdateUnitInfo");
            protocolRet.AddString(player.username);
            protocolRet.AddFloat(posX);
            protocolRet.AddFloat(posY);
            protocolRet.AddFloat(posZ);
            protocolRet.AddFloat(rotX);
            protocolRet.AddFloat(rotY);
            protocolRet.AddFloat(rotZ);
            room.Broadcast(protocolRet);
        }
Exemplo n.º 5
0
        //更新信息
        public void MsgUpdateInfo(Player player, ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;
            string        name  = proto.GetString(start, ref start);
            float         x     = proto.GetFloat(start, ref start);
            float         y     = proto.GetFloat(start, ref start);
            float         z     = proto.GetFloat(start, ref start);
            int           score = player.data.score;

            Scene.instance.UpdateInfo(player.id, 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.getInstance().Broadcast(protocolRet);
        }
Exemplo n.º 6
0
        //开始战斗
        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.username);
                protocol.AddInt(-1);
                player.Send(protocol);
                return;
            }

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

            Room room = player.tempData.room;

            if (!room.CanStart())
            {
                Console.WriteLine("MsgStartFight CanStart err " + player.username);
                protocol.AddInt(-1);
                player.Send(protocol);
                return;
            }
            //开始战斗
            protocol.AddInt(0);
            player.Send(protocol);
            room.StartFight();
        }
Exemplo n.º 7
0
 public void MsgGetLoadItemMsg(Player player, ProtocolBase protoBase)
 {
     ServerSQL.instance.LoadItemMsg();
 }
Exemplo n.º 8
0
 public void MsgHeartBeat(Conn conn, ProtocolBase protocolBase)
 {
     conn.lastTickTime = Sys.GetTimeStamp();
     Console.WriteLine("[更新心跳时间]" + conn.GetAdress());
 }
Exemplo n.º 9
0
        // Protocol: GetRoomList
        // Rec Args: None
        // Return: int[roomCount] int[room1playercount] int[room1status] int[room2playercount] int[oom2status]...
        public void MsgGetRoomList(Player player, ProtocolBase protoBase)
        {
            Console.WriteLine("[HandleRoomMsg.MsgGetRoomList] Receive GetRoomList protocol from " + player.id);

            player.Send(RoomMgr.instance.GetRoomList());
        }
 // Protocol: HeartBeat
 // Rec Args: None
 // Return: None
 public void MsgHeartBeat(Conn conn, ProtocolBase protoBase)
 {
     conn.lastTickTime = Sys.GetTimeStamp();
     Console.WriteLine("[HandleConnMsg.MsgHeartBeat] Update HeartBeat Time: " + conn.GetAddress() + " : " + conn.lastTickTime.ToString());
 }
Exemplo n.º 11
0
        public void MsgGetRoomList(Player player, ProtocolBase protocol)
        {
            ProtocolBytes proto = (ProtocolBytes)RoomMgr.instance.GetRoomList();

            player.Send(proto);
        }
Exemplo n.º 12
0
 //处理心跳协议
 public void MsgHeatBeat(Conn conn, ProtocolBase protoBase)
 {
     conn.lastTickTime = Sys.GetTimeStamp();
 }
Exemplo n.º 13
0
 public void Send(ProtocolBase protoBase)
 {
     ServNet.instance.Send(this, protoBase);
 }
Exemplo n.º 14
0
 //获取玩家列表
 public void MsgGetList(Player player, ProtocolBase protoBase)
 {
     Scene.instance.SendPlayerList(player);
 }
Exemplo n.º 15
0
 //获取玩家输赢信息
 public void MsgGetInfo(Player player, ProtocolBase protocol)
 {
     player.Send(player.GetInfo());
 }
Exemplo n.º 16
0
 //获取房间列表
 public void MsgGetRoomList(Player player, ProtocolBase protoBase)
 {
     player.Send(RoomMgr.instance.GetRoomList());
 }
Exemplo n.º 17
0
 public void MsgKeyUp(Player player, ProtocolBase protocol)
 {
     ServNet.getInstance().Broadcast(protocol);
 }
 //发送协议
 public void Send(ProtocolBase protocol)
 {
     ServerTCP.instance.Send(this, protocol);
 }
Exemplo n.º 19
0
 //发送协议
 public void Send(ProtocolBase protocol)
 {
     ServNet.getInstance().Send(this, protocol);
 }