Exemple #1
0
        public void MsgLogin(Conn conn, ProtocolBase protoBase)
        {
            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protoBase;
            string        protoName = protocol.GetString(start, ref start);
            string        id        = protocol.GetString(start, ref start);
            string        pw        = protocol.GetString(start, ref start);
            string        strFormat = "[ 收到登录协议 ]" + conn.GetAdress();

            Console.WriteLine(strFormat + " 用户名: " + id + " 密码: " + pw);

            ProtocolBytes protocolRet = new ProtocolBytes();

            protocolRet.AddString("Login");
            int ckstate = DataMgr.instance.CheckPassWord(id, pw);

            if (ckstate != 200)
            {
                protocolRet.AddInt(ckstate);
                conn.Send(protocolRet);
                return;
            }

            ProtocolBytes protocolLogout = new ProtocolBytes();

            protocolLogout.AddString("Logout");
            int kfstate = Player.KickOff(id, protocolLogout);

            if (kfstate != 200)
            {
                protocolRet.AddInt(kfstate);
                conn.Send(protocolRet);
                return;
            }

            PlayerData playerData = DataMgr.instance.GetPlayerData(id);

            if (playerData == null)
            {
                protocolRet.AddInt(502);
                conn.Send(protocolRet);
                return;
            }
            conn.player      = new Player(id, conn);
            conn.player.data = playerData;

            ServNet.instance.handlePlayerEvent.OnLogin(conn.player);

            protocolRet.AddInt(200);
            conn.Send(protocolRet);
        }
Exemple #2
0
        public void MsgUpdateInfo(Player player, ProtocolBase protoBase)
        {
            Room room = player.tempData.room;

            if (room == null)
            {
                return;
            }
            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);

            //int score = protocol.GetInt(start, ref start);
            room.UpdateInfo(player.id, x, y);

            ProtocolBytes protocolRet = new ProtocolBytes();

            protocolRet.AddString("UpdateInfo");
            protocolRet.AddString(player.id);
            protocolRet.AddFloat(x);
            protocolRet.AddFloat(y);
            //protocolRet.AddInt(score);
            room.Broadcast(protocolRet);
        }
Exemple #3
0
        public void MsgRegister(Conn conn, ProtocolBase protoBase)
        {
            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protoBase;
            string        protoName = protocol.GetString(start, ref start);
            string        id        = protocol.GetString(start, ref start);
            string        pw        = protocol.GetString(start, ref start);
            string        strFormat = "[ 收到注册协议 ]" + conn.GetAdress();

            Console.WriteLine(strFormat + " 用户名: " + id + " 密码: " + pw);

            protocol = new ProtocolBytes();
            protocol.AddString("Register");

            protocol.AddInt(DataMgr.instance.Register(id, pw));

            DataMgr.instance.CreatePlayer(id);
            conn.Send(protocol);
        }
Exemple #4
0
        public void MsgKilledHuman(Player player, ProtocolBase protoBase)
        {
            if (!player.tempData.isKiller)
            {
                return;
            }
            Room room = player.tempData.room;

            if (room == null)
            {
                return;
            }

            int           start     = 0;
            ProtocolBytes protocol  = (ProtocolBytes)protoBase;
            string        protoName = protocol.GetString(start, ref start);
            string        humanID   = protocol.GetString(start, ref start);

            room.KilledHuman(room.list[humanID]);
        }