public static MaplePakcet Ping() { using (MapleBuffer buffer = new MapleBuffer()) { return(new MaplePakcet(buffer.ToArray())); } }
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) { 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) { 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) { //TODO:选择服务器(0%) short serverId = mapleBuffer.read <byte>(); client.SendDatat(LoginPakcet.getServerStatus(0)); }
/// <summary> /// 玩家基本消息 /// </summary> /// <param name="buffer"></param> /// <param name="chr"></param> /// <param name="client"></param> public static void addCharStats(MapleBuffer buffer, CCharacter chr, CMapleClient client) { buffer.add <int>(chr.Id); buffer.add(chr.Name, 0x13); buffer.add <byte>(client.UserInfo.Gender); buffer.add <byte>(byte.Parse(chr.Skin.ToString())); buffer.add <int>(chr.Face); buffer.add <int>(chr.Hair); buffer.add <long>(0); buffer.add <byte>((byte)chr.Level); buffer.add <short>(chr.Job); buffer.add <short>(chr.Str); buffer.add <short>(chr.Dex); buffer.add <short>(chr.Int_); buffer.add <short>(chr.Luk); buffer.add <short>(chr.Hp); buffer.add <short>(chr.Mp); buffer.add <short>(chr.Maxhp); buffer.add <short>(chr.Maxmp); buffer.add <short>(chr.Ap); buffer.add <short>(chr.Sp); buffer.add <int>(chr.Exp); buffer.add <short>(chr.Fame); buffer.add <int>(chr.MapId); buffer.add <byte>(chr.Spawnpoint); buffer.addTime(150842304000000000L); buffer.add <long>(0); }
//TODO:道具信息(30%) public static void AddItemInfo(MapleBuffer buffer, CItem item) { //buffer.add<int> short Posin = (short)item.Position; if (Posin <= -1) { Posin *= -1; if (Posin > 100 && Posin < 1000) { Posin -= 100; } } buffer.add <byte>((byte)Posin); if (false)//宠物道具信息 { } else { if (item.Type == 0 || item.Type == 1)//0:佩戴,1装备 { //装备道具数据 CEquip equip = Common.Sql.MySqlFactory.GetFactory.Query <CEquip>().Where(a => a.InventoryitemsId == item.Id).FirstOrDefault(); if (equip == null) { AddBaseItemHeader(buffer, item); buffer.add <byte>(0); buffer.add <byte>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <short>(0); buffer.add <string>(""); } else { AddBaseItemHeader(buffer, item); AddEquipItemInfo(buffer, equip); } } else { //其他道具数据 AddOtherItemInfo(buffer, item); } } }
public static MaplePakcet ShowRegister(bool isShow) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <bool>(isShow); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet RemovePlayer(int cid) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <int>(cid); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet CharNameResponse(string Name, bool ret) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <string>(Name); buffer.add <bool>(ret); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet getEndOfServerList() { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(0xFF);//世界ID return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet RegisterAccount(bool Success) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add(Success); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet CheckAccount(string Name, bool Success) { using (MapleBuffer buff = new MapleBuffer()) { buff.add <string>(Name); buff.add <bool>(Success); return(new MaplePakcet(buff.ToArray())); } }
public static MaplePakcet AddPlayer(CMapleClient client, CCharacter chr) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(0); addCharEntry(buffer, chr, client); return(new MaplePakcet(buffer.ToArray())); } }
//TODO:道具基础头部(100%) public static void AddBaseItemHeader(MapleBuffer buffer, CItem item) { buffer.add <int>(item.ItemId); buffer.add <byte>(item.Uniqueid > 0 ? (byte)1 : (byte)0); if (item.Uniqueid > 0) { buffer.add <long>(item.Uniqueid); } buffer.addTime(Common.constants.GameConstants.getTime(item.Expiredate)); //到期时间 }
public static MaplePakcet GetChatText(int cid, string Text, bool whiteBG = false) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <int>(cid); buffer.add <byte>(whiteBG ? (byte)1 : (byte)0);//是否显示说话对话框 buffer.add <string>(Text); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet ShowNumber() { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(1); buffer.add <int>(5); buffer.add <int>(5 + (3 - 5 % 3)); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet getLoginFailed(byte type) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(type); buffer.add <byte>(0); buffer.add(new byte[1000]); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet getServerStatus(byte status) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(status); if (status != 0) { buffer.add(new byte[6]); } return(new MaplePakcet(buffer.ToArray())); } }
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%) }
/// <summary> /// 验证版本 /// </summary> /// <returns></returns> public static byte[] GetHello(short mapleVersion, byte[] sendIv, byte[] recvIv) { using (MapleBuffer mapleBuffer = new MapleBuffer()) { mapleBuffer.add((short)0x0E); mapleBuffer.add <short>(mapleVersion); mapleBuffer.add(recvIv); mapleBuffer.add(sendIv); mapleBuffer.add(4); return(mapleBuffer.ToArray()); } }
public static MaplePakcet getServerIP(byte[] IPaddr, short port, int chrid) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <short>(0); buffer.add(IPaddr); buffer.add <short>(port); buffer.add <int>(chrid); buffer.add <byte>(0); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet GetChannelChange(string Address, short port) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(1); string[] adds = Address.Split("."); foreach (string add in adds) { buffer.add(byte.Parse(add.ToString()));//IP地址 } buffer.add <short>(port); return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet ShowPlayList(CMapleClient client, Dictionary <CCharacter, Dictionary <short, CItem> > PlayerList, byte worldid) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(0); buffer.add <int>(0); buffer.add <byte>((byte)PlayerList.Count); foreach (KeyValuePair <CCharacter, Dictionary <short, CItem> > chr in PlayerList) { addCharEntry(buffer, chr.Key, client, chr.Value); } return(new MaplePakcet(buffer.ToArray())); } }
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 static MaplePakcet ServerMessage(int type, string Message, int channel = 0, bool megaEar = false) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>((byte)type); buffer.add <string>(Message); switch (type) { case 3: buffer.add <byte>((byte)channel); buffer.add <byte>(megaEar ? (byte)1 : (byte)0); break; } return(new MaplePakcet(buffer.ToArray())); } }
public static MaplePakcet GetCharInfo(int Channelid, CCharacter chr, CMapleClient client) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <int>(Channelid);//频道 buffer.add <byte>(0); buffer.add <byte>(1); buffer.add <int>(new System.Random().Next()); buffer.add <int>(new System.Random().Next()); buffer.add <int>(new System.Random().Next()); buffer.add <int>(0); AddCharacterInfo(buffer, chr, client); return(new MaplePakcet(buffer.ToArray())); } }
/// <summary> /// 游戏版本封包 /// </summary> /// <param name="mapleVersion"></param> /// <param name="sendIv"></param> /// <param name="recvIv"></param> /// <returns></returns> public static MaplePakcet GetHello(short mapleVersion, byte[] sendIv, byte[] recvIv) { using (MapleBuffer mapleBuffer = new MapleBuffer()) { System.Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name); mapleBuffer.add((short)0x0E); mapleBuffer.add <short>(mapleVersion); mapleBuffer.add <short>(1); mapleBuffer.add <byte>(0x31); mapleBuffer.add(recvIv); mapleBuffer.add(sendIv); mapleBuffer.add <byte>(4); return(new MaplePakcet(mapleBuffer.ToArray())); } }
public static MaplePakcet getAuthSuccessRequest(CUser user) { //01 00 01 00 00 00 00 00 06 00 78 7A 6B 6D 78 64 01 00 00 00 01 //01 04 01 00 00 00 00 00 06 00 78 7A 6B 6D 78 64 01 00 00 00 01 using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <byte>(0); buffer.add <int>(user.Id); buffer.add <byte>(0); buffer.add <byte>((byte)(user.Gm ?? 0));//是否管理员 buffer.add <string>(user.Name); buffer.add <int>(user.Id); buffer.add <byte>(0); return(new MaplePakcet(buffer.ToArray())); } }