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


C# Region.AddItem方法代码示例

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


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

示例1: Drop

		/// <summary>
		/// Drops item at location.
		/// </summary>
		/// <param name="region">Region to drop the item in.</param>
		/// <param name="pos">
		/// Center point of the drop, which is slightly randomized in this method.
		/// </param>
		/// <param name="radius">
		/// Radius around position where the item may drop.
		/// </param>
		/// <param name="owner">
		/// The only entity that is allowed to pick up the item for a
		/// certain period of time. Set to null to not protect item from
		/// being picked up.
		/// </param>
		/// <param name="playerDrop">
		/// Whether the item is being dropped by a player, the owner.
		/// If it is, normal items aren't protected.
		/// </param>
		public void Drop(Region region, Position pos, int radius, Creature owner, bool playerDrop)
		{
			var rnd = RandomProvider.Get();

			// Randomize position if radius was specified
			if (radius > 0)
				pos = pos.GetRandomInRange(radius, rnd);

			var x = pos.X;
			var y = pos.Y;

			//this.SetNewEntityId();
			this.Move(region.Id, x, y);

			// Keys don't disappear (?)
			if (!this.HasTag("/key/"))
				this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60));

			// Specify who can pick up the item when
			if (owner != null)
			{
				this.OwnerId = owner.EntityId;

				// Personal items can never be picked up by anyone else
				var isPersonal =
					(this.Data.Action == ItemAction.StaticItem || this.Data.Action == ItemAction.AccountPersonalItem || this.Data.Action == ItemAction.CharacterPersonalItem)
					|| this.Is(ItemFlags.Personalized);

				// Set protection if item wasn't dropped by a player
				// and it's not a dungeon room key
				var standardProtection = (!isPersonal && !playerDrop && !this.IsDungeonRoomKey);

				if (isPersonal)
				{
					this.ProtectionLimit = DateTime.MaxValue;
				}
				else if (standardProtection)
				{
					var seconds = ChannelServer.Instance.Conf.World.LootStealProtection;
					if (seconds > 0)
						this.ProtectionLimit = DateTime.Now.AddSeconds(seconds);
					else
						this.ProtectionLimit = null;
				}
			}
			else
			{
				this.OwnerId = 0;
				this.ProtectionLimit = null;
			}

			// Random direction
			this.Info.FigureC = (byte)rnd.Next(256);

			// Add item to region
			region.AddItem(this);
		}
开发者ID:tkiapril,项目名称:aura,代码行数:76,代码来源:Item.cs

示例2: Drop

		/// <summary>
		/// Drops item in location with a new entity id.
		/// </summary>
		/// <param name="region"></param>
		/// <param name="pos"></param>
		public void Drop(Region region, Position pos)
		{
			var rnd = RandomProvider.Get();

			// Get random drop position
			var x = rnd.Next(pos.X - DropRadius, pos.X + DropRadius + 1);
			var y = rnd.Next(pos.Y - DropRadius, pos.Y + DropRadius + 1);

			//this.SetNewEntityId();
			this.Move(region.Id, x, y);

			// Keys don't disappear (?)
			if (!this.HasTag("/key/"))
				this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60));

			region.AddItem(this);
		}
开发者ID:xKamuna,项目名称:aura,代码行数:22,代码来源:Item.cs


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