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


C# Packet.GetByte方法代码示例

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


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

示例1: _handleRefreshReply

        private void _handleRefreshReply(Packet pkt)
        {
            if (OnWarpAgree == null)
                return;

            byte numOtherChars = pkt.GetChar();
            if (pkt.GetByte() != 255)
                return;

            List<CharacterData> otherChars = new List<CharacterData>(numOtherChars);
            for (int i = 0; i < numOtherChars; ++i)
            {
                CharacterData data = new CharacterData(pkt);
                otherChars.Add(data);
                if (pkt.GetByte() != 255)
                    return;
            }

            List<NPCData> otherNPCs = new List<NPCData>();
            while (pkt.PeekByte() != 255)
            {
                NPCData newGuy = new NPCData(pkt);
                otherNPCs.Add(newGuy);
            }
            pkt.GetByte();

            List<MapItem> mapItems = new List<MapItem>();
            while (pkt.ReadPos < pkt.Length)
            {
                mapItems.Add(new MapItem
                {
                    uid = pkt.GetShort(),
                    id = pkt.GetShort(),
                    x = pkt.GetChar(),
                    y = pkt.GetChar(),
                    amount = pkt.GetThree(),
                    //turn off drop protection for items coming into view - server will validate
                    time = DateTime.Now.AddSeconds(-5),
                    npcDrop = false,
                    playerID = -1
                });
            }

            OnWarpAgree(-1, WarpAnimation.None, otherChars, otherNPCs, mapItems);
        }
开发者ID:Vulttwin,项目名称:EndlessClient,代码行数:45,代码来源:Refresh.cs

示例2: _handleAppearReply

		private void _handleAppearReply(Packet pkt)
		{
			if (pkt.Length - pkt.ReadPos != 8 || 
				pkt.GetChar() != 0 || pkt.GetByte() != 255 ||
				OnNPCEnterMap == null)
				return; //malformed packet

			OnNPCEnterMap(new NPCData(pkt));
		}
开发者ID:weedindeed,项目名称:EndlessClient,代码行数:9,代码来源:NPC.cs

示例3: _handleWarpAgree

        private void _handleWarpAgree(Packet pkt)
        {
            if (pkt.GetChar() != 2 || OnWarpAgree == null) return;

            short mapID = pkt.GetShort();
            WarpAnimation anim = (WarpAnimation)pkt.GetChar();

            int numOtherCharacters = pkt.GetChar();
            if (pkt.GetByte() != 255) return;

            List<CharacterData> otherCharacters = new List<CharacterData>(numOtherCharacters - 1);
            for (int i = 0; i < numOtherCharacters; ++i)
            {
                CharacterData newChar = new CharacterData(pkt);
                otherCharacters.Add(newChar);
                if (pkt.GetByte() != 255) return;
            }

            List<NPCData> otherNPCs = new List<NPCData>();
            while (pkt.PeekByte() != 255)
            {
                otherNPCs.Add(new NPCData(pkt));
            }
            if (pkt.GetByte() != 255) return;

            List<MapItem> otherItems = new List<MapItem>();
            while (pkt.ReadPos < pkt.Length)
            {
                otherItems.Add(new MapItem
                {
                    uid = pkt.GetShort(),
                    id = pkt.GetShort(),
                    x = pkt.GetChar(),
                    y = pkt.GetChar(),
                    amount = pkt.GetThree(),
                    //turn off drop protection for items coming into view - server will validate
                    time = DateTime.Now.AddSeconds(-5),
                    npcDrop = false,
                    playerID = -1
                });
            }

            OnWarpAgree(mapID, anim, otherCharacters, otherNPCs, otherItems);
        }
开发者ID:Vulttwin,项目名称:EndlessClient,代码行数:44,代码来源:Warp.cs

示例4: _handlePlayersAgree

        // Handles PLAYERS_AGREE packet which is sent when a player enters a map by warp or upon spawning
        private void _handlePlayersAgree(Packet pkt)
        {
            if (pkt.GetByte() != 255 || OnPlayerEnterMap == null)
                return;

            CharacterData newGuy = new CharacterData(pkt);

            byte nextByte = pkt.GetByte();
            WarpAnimation anim = WarpAnimation.None;
            if (nextByte != 255) //next byte was the warp animation: sent on Map::Enter in eoserv
            {
                pkt.Skip(-1);
                anim = (WarpAnimation)pkt.GetChar();
                if (pkt.GetByte() != 255) //the 255 still needs to be read...
                    return;
            }
            //else... //next byte was a 255. proceed normally.

            if (pkt.GetChar() == 1) //0 for NPC, 1 for player. In eoserv it is never 0.
                OnPlayerEnterMap(newGuy, anim);
        }
开发者ID:Vulttwin,项目名称:EndlessClient,代码行数:22,代码来源:Players.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: _handleMainPlayerWalk

		private void _handleMainPlayerWalk(Packet pkt)
		{
			if (pkt.GetByte() != 255 || pkt.GetByte() != 255 || OnMainPlayerWalk == null)
				return;

			//response contains the map items that are now in range
			int numberOfMapItems = pkt.PeekEndString().Length / 9;
			List<MapItem> items = new List<MapItem>(numberOfMapItems);
			for (int i = 0; i < numberOfMapItems; ++i)
			{
				items.Add(new MapItem
				{
					uid = pkt.GetShort(),
					id = pkt.GetShort(),
					x = pkt.GetChar(),
					y = pkt.GetChar(),
					amount = pkt.GetThree()
				});
			}

			OnMainPlayerWalk(items);
		}
开发者ID:weedindeed,项目名称:EndlessClient,代码行数:22,代码来源:Walk.cs

示例7: _handleLoginReply

		//handler for LOGIN_REPLY received from server
		private void _handleLoginReply(Packet pkt)
		{
			m_login_reply = (LoginReply)pkt.GetShort();

			if (m_login_reply == LoginReply.Ok)
			{
				byte numCharacters = pkt.GetChar();
				pkt.GetByte();
				pkt.GetByte();

				m_character_data = new CharacterRenderData[numCharacters];

				for (int i = 0; i < numCharacters; ++i)
				{
					CharacterRenderData nextData = new CharacterRenderData(pkt);
					m_character_data[i] = nextData;
					if (255 != pkt.GetByte())
						return; //malformed packet - time out and signal error
				}
			}

			m_login_responseEvent.Set();
		}
开发者ID:weedindeed,项目名称:EndlessClient,代码行数:24,代码来源:Login.cs

示例8: 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

示例9: 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

示例10: Prepare

		/// <summary>
		/// Prepares 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 materials = new List<ProductionMaterial>();
			var hits = new List<HammerHit>();

			var stage = (Stage)packet.GetByte();
			var propEntityId = packet.GetLong();
			var unkInt1 = packet.GetInt();
			var existingItemEntityId = packet.GetLong();
			var finishId = packet.GetInt();

			if (stage == Stage.Progression)
			{
				// Materials
				if (!this.ReadMaterials(creature, packet, out materials))
					return false;
			}
			else if (stage == Stage.Finish)
			{
				// Hits
				if (!this.ReadHits(creature, packet, out hits))
					return false;
			}
			else
			{
				Send.ServerMessage(creature, Localization.Get("Stage error, please report."));
				Log.Error("Tailoring: Unknown progress stage '{0}'.", stage);
				return false;
			}

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

			// Check if ready for completion
			if (stage == Stage.Progression && existingItemEntityId != 0)
			{
				// Check item
				var item = creature.Inventory.GetItem(existingItemEntityId);
				if (item == null)
				{
					Log.Warning("Blacksmithing.Complete: Creature '{0:X16}' tried to work on non-existent item.", creature.EntityId);
					return false;
				}

				// Check prop
				var prop = creature.Region.GetProp(propEntityId);
				if (prop == null || !creature.GetPosition().InRange(prop.GetPosition(), 500))
				{
					Send.Notice(creature, Localization.Get("You need an anvil."));
					return false;
				}

				// Check item progress
				if (item.MetaData1.GetFloat(ProgressVar) == 1)
				{
					var rnd = RandomProvider.Get();

					// Get manual
					var manualId = creature.Magazine.MetaData1.GetInt("FORMID");
					var manualData = AuraData.ManualDb.Find(ManualCategory.Blacksmithing, manualId);
					if (manualData == null)
					{
						Log.Error("Blacksmithing.Complete: Manual '{0}' not found.", manualId);
						Send.ServerMessage(creature, Localization.Get("Failed to look up pattern, please report."));
						return false;
					}

					// Get items to decrement
					var requiredMaterials = manualData.GetFinish(finishId).Materials;
					List<ProductionMaterial> toDecrement;
					if (!this.GetItemsToDecrement(creature, Stage.Finish, manualData, requiredMaterials, materials, out toDecrement))
						return false;

					// Decrement mats
					this.DecrementMaterialItems(creature, toDecrement, rnd);

					// Start minigame
					var deviation = (byte)(skill.Info.Rank < SkillRank.R9 ? 3 : 2);
					var dots = new List<BlacksmithDot>();
					for (int i = 0; i < 5; ++i)
					{
						var dot = new BlacksmithDot();

						dot.Deviation = rnd.Next(0, deviation + 1);
						dot.X = rnd.Next(FieldMin, FieldMax + 1);
						dot.Y = rnd.Next(FieldMin, FieldMax + 1);

						// Use static displacement until we know the formula.
						dot.TimeDisplacement = 1; // rnd.Between(0.81f, 0.98f);

						dots.Add(dot);
					}
//.........这里部分代码省略.........
开发者ID:tkiapril,项目名称:aura,代码行数:101,代码来源:Blacksmithing.cs

示例11: Prepare

		/// <summary>
		/// Starts production, finished in Complete.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		/// <example>
		/// 001 [............271D] Short  : 10013
		/// 002 [..............02] Byte   : 2
		/// 003 [........00000006] Int    : 6
		/// 004 [............0001] Short  : 1
		/// 005 [............0006] Short  : 6
		/// 006 [............0001] Short  : 1
		/// 007 [..............01] Byte   : 1
		/// 008 [005000CC7F17E280] Long   : 22518876442452608
		/// 009 [............0003] Short  : 3
		/// 
		/// 001 [............271B] Short  : 10011
		/// 002 [..............01] Byte   : 1
		/// 003 [00A188D000050041] Long   : 45467898185318465
		/// 004 [........00000000] Int    : 0
		/// 005 [........00000002] Int    : 2
		/// 006 [............0001] Short  : 1
		/// 007 [............0001] Short  : 1
		/// 008 [............0002] Short  : 2
		/// 009 [..............01] Byte   : 1
		/// 010 [005000CC80BA58CD] Long   : 22518876469876941
		/// 011 [............000A] Short  : 10
		/// </example>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var unkByte = packet.GetByte();
			var propEntityId = 0L;
			var unkInt = 0;
			if (packet.Peek() == PacketElementType.Long) // Rule unknown
			{
				propEntityId = packet.GetLong();
				unkInt = packet.GetInt();
			}
			var productId = packet.GetInt();
			var unkShort1 = packet.GetShort();
			var category = (ProductionCategory)packet.GetShort();
			var amountToProduce = packet.GetShort();
			var count = packet.GetByte();
			var materials = new List<ProductionMaterial>(count);
			for (int i = 0; i < count; ++i)
			{
				var entityId = packet.GetLong();
				var amount = packet.GetShort();

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

				materials.Add(new ProductionMaterial(item, amount));
			}

			// Get product data
			var potentialProducts = AuraData.ProductionDb.Find(category, productId);
			if (potentialProducts.Length == 0)
			{
				Send.ServerMessage(creature, "Unknown product.");
				return false;
			}
			var productData = potentialProducts[0];

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

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

			// Check mana
			if (!this.CheckMana(creature, productData))
				return false;

			// Give skills the ability to use motions and other things.
			this.OnUse(creature, skill);

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

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

示例12: Complete

		/// <summary>
		/// Completes production.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		public void Complete(Creature creature, Skill skill, Packet packet)
		{
			var unkByte = packet.GetByte();
			var propEntityId = 0L;
			var unkInt = 0;
			if (packet.Peek() == PacketElementType.Long) // Rule unknown
			{
				propEntityId = packet.GetLong();
				unkInt = packet.GetInt();
			}
			var productId = packet.GetInt();
			var unkShort = packet.GetShort();
			var category = (ProductionCategory)packet.GetShort();
			var amountToProduce = packet.GetShort();
			var count = packet.GetByte();
			var materials = new List<ProductionMaterial>(count);
			for (int i = 0; i < count; ++i)
			{
				var entityId = packet.GetLong();
				var amount = packet.GetShort();

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

				materials.Add(new ProductionMaterial(item, amount));
			}

			// Check prop
			if (!this.CheckProp(creature, propEntityId))
				goto L_Fail;

			// Check category
			if (!this.CheckCategory(creature, category))
			{
				Log.Warning("ProductionSkill.Complete: Creature '{0:X16}' tried to use category '{1}' with skill '{2}'.", creature.EntityId, category, this.GetType().Name);
				goto L_Fail;
			}

			// Get potential products
			// Some productions can produce items of varying quality (cheap,
			// common, fine, finest)
			var potentialProducts = AuraData.ProductionDb.Find(category, productId);
			if (potentialProducts.Length == 0)
			{
				Send.ServerMessage(creature, "Unknown product.");
				goto L_Fail;
			}

			// Get reference product for checks and mats
			var productData = potentialProducts[0];

			// Check tools
			if (!this.CheckTools(creature, skill, productData))
				goto L_Fail;

			// Check mana
			if (!this.CheckMana(creature, productData))
				goto L_Fail;

			if (productData.Mana > 0)
			{
				creature.Mana -= productData.Mana;
				Send.StatUpdate(creature, StatUpdateType.Private, Stat.Mana);
			}

			// Check materials
			var requiredMaterials = productData.GetMaterialList();
			var toReduce = new List<ProductionMaterial>();
			var inUse = new HashSet<long>();
			foreach (var reqMat in requiredMaterials)
			{
				// Check all selected items for tag matches
				foreach (var material in materials)
				{
					// Check item and stack item for tag, pouches can be put
					// into the window, reducing the contained items.
					var match =
						material.Item.HasTag(reqMat.Tag) ||
						(material.Item.IsGatheringPouch && material.Item.Data.StackItem != null && material.Item.Data.StackItem.HasTag(reqMat.Tag));

					// Satisfy requirement with item, up to the max amount
					// needed or available
					if (match)
					{
						// Cancel if one item matches multiple materials.
						// It's unknown how this would be handled, can it even
						// happen? Can one item maybe only be used as one material?
						if (inUse.Contains(material.Item.EntityId))
						{
//.........这里部分代码省略.........
开发者ID:tkiapril,项目名称:aura,代码行数:101,代码来源:Production.cs

示例13: _handleQuestDialog

		private void _handleQuestDialog(Packet pkt)
		{
			if (OnQuestDialog == null) return;

			int numDialogs = pkt.GetChar();
			short vendorID = pkt.GetShort();
			short questID = pkt.GetShort();
			short sessionID = pkt.GetShort(); //not used by eoserv
			short dialogID = pkt.GetShort(); //not used by eoserv
			if (pkt.GetByte() != 255) return;

			QuestState stateInfo = new QuestState(sessionID, dialogID, questID, vendorID);

			var dialogNames = new Dictionary<short, string>(numDialogs);
			for (int i = 0; i < numDialogs; ++i)
			{
				dialogNames.Add(pkt.GetShort(), pkt.GetBreakString());
			}

			var pages = new List<string>();
			var links = new Dictionary<short, string>();
			while (pkt.ReadPos != pkt.Length)
			{
				var entry = (DialogEntry) pkt.GetShort();
				switch (entry)
				{
					case DialogEntry.DialogText:
						pages.Add(pkt.GetBreakString());
						break;
					case DialogEntry.DialogLink:
						links.Add(pkt.GetShort(), pkt.GetBreakString());
						break;
				}
			}

			OnQuestDialog(stateInfo, dialogNames, pages, links);
		}
开发者ID:weedindeed,项目名称:EndlessClient,代码行数:37,代码来源:Quest.cs

示例14: WelcomeMessageData

		internal WelcomeMessageData(Packet pkt)
		{
			m_news = new List<string>();
			for (int i = 0; i < 9; ++i)
			{
				m_news.Add(pkt.GetBreakString());
			}

			Weight = pkt.GetChar();
			MaxWeight = pkt.GetChar();

			m_inventory = new List<InventoryItem>();
			while (pkt.PeekByte() != 255)
				m_inventory.Add(new InventoryItem { id = pkt.GetShort(), amount = pkt.GetInt() });
			pkt.GetByte();

			m_spells = new List<CharacterSpell>();
			while (pkt.PeekByte() != 255)
				m_spells.Add(new CharacterSpell { id = pkt.GetShort(), level = pkt.GetShort() });
			pkt.GetByte();

			//Get data for other characters
			int numOtherCharacters = pkt.GetChar();
			m_characters = new List<CharacterData>(numOtherCharacters);
			if (pkt.GetByte() != 255) throw new Exception();
			for (int i = 0; i < numOtherCharacters; ++i)
			{
				CharacterData newGuy = new CharacterData(pkt);
				if (pkt.GetByte() != 255)
					throw new Exception();

				m_characters.Add(newGuy);
			}

			//get data for any npcs
			m_npcs = new List<NPCData>();
			while (pkt.PeekByte() != 255)
			{
				NPCData newGuy = new NPCData(pkt);
				m_npcs.Add(newGuy);
			}
			pkt.GetByte();

			//get data for items on map
			m_items = new List<MapItem>();
			while (pkt.ReadPos < pkt.Length)
			{
				m_items.Add(new MapItem
				{
					uid = pkt.GetShort(),
					id = pkt.GetShort(),
					x = pkt.GetChar(),
					y = pkt.GetChar(),
					amount = pkt.GetThree(),
					//turn off drop protection for items coming into view - server will validate
					time = DateTime.Now.AddSeconds(-5),
					npcDrop = false,
					playerID = -1
				});
			}
		}
开发者ID:weedindeed,项目名称:EndlessClient,代码行数:61,代码来源:Welcome.cs

示例15: Prepare

		/// <summary>
		/// Prepares the 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 materials = new List<ProductionMaterial>();
			var stitches = new List<Point>();

			var stage = (Stage)packet.GetByte();
			var propEntityId = packet.GetLong();
			var unkInt1 = packet.GetInt();
			var existingItemEntityId = packet.GetLong();
			var finishId = packet.GetInt();

			if (stage == Stage.Progression)
			{
				// Materials
				if (!this.ReadMaterials(creature, packet, out materials))
					return false;
			}
			else if (stage == Stage.Finish)
			{
				// Stitches
				if (!this.ReadStitches(creature, packet, out stitches))
					return false;
			}
			else
			{
				Send.ServerMessage(creature, Localization.Get("Stage error, please report."));
				Log.Error("Tailoring: Unknown progress stage '{0}'.", stage);
				return false;
			}

			// Check tools
			if (!CheckTools(creature))
			{
				Send.MsgBox(creature, Localization.Get("You need a Tailoring Kit in your right hand\nand a Sewing Pattern in your left."));
				return false;
			}

			// Check if ready for completion
			if (stage == Stage.Progression && existingItemEntityId != 0)
			{
				// Check item
				var item = creature.Inventory.GetItem(existingItemEntityId);
				if (item == null)
				{
					Log.Warning("Tailoring.Complete: Creature '{0:X16}' tried to work on non-existent item.", creature.EntityId);
					return false;
				}

				// Check item progress
				if (item.MetaData1.GetFloat(ProgressVar) == 1)
				{
					var rnd = RandomProvider.Get();

					// Get manual
					var manualId = creature.Magazine.MetaData1.GetInt("FORMID");
					var manualData = AuraData.ManualDb.Find(ManualCategory.Tailoring, manualId);
					if (manualData == null)
					{
						Log.Error("Tailoring.Complete: Manual '{0}' not found.", manualId);
						Send.ServerMessage(creature, Localization.Get("Failed to look up pattern, please report."));
						return false;
					}

					// Get items to decrement
					var requiredMaterials = manualData.GetFinish(finishId).Materials;
					List<ProductionMaterial> toDecrement;
					if (!this.GetItemsToDecrement(creature, Stage.Finish, manualData, requiredMaterials, materials, out toDecrement))
						return false;

					// Decrement mats
					this.DecrementMaterialItems(creature, toDecrement, rnd);

					// Start minigame
					var xOffset = (short)rnd.Next(30, 50);
					var yOffset = (short)rnd.Next(20, 30);
					var deviation = new byte[6];
					var deviation2 = (byte)(skill.Info.Rank < SkillRank.R9 ? 4 : 2);
					for (int i = 0; i < deviation.Length; ++i)
						deviation[i] = (byte)rnd.Next(0, deviation2 + 1);

					Send.TailoringMiniGame(creature, item, xOffset, yOffset, deviation, deviation2);

					// Save offsets for complete
					creature.Temp.TailoringMiniGameX = xOffset;
					creature.Temp.TailoringMiniGameY = yOffset;

					return false;
				}
			}

			// Skill training
			if (skill.Info.Rank == SkillRank.Novice)
				skill.Train(1); // Use the skill.
//.........这里部分代码省略.........
开发者ID:tkiapril,项目名称:aura,代码行数:101,代码来源:Tailoring.cs


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