当前位置: 首页>>代码示例>>C#>>正文


C# Packet.TryReadBool方法代码示例

本文整理汇总了C#中Estrella.FiestaLib.Networking.Packet.TryReadBool方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.TryReadBool方法的具体用法?C# Packet.TryReadBool怎么用?C# Packet.TryReadBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Estrella.FiestaLib.Networking.Packet的用法示例。


在下文中一共展示了Packet.TryReadBool方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChangeFromGuildAcademyToResponse

        public static void ChangeFromGuildAcademyToResponse(WorldClient client, Packet packet)
        {
            string GuildName;
              string RequestName;
              bool answer;
              if (!packet.TryReadString(out GuildName, 16) || !packet.TryReadString(out RequestName, 16)|| (!packet.TryReadBool(out answer) || !client.Character.IsInGuildAcademy))
                  return;
             if (answer)
            {
                GuildAcademyMember pMember = client.Character.GuildAcademy.Members.Find(m => m.Character.Character.Name == RequestName);
                if (pMember == null)
                    return;
                pMember.Character.IsInGuildAcademy = false;
                pMember.Academy.RemoveMember(pMember);
               pMember.Character.GuildAcademy.Guild.AddMember(pMember.Character, GuildRank.Member, Program.DatabaseManager.GetClient().GetConnection(), true, true);

                pMember.Character.Guild = pMember.Character.GuildAcademy.Guild;
                pMember.Character.IsInGuild = true;
             using (var pack = new Packet(SH38Type.SendJoinGuildFromAcademy))
             {
                 //this packet remove character from academy List and added to GuildList
                 pack.WriteString(RequestName, 16);
                 pack.WriteString(client.Character.Character.Name, 16);
                 pack.WriteByte(6);//rank
                 pack.WriteInt(0);//unk
                 pack.WriteUShort(0);//korp
                 pack.Fill(64, 0x00);//unk
                 pack.WriteByte(true ? (byte)0x95 : (byte)0x00);// (this.isOnline ? (byte)0x95 : (byte)0x00);
                 pack.Fill(3, 0x00);//unk
                 pack.WriteByte(pMember.Character.Character.Job);
                 pack.WriteByte(pMember.Character.Character.CharLevel);
                 pack.Fill(13, 0x00);//unk
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);
                 }
             }
             using (var p2 = new Packet(SH4Type.CharacterGuildinfo))
             {
                 client.Character.Guild.WriteGuildInfo(packet);
                 client.SendPacket(p2);
             }
             using (var pack = new Packet(SH29Type.GuildMemberJoined))
             {
                 pack.WriteString(client.Character.Character.Name, 16);
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);

             }
             using (var pack = new Packet(SH29Type.ChangeResponse))
             {
                 pack.WriteUShort(3137);//unk
                 pack.WriteByte(3);
                 pack.Fill(2, 0x00);//unk
                 client.SendPacket(pack);
             }
        }
开发者ID:,项目名称:,代码行数:56,代码来源:

示例2: FriendInviteResponse

        public static void FriendInviteResponse(WorldClient pClient, Packet pPacket)
        {
            string target, sender;
            bool response;
            if (!pPacket.TryReadString(out target, 16) ||
                !pPacket.TryReadString(out sender, 16) ||
                !pPacket.TryReadBool(out response))
            {
                Log.WriteLine(LogLevel.Warn, "Could not reat friend invite response.");
                return;
            }
            WorldClient sendchar = ClientManager.Instance.GetClientByCharname(sender);
            if (sendchar == null)
            {
                Log.WriteLine(LogLevel.Warn, "Invalid friend reject received.");
                return;
            }
            if (response)
            {
                Friend sendfriend = sendchar.Character.AddFriend(pClient.Character);
                if (sendfriend != null)
                {
                    using (var packet = new Packet(SH21Type.FriendInviteResponse))
                    {
                        packet.WriteString(sender, 16);
                        packet.WriteString(target, 16);
                        packet.WriteByte(0);
                        sendchar.SendPacket(packet);
                    }

                    using (var packet = new Packet(SH21Type.FriendExtraInformation))
                    {
                        sendfriend.WritePacket(packet);
                        sendchar.SendPacket(packet);
                    }
                }
            }
            else
            {
                using (var packet = new Packet(SH21Type.FriendInviteReject))
                {
                    packet.WriteString(target, 16);
                    sendchar.SendPacket(packet);
                }
            }
        }
开发者ID:,项目名称:,代码行数:46,代码来源:

示例3: On_GameClient_GuildInviteResponse

        public static void On_GameClient_GuildInviteResponse(WorldClient Client, Packet pPacket)
        {
            string guildName;
            bool joinGuild;
            if (!pPacket.TryReadString(out guildName, 16)
                || !pPacket.TryReadBool(out joinGuild))
            {
                return;
            }

            //get guild
            Guild guild;
            if (GetGuildByName(guildName, out guild))
            {
                guild.AddMember(Client.Character, GuildRank.Member, null, true, true);
            }
        }
开发者ID:,项目名称:,代码行数:17,代码来源:

示例4: On_GameClient_CreateGuild

        public static void On_GameClient_CreateGuild(WorldClient Client, Packet Packet)
        {
            string name, password;
            bool allowGuildWar;
            if (!Packet.TryReadString(out name, 16)
                || !Packet.TryReadString(out password, 8)
                || !Packet.ReadSkip(4) // unk ?
                || !Packet.TryReadBool(out allowGuildWar))
            {
                return;
            }

            GuildCreateResponse response;

            if (Client.Character.Character.CharLevel < 20)
            {
                response = GuildCreateResponse.LevelTooLow;
            }
            else if (Client.Character.Character.Money < Guild.Price)
            {
                response = GuildCreateResponse.MoneyTooLow;
            }
            else
            {
                //encrypt guild pw
               var pwData = Encoding.UTF8.GetBytes(password);
            //                InterCrypto.Encrypt(ref pwData, 0, pwData.Length);

                Guild guild;

                //try to create guild
                lock (ThreadLocker)
                {
                    int result;
                    int guildID;
                    var createTime = Program.CurrentTime;

                    using (var con = Program.DatabaseManager.GetClient().GetConnection())
                    {
                        //insert guild in db
                        using (var cmd = con.CreateCommand())
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.CommandText = "Guild_Create";

                            cmd.Parameters.Add(new MySqlParameter("@pName", name));
                            cmd.Parameters.Add(new MySqlParameter("@pPassword", pwData));
                            cmd.Parameters.Add(new MySqlParameter("@pAllowGuildWar", allowGuildWar));
                            cmd.Parameters.Add(new MySqlParameter("@pCreaterID", Client.Character.ID));
                            cmd.Parameters.Add(new MySqlParameter("@pCreateTime", createTime));

                            var idParam = cmd.Parameters.Add(new MySqlParameter("@pID", SqlDbType.Int)
                                {
                                    Direction = ParameterDirection.Output
                                });
                            result = Convert.ToInt32(cmd.ExecuteScalar());
                            guildID = (int)idParam.Value;
                        }

                        switch (result)
                        {
                            case -1:
                                //guild name already exists (ToDo: get response code)

                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.AlredyExist);
                                return;

                            case -2: //database error @ insert guild (ToDo: get response code)
                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.Failed);
                                return;
                            case -3: //database error @ insert guild academy (ToDo: get response code)
                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.Failed);
                                return;

                            case 0:

                                //create guild
                                guild = new Guild(con, guildID, name, pwData, allowGuildWar, Client.Character, createTime);
                            //insert guild master (character will get updated)
                                guild.AddMember(Client.Character, GuildRank.Master, con, false, false);
                                //add to loaded guilds
                                LoadedGuilds.Add(guild);

                                break;

                            default:
                                return;
                        }
                    }
                }

                Client.Character.
                //revoke money
               Client.Character.ChangeMoney(Client.Character.Character.Money - Guild.Price);

                //let character broadcast guild name packet
                using (var packet = new Packet(SH29Type.GuildNameResult))
                {
                    packet.WriteInt(guild.ID);
                    packet.WriteString(guild.Name, 16);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的Estrella.FiestaLib.Networking.Packet.TryReadBool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。