Esempio n. 1
0
        public void DoReady(Conn client, byte[] buffer)
        {
            var        simpleInt = NetUtil.ProtobufDeserialize <simpledata.SimpleInt>(buffer);
            int        roomid    = simpleInt.simple;
            NiuNiuGame game      = nnGames[roomid];

            game.PlayerReady(client);
        }
Esempio n. 2
0
        public void DoLeave(Conn client, byte[] buffer)
        {
            var simpleInt = NetUtil.ProtobufDeserialize <simpledata.SimpleInt>(buffer);
            int roomid    = simpleInt.simple;

            NiuNiuGame nngame = nnGames[roomid];

            if (nngame.RoomLeave(client))
            {
                nnGames.Remove(roomid);
                LogUtil.LogInfo("******  房间解散 :" + roomid);
            }
        }
Esempio n. 3
0
        public void DoCreate(Conn client, byte[] buffer)
        {
            int roomid = new Random().Next(1000, 10000);

            while (nnGames.ContainsKey(roomid))
            {
                roomid = new Random().Next(1000, 10000);
            }


            var newGame = new NiuNiuGame(roomid);

            newGame.RoomCreate(client);
            nnGames.Add(roomid, newGame);
            LogUtil.LogInfo("******  创建房间 :" + roomid);
        }
Esempio n. 4
0
        public void DoJion(Conn client, byte[] buffer)
        {
            var simpleInt = NetUtil.ProtobufDeserialize <simpledata.SimpleInt>(buffer);
            int jroomid   = simpleInt.simple;


            if (!nnGames.ContainsKey(jroomid))
            {
                var simpleStr = new simpledata.SimpleString();
                simpleStr.simple = string.Format("加入房间失败:房间号{0}不存在!", jroomid);
                byte[] data = NetUtil.ProtobufSerialize(simpleStr);
                client.SendAsync((ushort)MainID.NiuNiu, (ushort)NiuNiuID.JionFailure, data);
                return;
            }

            NiuNiuGame jGame = nnGames[jroomid];

            jGame.RoomJion(client);
        }