/// <summary> /// 删除玩家 /// </summary> /// <param name="chr"></param> public void RemovePlayer(CMapleCharacter chr) { Console.WriteLine("{0}玩家退出地图:{1}", chr.character.Name, chr.character.MapId); m_Players.Remove(chr.character.Id); foreach (KeyValuePair <int, CMapleCharacter> player in m_Players) { Console.WriteLine("玩家:{0} 退出地图{1}", player.Value.character.Name, chr.character.MapId); player.Value.SendSpawnData(player.Value.client, PlayerPakcet.RemovePlayer(chr.character.Id)); } }
/// <summary> /// 增加玩家 /// </summary> /// <param name="chr"></param> public void AddPlayer(CMapleCharacter chr) { Console.WriteLine("{0}玩家进入地图:{1}", chr.character.Name, chr.character.MapId); //发送召唤玩家 m_Players.Add(chr.character.Id, chr); foreach (KeyValuePair <int, CMapleCharacter> player in m_Players) { Console.WriteLine("玩家:{0} 进入地图{1}", player.Value.character.Name, chr.character.MapId); player.Value.SendSpawnData(player.Value.client, PlayerPakcet.SpawnPlayer(chr)); } }
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:游戏登陆(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 SpawnPlayer(CMapleCharacter chr) { using (MapleBuffer buffer = new MapleBuffer()) { buffer.add <int>(chr.character.Id + 1); buffer.add <string>(chr.character.Name); buffer.add <int>(0);//Buffmask addCharLook(buffer, chr); buffer.add <int>(0); buffer.add <int>(0);//getItemEffect buffer.add <int>(0); buffer.add <short>((short)chr.GetPoint().X); buffer.add <short>((short)chr.GetPoint().Y); buffer.add <byte>(chr.GetStance()); buffer.add <short>(0); buffer.add(new byte[3]); return(new MaplePakcet(buffer.ToArray())); } }
public static void addCharLook(MapleBuffer buffer, CMapleCharacter chr) { buffer.add <byte>(0);//性别 buffer.add <byte>((byte)chr.character.Skin); buffer.add <int>(chr.character.Face); buffer.add <byte>(0); buffer.add <int>(chr.character.Hair); List <CItem> equipped = new List <CItem>(); List <CItem> equippedCash = new List <CItem>(); //判断是否点装.. foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.佩戴).getInventory()) { if (item.Key < 0 && item.Key > -100) { equipped.Add(item.Value); } else if (item.Key <= -100 && item.Key > -1000) { equippedCash.Add(item.Value); } } //装备 foreach (CItem item in equipped) { buffer.add <byte>((byte)item.Position); buffer.add <int>(item.ItemId); } buffer.add <byte>(0xFF);//1 //现金装备 foreach (CItem item in equippedCash) { buffer.add <byte>((byte)item.Position); buffer.add <int>(item.ItemId); } buffer.add <int>(0);//宠物?? }
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)); } }
//TODO:道具信息(100%) public static void AddInventoryInfo(MapleBuffer buffer, CMapleCharacter chr) { List <CItem> equipped = new List <CItem>(); List <CItem> equippedCash = new List <CItem>(); //判断是否点装.. foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.佩戴).getInventory()) { if (item.Key < 0 && item.Key > -100) { equipped.Add(item.Value); } else if (item.Key <= -100 && item.Key > -1000) { equippedCash.Add(item.Value); } } //装备 foreach (CItem item in equipped) { AddItemInfo(buffer, item); } buffer.add <byte>(0);//1 //现金装备 foreach (CItem item in equippedCash) { AddItemInfo(buffer, item); } buffer.add <byte>(0); //2 buffer.add <byte>((byte)chr.GetMapleInventory(Common.Client.Inventory.InventoryType.装备).getInventory().Count); //2 foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.装备).getInventory()) { AddItemInfo(buffer, item.Value); } buffer.add <byte>(0); //3 buffer.add <byte>((byte)chr.GetMapleInventory(Common.Client.Inventory.InventoryType.消耗).getInventory().Count); //2 foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.消耗).getInventory()) { AddItemInfo(buffer, item.Value); } buffer.add <byte>(0); //4 buffer.add <byte>((byte)chr.GetMapleInventory(Common.Client.Inventory.InventoryType.设置).getInventory().Count); //2 foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.设置).getInventory()) { AddItemInfo(buffer, item.Value); } buffer.add <byte>(0); //5 buffer.add <byte>((byte)chr.GetMapleInventory(Common.Client.Inventory.InventoryType.其他).getInventory().Count); //2 foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.其他).getInventory()) { AddItemInfo(buffer, item.Value); } buffer.add <byte>(0); //6 buffer.add <byte>((byte)chr.GetMapleInventory(Common.Client.Inventory.InventoryType.现金).getInventory().Count); //2 foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.现金).getInventory()) { AddItemInfo(buffer, item.Value); } buffer.add <byte>(0);//7 }