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


C# Position.GetRandomInRange方法代码示例

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


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

示例1: OnCleared

	public override void OnCleared(Dungeon dungeon)
	{
		var rnd = RandomProvider.Get();
		var end = dungeon.Generator.Floors[0].MazeGenerator.EndPos;
		var endX = end.X * Dungeon.TileSize + Dungeon.TileSize / 2;
		var endY = end.Y * Dungeon.TileSize + Dungeon.TileSize / 2;
		var center = new Position(endX, endY + Dungeon.TileSize * 2);
		var region = dungeon.Regions.Last();

		for (int i = 0; i < 150; ++i)
		{
			var item = Item.CreateGold(rnd.Next(500, 1000 + 1));
			item.Drop(region, center.GetRandomInRange(500, 1000, rnd));
		}

		for (int i = 0; i < 50; ++i)
		{
			var item = Item.CreateCheck(rnd.Next(1, 4 + 1) * 10000);
			item.Drop(region, center.GetRandomInRange(500, 1000, rnd));
		}
	}
开发者ID:ripxfrostbite,项目名称:aura,代码行数:21,代码来源:tircho_alby_whiteday_dungeon.cs

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

示例3: DropGold


//.........这里部分代码省略.........
			if (rnd.NextDouble() >= goldDropChance)
				return;

			// Random base amount
			var amount = rnd.Next(this.Drops.GoldMin, this.Drops.GoldMax + 1);

			// Add global bonus
			float goldDropBonus;
			if (ChannelServer.Instance.GameEventManager.GlobalBonuses.GetBonusMultiplier(GlobalBonusStat.GoldDropAmount, out goldDropBonus, out bonuses))
				amount = (int)(amount * goldDropBonus);

			if (amount > 0)
			{
				var finish = LuckyFinish.None;

				// Lucky Finish
				var luckyChance = rnd.NextDouble();

				// Sunday: Increase in lucky finish.
				// +5%, bonus is unofficial.
				if (ErinnTime.Now.Month == ErinnMonth.Imbolic)
					luckyChance += 0.05;

				var hugeLuckyFinishChance = ChannelServer.Instance.Conf.World.HugeLuckyFinishChance;
				var bigLuckyFinishChance = ChannelServer.Instance.Conf.World.BigLuckyFinishChance;
				var luckyFinishChance = ChannelServer.Instance.Conf.World.LuckyFinishChance;

				// Add global bonus
				float luckyDropBonus;
				if (ChannelServer.Instance.GameEventManager.GlobalBonuses.GetBonusMultiplier(GlobalBonusStat.LuckyFinishRate, out luckyDropBonus, out bonuses))
				{
					hugeLuckyFinishChance *= luckyDropBonus;
					bigLuckyFinishChance *= luckyDropBonus;
					luckyFinishChance *= luckyDropBonus;
				}

				if (luckyChance < hugeLuckyFinishChance)
				{
					amount *= 100;
					finish = LuckyFinish.Lucky;

					Send.CombatMessage(killer, Localization.Get("Huge Lucky Finish!!"));
					Send.Notice(killer, Localization.Get("Huge Lucky Finish!!"));
				}
				else if (luckyChance < bigLuckyFinishChance)
				{
					amount *= 5;
					finish = LuckyFinish.BigLucky;

					Send.CombatMessage(killer, Localization.Get("Big Lucky Finish!!"));
					Send.Notice(killer, Localization.Get("Big Lucky Finish!!"));
				}
				else if (luckyChance < luckyFinishChance)
				{
					amount *= 2;
					finish = LuckyFinish.HugeLucky;

					Send.CombatMessage(killer, Localization.Get("Lucky Finish!!"));
					Send.Notice(killer, Localization.Get("Lucky Finish!!"));
				}

				// If lucky finish
				if (finish != LuckyFinish.None)
				{
					// Event
					ChannelServer.Instance.Events.OnCreatureGotLuckyFinish(killer, finish, amount);

					// Sunday: Increase in lucky bonus.
					// +5%, bonus is unofficial.
					if (ErinnTime.Now.Month == ErinnMonth.Imbolic)
						amount = (int)(amount * 1.05f);
				}

				// Drop rate muliplicator
				amount = Math.Min(21000, Math2.MultiplyChecked(amount, ChannelServer.Instance.Conf.World.GoldDropRate));

				// Drop stack for stack
				var i = 0;
				var pattern = (amount == 21000);
				do
				{
					Position dropPos;
					if (!pattern)
					{
						dropPos = pos.GetRandomInRange(Item.DropRadius, rnd);
					}
					else
					{
						dropPos = new Position(pos.X + CreatureDrops.MaxGoldPattern[i, 0], pos.Y + CreatureDrops.MaxGoldPattern[i, 1]);
						i++;
					}

					var gold = Item.CreateGold(Math.Min(1000, amount));
					gold.Drop(this.Region, dropPos, 0, killer, false);

					amount -= gold.Info.Amount;
				}
				while (amount > 0);
			}
		}
开发者ID:aura-project,项目名称:aura,代码行数:101,代码来源:Creature.cs


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