Beispiel #1
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));
            }
        }
Beispiel #2
0
 /// <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));
     }
 }
Beispiel #3
0
 /// <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));
     }
 }
Beispiel #4
0
        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);
        }
Beispiel #5
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);
        }
Beispiel #6
0
 public int Execute(CMapleClient client, string[] paramArrayOfString)
 {
     client.SendDatat(PlayerPakcet.ServerMessage(1, "游戏升级命令!" + int.Parse(paramArrayOfString[0])));
     return(1);
 }