public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { int serverid = mapleBuffer.read <byte>(); int channel = mapleBuffer.read <byte>(); int id = client.UserInfo.Id; Dictionary <CCharacter, Dictionary <short, CItem> > Playerlist = CMapleCharacter.ShowAllCharacter(id, serverid); client.SendDatat(LoginPakcet.ShowPlayList(client, Playerlist, (byte)serverid)); //TODO:获取角色列表(0%) }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { //TODO:游戏聊天(50%) //聊天消息 string Text = mapleBuffer.read <string>(); //管理员命令:!<命令> 参数 //玩家命令:@<命令> 参数 //以空格作为分割.分割1:命令头部,分割2:参数(参数以逗号分割.) string[] commands = Text.Split(" "); if (commands.Length >= 2) { //识别该说话为命令. if (commands[0].StartsWith("!<") && commands[0].EndsWith(">")) { if (client.CharacterInfo.character.Gm >= 0)//只有管理员才能使用命令, { //存在该符号 string Command = commands[0].Trim().TrimStart("!<".ToCharArray()).TrimEnd(">".ToCharArray()); Console.WriteLine("玩家:" + client.CharacterInfo.character.Name + "使用命令:" + Command); Commands.CommandProcessor.Processor.Execute(Command, commands[1].Split(","), client); } } else if (commands[0].StartsWith("@<") && commands[0].EndsWith(">")) { //玩家命令... } } else { client.SendDatat(PlayerPakcet.GetChatText(client.CharacterInfo.character.Id, Text)); } }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { int cid = mapleBuffer.read <int>(); // client.SendDatat(LoginPakcet.getServerIP(new byte[] { 127, 0, 0, 1 }, 7575, cid)); }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { String Name = mapleBuffer.read <string>(); bool ret = Common.Tools.MapleCharacterUtil.getIdByName(Name); client.SendDatat(LoginPakcet.CharNameResponse(Name, !ret)); }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { //TODO:选择服务器(0%) short serverId = mapleBuffer.read <byte>(); client.SendDatat(LoginPakcet.getServerStatus(0)); }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { //TODO:帐号注册(已完成) string UserNmae = mapleBuffer.read <string>(); string UserPass = mapleBuffer.read <string>(); CUserInfo info = new Common.Client.SQL.CUserInfo { Name = mapleBuffer.read <string>(), BirthTime = mapleBuffer.read <string>(), HomePhone = mapleBuffer.read <string>(), }; string[] Text = new string[4]; for (int i = 0; i < 4; i++) { Text[i] = mapleBuffer.read <string>(); } info.Problem = String.Join(",", Text); info.Email = mapleBuffer.read <string>(); info.IDCard = mapleBuffer.read <string>(); info.PhoneId = mapleBuffer.read <string>(); //创建帐号 CUser user = MySqlFactory.GetFactory.Insert <CUser>(new CUser { Name = UserNmae, Passw = UserPass, Gender = mapleBuffer.read <byte>(), } ); if (user == null) { client.SendDatat(LoginPakcet.RegisterAccount(true)); return; } info.accid = user.Id; MySqlFactory.GetFactory.InsertAsync <CUserInfo>(info); }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { //封包: 01 05 00 61 64 6D 69 6E 05 00 61 61 61 61 61 00 00 E0 4C 68 02 E1 D9 62 59 24 00 00 00 00 BF F5 00 00 00 00 //TODO:登陆帐号(5%) CUser user = new CUser() { Name = mapleBuffer.read <string>(), Passw = mapleBuffer.read <string>(), }; //MySqlContext context = new MySqlContext(MySqlFactory.GetFactory);//MySqlFactory.GetFactory.Query<CUser>(); IQuery <CUser> q = MySqlFactory.GetFactory.Query <CUser>(); CUser UserInfo = (CUser)q.Where(a => a.Name.Equals(user.Name)).FirstOrDefault(); if (UserInfo == null) { //client.SendDatat(LoginPakcet.getLoginFailed(5)); //TODO:自动注册功能(100%) client.SendDatat(LoginPakcet.ShowRegister(true)); } else { if (!user.Passw.Equals(UserInfo.Passw)) { System.Console.WriteLine("密码错误.."); client.SendDatat(LoginPakcet.getLoginFailed(4)); return; } //TODO:登陆请求(50%) client.UserInfo = UserInfo; client.SendDatat(LoginPakcet.getAuthSuccessRequest(UserInfo)); //发送全部世界.. for (int i = 0; i < WorldEntity.GetWorld().Count; i++) { client.SendDatat(LoginPakcet.getServerList(WorldEntity.GetWorld()[i])); } client.SendDatat(LoginPakcet.getEndOfServerList()); } }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { byte ChannelId = mapleBuffer.read <byte>(); ChannelInfo state = new ChannelInfo(); Task.Run(async() => { state = (await ChannelServices.sChannelService.GetChannelInfo(ChannelId)); }).Wait(); client.SendDatat(PlayerPakcet.GetChannelChange(state.Address, state.port)); //把该玩家从地图中删除对象. MapleMapFactory.MapFactory.GetMap(client.CharacterInfo.character.MapId).RemovePlayer(client.CharacterInfo); }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { //TODO:游戏登陆(0%) int cid = mapleBuffer.read <int>(); //加载角色信息 CCharacter mapleCharacter = CMapleCharacter.LoadData(cid, client); client.SendDatat(PlayerPakcet.GetCharInfo(ChannelServices.ChannelId, mapleCharacter, client)); Console.WriteLine("角色信息:" + mapleCharacter.Name); //进行添加到地图列表中... MapleMapFactory.MapFactory.GetMap(client.CharacterInfo.character.MapId).AddPlayer(client.CharacterInfo); //CMapleMap.AddPlayer(mapleCharacter.MapId, client.CharacterInfo); }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { //TODO:帐号检查(已完成) CUser user = new CUser() { Name = mapleBuffer.read <string>(), }; if (MySqlFactory.GetFactory.Query <CUser>().Where(a => a.Name.Equals(user.Name) ).FirstOrDefault() == null) { client.SendDatat(LoginPakcet.CheckAccount(user.Name, false)); } else { client.SendDatat(LoginPakcet.CheckAccount(user.Name, true)); } }
public override void ChannelRead(IChannelHandlerContext context, object message) { try { MapleBuffer buffer = new MapleBuffer((byte[])message); if (buffer.Available < 2) { return; } System.Console.WriteLine("封包: {0}", buffer.ToString()); CMapleClient client = context.GetAttribute <CMapleClient>(CMapleClient.attributeKey).Get(); if (client != null) { short packetId = buffer.read <byte>(); CommonGlobal.Run(packetId, buffer, client); } } catch (Exception e) { System.Console.WriteLine("错误:" + e); } }
public override void Handle(MapleBuffer mapleBuffer, CMapleClient client) { //封包: 0B 08 00 78 7A 6B 6D 78 64 61 35 [20 4E 00 00] [4E 75 00 00] [82 DE 0F 00] [A2 2C 10 00] [81 5B 10 00] [F0 DD 13 00] 04 06 0A 05 CCharacter character = new CCharacter() { Name = mapleBuffer.read <string>(), Face = mapleBuffer.read <int>(), Hair = mapleBuffer.read <int>(), Userid = client.UserInfo.Id, Party = 1, Gm = 0, Hp = 50, Mp = 50, MapId = 0, Maxhp = 50, Maxmp = 50, Job = 0, Sp = 0, World = 0, Level = 1, Exp = 0, }; int[] Euqip = new int[4]; for (int i = 0; i < Euqip.Length; i++) { Euqip[i] = mapleBuffer.read <int>(); } Dictionary <short, int> dictionary = new Dictionary <short, int>(); for (int i = 0; i < Euqip.Length; i++) { switch (i) { case 0: dictionary.Add(-5, Euqip[i]); break; case 1: dictionary.Add(-6, Euqip[i]); break; case 2: dictionary.Add(-7, Euqip[i]); break; case 3: dictionary.Add(-9, Euqip[i]); break; } } //dictionary.Add(-) character.Str = mapleBuffer.read <byte>(); character.Dex = mapleBuffer.read <byte>(); character.Int_ = mapleBuffer.read <byte>(); character.Luk = mapleBuffer.read <byte>(); if (CMapleCharacter.CreatorPlayer(client.UserInfo.Id, client, character, dictionary)) { client.SendDatat(LoginPakcet.AddPlayer(client, character)); } }