Esempio n. 1
0
        /// <summary>
        /// 获取角色信息
        /// </summary>
        public byte[] GetCharacterListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            List <CharacterInfo> info = mCharacter.GetCharacterInfoByAccountId(_client.MySQLConn, _client.GetCurAccount.AccountId);

            if (info.Count > 0)
            {
                return(MessageTool.ProtoBufDataSerialize(info));
            }
            else
            {
                CharacterInfo infoInit = new CharacterInfo()
                {
                    AccountId   = _client.GetCurAccount.AccountId,
                    CharacterId = 1001,
                    CurExp      = 0,
                    CurStrength = 0,
                    Level       = 1,
                    Name        = "默认名称",
                    Coin        = 0
                };
                info = new List <CharacterInfo>();
                info.Add(infoInit);
                mCharacter.UpdateOrAddCharacter(_client.MySQLConn, infoInit, true);
                return(MessageTool.ProtoBufDataSerialize(info));
            }
        }
Esempio n. 2
0
 private void RunTimer()
 {
     Thread.Sleep(1000);
     for (int i = 10; i > 0; i--)
     {
         BroadcastMessage(null, ActionCode.ShowTimer, MessageTool.ProtoBufDataSerialize(i));
         Thread.Sleep(1000);
     }
     BroadcastMessage(null, ActionCode.StartPlay, MessageTool.ProtoBufDataSerialize("strat"));
 }
Esempio n. 3
0
        public byte[] GetInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            List <InventoryInfo> receive = mInv.GetInventoryListInfo(_client.MySQLConn, _client.GetCurAccount.AccountId);

            if (receive.Count > 0)
            {
                return(MessageTool.ProtoBufDataSerialize(receive));
            }
            MSGCallBack send = new MSGCallBack(ReturnCode.Fail);

            return(MessageTool.ProtoBufDataSerialize(send));
        }
Esempio n. 4
0
        public byte[] UpdateImgInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            ImgInfo receive = MessageTool.ProtoBufDataDeSerialize <ImgInfo>(_data);

            receive = new ImgInfo()
            {
                AccountId = _client.GetCurAccount.AccountId,
                ImgId     = receive.ImgId,
                ImgPath   = _client.ImgPathDic[receive.ImgId]
            };
            ImgInfo send = mImgDao.AddOrUpdateImgInfo(_client.MySQLConn, receive, false);

            return(MessageTool.ProtoBufDataSerialize(send));
        }
Esempio n. 5
0
        public byte[] GetRoomList(byte[] _data, ClientPeer _client, MainServer _server)
        {
            List <RoomInfo> send = room.GetRoomListInfo(_client.MySQLConn);

            for (int i = 0; i < send.Count; i++)
            {
                _server.RoomList.Add(new RoomManager(_server));
            }
            for (int i = 0; i < _server.RoomList.Count; i++)
            {
                _server.RoomList[i].SetRoomData(send[i]);
            }
            return(MessageTool.ProtoBufDataSerialize(send));
        }
Esempio n. 6
0
        public byte[] GetImgInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            ImgInfo img = mImgDao.GetImgInfo(_client.MySQLConn, _client.GetCurAccount.AccountId);

            if (img == null)
            {
                img = new ImgInfo()
                {
                    AccountId = _client.GetCurAccount.AccountId,
                    ImgId     = 1001,
                    ImgPath   = _client.ImgPathDic[1001]
                };
                mImgDao.AddOrUpdateImgInfo(_client.MySQLConn, img, true);
            }
            return(MessageTool.ProtoBufDataSerialize(img));
        }
Esempio n. 7
0
        /// <summary>
        /// 更新人物信息
        /// </summary>
        public byte[] UpdateCharacterListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            CharacterInfo receive = MessageTool.ProtoBufDataDeSerialize <CharacterInfo>(_data);
            CharacterInfo info    = mCharacter.UpdateOrAddCharacter(_client.MySQLConn, receive, false);

            MSGCallBack send = null;

            if (info != null)
            {
                send = new MSGCallBack(ReturnCode.Success);
            }
            else
            {
                send = new MSGCallBack(ReturnCode.Fail);
            }
            return(MessageTool.ProtoBufDataSerialize(send));
        }
        public byte[] Login(byte[] data, ClientPeer client, MainServer server)
        {
            AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data);
            AccountInfo user   = mAccount.VerifyUser(client.MySQLConn, recive.AccountName, recive.Password);

            MSGCallBack msg;

            if (user == null)
            {
                msg = new MSGCallBack(ReturnCode.Fail);
            }
            else
            {
                client.IsOnLine = true;
                client.SetCurAccountData(user);
                msg = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(msg));
        }
        public byte[] Register(byte[] data, ClientPeer client, MainServer server)
        {
            AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data);

            bool        res = mAccount.GetAccountByAccountId(client.MySQLConn, recive.AccountId);
            MSGCallBack msg;

            if (res)
            {
                msg = new MSGCallBack(ReturnCode.Fail);
            }
            else
            {
                mAccount.AddAccount(client.MySQLConn, recive.AccountId,
                                    recive.AccountName, recive.Password, 1001, client.ImgPathDic[1001]);
                client.IsOnLine = true;
                msg             = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(msg));
        }
Esempio n. 10
0
        /// <summary>
        /// 匹配
        /// </summary>
        public byte[] SatrtMatchingPlayer(byte[] _data, ClientPeer _client, MainServer _server)
        {
            _client.IsMatching = true;
            List <ClientPeer> matchList = new List <ClientPeer>();

            do
            {
                foreach (var account in _server.OnLineAccountList)
                {
                    if (account.IsMatching)
                    {
                        matchList.Add(account);
                    }
                }
            } while (matchList.Count < 3);
            if (matchList.Count >= 3)
            {
                room = _server.CreatRoom(matchList);
            }
            return(MessageTool.ProtoBufDataSerialize("goLobby"));
        }
Esempio n. 11
0
        public byte[] JoinRoom(byte[] _data, ClientPeer _client, MainServer _server)
        {
            RoomInfo    roomInfo = MessageTool.ProtoBufDataDeSerialize <RoomInfo>(_data);
            MSGCallBack sendMsg  = null;

            foreach (var room in _server.RoomList)
            {
                if (roomInfo.RoomId == room.GetRoonInfo.RoomId)
                {
                    if (room.GetRoonInfo.TotalNum >= room.GetRoonInfo.PlayerNum)
                    {
                        _server.JoinRoom(_client, room);
                        sendMsg = new MSGCallBack(ReturnCode.Success);
                    }
                    else
                    {
                        sendMsg = new MSGCallBack(ReturnCode.Fail);
                    }
                }
            }
            return(MessageTool.ProtoBufDataSerialize(sendMsg));
        }
Esempio n. 12
0
        public byte[] UpdateInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            List <InventoryInfo> inv  = MessageTool.ProtoBufDataDeSerialize <List <InventoryInfo> >(_data);
            MSGCallBack          send = null;

            if (!isAdded)
            {
                for (int i = 0; i < inv.Count; i++)
                {
                    mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], true);
                }
                isAdded = true;
                send    = new MSGCallBack(ReturnCode.Success);
            }
            else
            {
                for (int i = 0; i < inv.Count; i++)
                {
                    mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], false);
                }
                send = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(send));
        }