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


C# Packet.GetString方法代码示例

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


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

示例1: PacketEventArgs

        public PacketEventArgs(Packet packet, PacketEventType type)
        {
            Packet = packet;

            if (type == PacketEventType.Send)
            {
                Logger.Log("-> " + packet.GetString());
            }
            else if (type == PacketEventType.Receive)
            {
                Logger.Log("<- " + packet.GetString());
            }
        }
开发者ID:Rewtek,项目名称:GameLibrary,代码行数:13,代码来源:PacketEventArgs.cs

示例2: Prepare

		/// <summary>
		/// Prepares skill.
		/// </summary>
		/// <remarks>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var parameters = packet.GetString();
			var itemEntityId = MabiDictionary.Fetch<long>("ITEMID", parameters);
			var guild = creature.Guild;

			if (itemEntityId == 0 || creature.Inventory.GetItem(itemEntityId) == null)
			{
				Log.Warning("HiddenGuildStoneSetting.Prepare: User '{0}' tried to use skill with invalid item.", creature.Client.Account.Id);
				return false;
			}
			else if (guild == null)
			{
				Send.MsgBox(creature, Localization.Get("You're not in a guild."));
				return false;
			}
			else if (creature.GuildMember.Rank != GuildMemberRank.Leader)
			{
				Send.MsgBox(creature, Localization.Get("Only the guild leader can place the guild stone."));
				return false;
			}
			else if (guild.HasStone)
			{
				Send.MsgBox(creature, Localization.Get("Your guild already has a guild stone."));
				return false;
			}

			skill.Stacks = 1;
			skill.State = SkillState.Ready;

			Send.Echo(creature, Op.SkillReady, packet);

			return true;
		}
开发者ID:aura-project,项目名称:aura,代码行数:42,代码来源:HiddenGuildStoneSetting.cs

示例3: Ready

		/// <summary>
		/// Readies skill.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Ready(Creature creature, Skill skill, Packet packet)
		{
			var unkStr = packet.GetString();

			Send.SkillReady(creature, skill.Info.Id, unkStr);

			return true;
		}
开发者ID:aura-project,项目名称:aura,代码行数:15,代码来源:Fishing.cs

示例4: Prepare

		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var unkStr = packet.GetString();

			// Get all items on floor and remove those that are within skill range
			var items = creature.Region.GetAllItems();
			foreach (var item in items.Where(a => a.GetPosition().InRange(creature.GetPosition(), (int)skill.RankData.Var1)))
				creature.Region.RemoveItem(item);

			return false; // Silent cancel
		}
开发者ID:tkiapril,项目名称:aura,代码行数:11,代码来源:AdministrativePicking2.cs

示例5: Prepare

		/// <summary>
		/// Prepares skill, specifying the ingredients.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var ingredients = new List<Ingredient>();

			var unkByte = packet.GetByte();
			var method = packet.GetString();
			var propEntityId = packet.GetLong();
			var unkInt1 = packet.GetInt();
			var count = packet.GetInt();
			for (int i = 0; i < count; ++i)
			{
				var itemEntityId = packet.GetLong();
				var amount = packet.GetFloat();

				// Check item
				var item = creature.Inventory.GetItem(itemEntityId);
				if (item == null)
				{
					Log.Warning("Cooking.Prepare: Creature '{0:X16}' tried to use non-existent item.", creature.EntityId);
					return false;
				}

				ingredients.Add(new Ingredient(item, amount));
			}

			// Check tools
			if (!this.CheckTools(creature, method))
				return false;

			// Check rank
			if (!this.CheckRank(creature, method, skill.Info.Rank))
				return false;

			// Check prop
			if (!this.CheckProp(creature, method, propEntityId))
				return false;

			// Save information
			creature.Temp.CookingIngredients = ingredients;
			creature.Temp.CookingMethod = method;

			// Update tools
			// Item dura
			// Item exp
			// Item dura

			Send.SkillUse(creature, skill.Info.Id, this.GetTime(method));
			skill.State = SkillState.Used;

			Send.Effect(creature, Effect.Cooking, (byte)1, method);

			return true;
		}
开发者ID:aura-project,项目名称:aura,代码行数:60,代码来源:Cooking.cs

示例6: Prepare

		/// <summary>
		/// Loads skill.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var unkStr = packet.GetString();

			// Check rod and bait
			if (!this.CheckEquipment(creature))
			{
				Send.MsgBox(creature, Localization.Get("You need a Fishing Rod in your right hand\nand a Bait Tin in your left."));
				return false;
			}

			Send.SkillPrepare(creature, skill.Info.Id, unkStr);

			return true;
		}
开发者ID:aura-project,项目名称:aura,代码行数:22,代码来源:Fishing.cs

示例7: Prepare

		/// <summary>
		/// Prepares skill (effectively does nothing)
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			if (skill.Info.Id == SkillId.Campfire)
			{
				var itemId = packet.GetInt();

				Send.SkillPrepare(creature, skill.Info.Id, itemId);
			}
			else
			{
				var dict = packet.GetString();

				Send.SkillPrepare(creature, skill.Info.Id, dict);
			}

			return true;
		}
开发者ID:tkiapril,项目名称:aura,代码行数:24,代码来源:Campfire.cs

示例8: Prepare

		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var dict = packet.GetString();

			// Get item entity id
			creature.Temp.NameColorItemEntityId = MabiDictionary.Fetch<long>("ITEMID", dict);
			if (creature.Temp.NameColorItemEntityId == 0)
			{
				Log.Warning("UseItemChattingColorChange: Invalid item id '{0}' from creature '{1:X16}'.", creature.Temp.NameColorItemEntityId, creature.EntityId);
				return false;
			}

			// Go into ready mode
			Send.SkillReady(creature, skill.Info.Id, dict);
			skill.State = SkillState.Ready;

			return true;
		}
开发者ID:tkiapril,项目名称:aura,代码行数:18,代码来源:UseItemChattingColorChange.cs

示例9: PacketReading

		public void PacketReading()
		{
			var testPacket = GetTestPacket();

			// Read from packet
			var buffer = testPacket.Build();
			var packet = new Packet(buffer, 0);

			Assert.Equal(0x01234567, packet.Op);
			Assert.Equal(0x0123456789101112, packet.Id);
			Assert.Equal(byte.MaxValue / 2, packet.GetByte());
			Assert.Equal(short.MaxValue / 2, packet.GetShort());
			Assert.Equal(ushort.MaxValue / 2, packet.GetUShort());
			Assert.Equal(int.MaxValue / 2, packet.GetInt());
			Assert.Equal(uint.MaxValue / 2, packet.GetUInt());
			Assert.Equal(long.MaxValue / 2, packet.GetLong());
			Assert.Equal(ulong.MaxValue / 2, packet.GetULong());
			Assert.Equal(float.MaxValue / 2, packet.GetFloat());
			Assert.Equal("foobar^2", packet.GetString());
			Assert.Equal(new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, packet.GetBin());
			Assert.Equal(PacketElementType.None, packet.Peek());

			// Read from offset packet
			var buffer2 = new byte[3 + testPacket.GetSize()];
			buffer2[0] = 2;
			buffer2[1] = 3;
			buffer2[2] = 1;
			testPacket.Build(ref buffer2, 3);
			var packet2 = new Packet(buffer2, 3);

			Assert.Equal(0x01234567, packet2.Op);
			Assert.Equal(0x0123456789101112, packet2.Id);
			Assert.Equal(byte.MaxValue / 2, packet2.GetByte());
			Assert.Equal(short.MaxValue / 2, packet2.GetShort());
			Assert.Equal(ushort.MaxValue / 2, packet2.GetUShort());
			Assert.Equal(int.MaxValue / 2, packet2.GetInt());
			Assert.Equal(uint.MaxValue / 2, packet2.GetUInt());
			Assert.Equal(long.MaxValue / 2, packet2.GetLong());
			Assert.Equal(ulong.MaxValue / 2, packet2.GetULong());
			Assert.Equal(float.MaxValue / 2, packet2.GetFloat());
			Assert.Equal("foobar^2", packet2.GetString());
			Assert.Equal(new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, packet2.GetBin());
			Assert.Equal(PacketElementType.None, packet.Peek());
		}
开发者ID:tkiapril,项目名称:aura,代码行数:44,代码来源:Packet.cs

示例10: Prepare

		/// <summary>
		/// Prepares skill, getting the used item.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var parameters = packet.GetString();

			// Check item
			var itemEntityId = MabiDictionary.Fetch<long>("ITEMID", parameters);
			if (itemEntityId == 0)
			{
				Log.Warning("HiddenResurrection: Creature '{0:X16}' tried to use skill without item.");
				return false;
			}

			var item = creature.Inventory.GetItem(itemEntityId);
			if (item == null)
			{
				Log.Warning("HiddenResurrection: Creature '{0:X16}' tried to use skill with non-existing item.");
				return false;
			}

			if (!item.HasTag("/usable/resurrection/"))
			{
				Log.Warning("HiddenResurrection: Creature '{0:X16}' tried to use skill with invalid item.");
				return false;
			}

			// Check if any party members are actually dead if party feather
			if (item.HasTag("/party/") && !creature.Party.GetMembers().Any(a => a != creature && a.IsDead && a.DeadMenu.Has(ReviveOptions.PhoenixFeather)))
			{
				Send.MsgBox(creature, Localization.Get("There is no one available to resurrect."));
				return false;
			}

			creature.Temp.SkillItem1 = item;

			// Response
			Send.Echo(creature, Op.SkillReady, packet);
			skill.State = SkillState.Ready;

			return true;
		}
开发者ID:hzdlive,项目名称:aura-1,代码行数:47,代码来源:HiddenResurrection.cs

示例11: Prepare

		/// <summary>
		/// Prepares skill, reading the item to use from the packet.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var dictStr = packet.GetString();
			byte unkByte = 0;
			if (packet.Peek() == PacketElementType.Byte)
				unkByte = packet.GetByte();

			// Get item entity id
			var itemEntityId = MabiDictionary.Fetch<long>("ITEMID", dictStr);
			if (itemEntityId == 0)
			{
				Log.Warning("HiddenTownBack: Item entity id missing.");
				return false;
			}

			// Get item
			var item = creature.Inventory.GetItem(itemEntityId);
			if (item == null)
			{
				Log.Warning("HiddenTownBack: Creature '{0:X16}' tried to use non-existing item.", creature.EntityId);
				return false;
			}

			// Set callback for Complete
			creature.Skills.Callback(skill.Info.Id, () =>
			{
				// Try to warp and remove item if successful
				if (Warp(creature, item))
					creature.Inventory.Remove(item);
			});

			Send.SkillUse(creature, skill.Info.Id, itemEntityId, unkByte, "");
			skill.State = SkillState.Used;

			return true;
		}
开发者ID:tkiapril,项目名称:aura,代码行数:43,代码来源:HiddenTownBack.cs

示例12: Prepare

		/// <summary>
		/// Prepares skill, fails if no Bandage is found.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var itemEntityId = 0L;
			if (packet.Peek() == PacketElementType.String)
				itemEntityId = MabiDictionary.Fetch<long>("ITEMID", packet.GetString());

			// TODO: Get bandage if not item skill
			// Bandages are used starting from the bottom-right corner.
			// Higher quality bandages will take priority over lower quality bandages regardless of placement.
			// ~_______~
			// GetItem(ByTag) (starting in lower right?)

			// TODO: Check actual bandage
			if (creature.Inventory.Count(BandageItemId) == 0)
			{
				Send.Notice(creature, Localization.Get("You need more than one Bandage."));
				return false;
			}

			Send.SkillInitEffect(creature, null);
			Send.SkillPrepare(creature, skill.Info.Id, skill.GetCastTime());

			return true;
		}
开发者ID:xKamuna,项目名称:aura,代码行数:31,代码来源:FirstAid.cs

示例13: AddProp

        private void AddProp(Packet packet)
        {
            var prop = new Prop();

            prop.EntityId = packet.GetLong();
            prop.Id = packet.GetInt();

            if (prop.IsServerProp)
            {
                prop.Name = packet.GetString();
                prop.Title = packet.GetString();
                prop.Info = packet.GetObj<PropInfo>();
            }

            prop.State = packet.GetString();
            packet.GetLong();

            if (packet.GetBool())
                prop.Xml = packet.GetString();

            if (!prop.IsServerProp)
                prop.Direction = packet.GetFloat();

            AddEntity(prop);
        }
开发者ID:Xcelled,项目名称:MabiPale2,代码行数:25,代码来源:Main.cs

示例14: GetTarget

		/// <summary>
		/// Gets target, based on packet's values.
		/// </summary>
		/// <param name="packet"></param>
		/// <returns></returns>
		private Creature GetTarget(Packet packet)
		{
			Creature target = null;

			switch (packet.Peek())
			{
				case PacketElementType.Long:
					var targetEntityId = packet.GetLong();
					// 2 unk ints in older logs
					//var unkInt1 = packet.GetInt();
					//var unkInt2 = packet.GetInt();

					// Get from world, in case there's a remote feather that
					// doesn't use names.
					target = ChannelServer.Instance.World.GetCreature(targetEntityId);

					break;

				case PacketElementType.String:
					var targetName = packet.GetString();

					// Get from world, as advanced feathers can be used remotely
					target = ChannelServer.Instance.World.GetCreature(targetName);

					break;

				default:
					Log.Warning("HiddenResurrection: Unknown target var type '{0}'.", packet.Peek());
					break;
			}

			return target;
		}
开发者ID:hzdlive,项目名称:aura-1,代码行数:38,代码来源:HiddenResurrection.cs

示例15: Prepare

		/// <summary>
		/// Prepares skill, fails if no Bandage is found.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var itemEntityId = 0L;
			if (packet.Peek() == PacketElementType.String)
				itemEntityId = MabiDictionary.Fetch<long>("ITEMID", packet.GetString());

			Item bandage = null;

			// Get given bandage item or select one from the inventory
			if (itemEntityId != 0)
			{
				bandage = creature.Inventory.GetItem(itemEntityId);

				if (bandage == null || !bandage.HasTag("/bandage/"))
				{
					Log.Warning("FirstAid.Prepare: Creature '{0:X16}' tried to use invalid bandage.", creature.EntityId);
					return false;
				}
			}
			else
			{
				// Get all bandages in inventory
				var items = creature.Inventory.GetItems(a => a.HasTag("/bandage/"), StartAt.BottomRight);

				// Cancel if there are none
				if (items.Count == 0)
				{
					Send.Notice(creature, Localization.Get("You need more than one Bandage."));
					return false;
				}

				var best = 0;

				// Select the bandage with the highest quality,
				// starting from the bottom right
				foreach (var item in items)
				{
					var quality = 0;
					if (item.HasTag("/common_grade/"))
						quality = 1;
					else if (item.HasTag("/high_grade/"))
						quality = 2;
					else if (item.HasTag("/highest_grade/"))
						quality = 3;

					// Select this item, if the quality is *better* than the
					// previously selected one, we don't want to switch to a
					// bandage of equal quality, since we want to get the one
					// closest to the bottom right.
					if (bandage == null || quality > best)
					{
						best = quality;
						bandage = item;
					}
				}

				// Sanity check, shouldn't happen. Ever.
				if (bandage == null)
				{
					Log.Warning("FirstAid.Prepare: The impossible sanity check failed.");
					return false;
				}
			}

			creature.Temp.SkillItem1 = bandage;

			Send.SkillInitEffect(creature, null);
			Send.SkillPrepare(creature, skill.Info.Id, skill.GetCastTime());

			return true;
		}
开发者ID:aura-project,项目名称:aura,代码行数:78,代码来源:FirstAid.cs


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