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


C# Creature.GetPosition方法代码示例

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


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

示例1: OnUse

	public override void OnUse(Creature creature, Item item)
	{
		// Avon Feather
		if (item.HasTag("/feather_of_avon/"))
		{
			var regionId = item.MetaData1.GetInt("AFRR");
			var x = item.MetaData1.GetInt("AFRX");
			var y = item.MetaData1.GetInt("AFRY");
			var lastWarp = item.MetaData1.GetDateTime("AFLU");
			var inAvon = (creature.RegionId == AvonRegionId);
			var pos = creature.GetPosition();

			// Stop if on cooldown or creature is in a temp region
			if (DateTime.Now < lastWarp.AddMinutes(AvonCoolDown) || creature.Region.IsTemp)
			{
				Send.ServerMessage(creature, L("Safety error, failed to warp."));
				return;
			}

			// Don't warp if it's the first time and the creature already
			// is in Avon, or if creature already is in the target region.
			if ((regionId == 0 && creature.RegionId == AvonRegionId) || creature.RegionId == regionId)
			{
				Send.ServerMessage(creature, L("Region error, failed to warp."));
				return;
			}

			// Update feather's destination
			item.MetaData1.SetInt("AFRR", creature.RegionId);
			item.MetaData1.SetInt("AFRX", inAvon ? AvonX : pos.X);
			item.MetaData1.SetInt("AFRY", inAvon ? AvonY : pos.Y);
			item.MetaData1.SetLong("AFLU", DateTime.Now);
			Send.ItemUpdate(creature, item);

			// Warp, default to Avon if region is 0
			if (regionId == 0)
				creature.Warp(AvonRegionId, AvonX, AvonY);
			else
				creature.Warp(regionId, x, y);

			return;
		}

		// A few items prepare a skill, instead of sending use, to reduce
		// redundancy we'll call into the skill handler.
		HiddenTownBack.Warp(creature, item);
	}
开发者ID:tkiapril,项目名称:aura,代码行数:47,代码来源:warp_scroll.cs

示例2: UseMoonGate

	private bool UseMoonGate(Creature creature, string origin, string destination)
	{
		// Check locations
		if (origin == destination)
		{
			Send.Notice(creature, Localization.Get("You cannot teleport using the same Moon Gate."));
			return false;
		}

		// Check gates
		MoonGate originGate, destinationGate;
		if (!gatesStr.TryGetValue(origin, out originGate) || !gatesStr.TryGetValue(destination, out destinationGate))
		{
			Send.Notice(creature, Localization.Get("This moon gate is currently not operable. Please report."));
			return false;
		}

		// Check origin gate
		if (originGate.Prop.State == "closed")
		{
			// Don't log, someone could be waiting with the map open and
			// select a destination too late.
			return false;
		}

		// Check range to origin gate
		if (creature.RegionId != originGate.Prop.Info.Region || !creature.GetPosition().InRange(originGate.Prop.GetPosition(), 1000))
		{
			// Could happen due to desync? The range at least.
			Send.Notice(creature, L("You're too far away."));
			return false;
		}

		// Check if char has target
		if (!CanWarpTo(creature, destinationGate))
		{
			Log.Warning("MoongateScript.MoonGateUse: Creature '{0:X16}' tried to warp to moon gate that he can't use.", creature.EntityId);
			return false;
		}

		creature.Warp(destinationGate.Prop.GetLocation());

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

示例3: GetAimChance

		/// <summary>
		/// Returns the chance to hit target at the current aim time.
		/// </summary>
		/// <param name="target"></param>
		/// <returns></returns>
		public double GetAimChance(Creature target)
		{
			// Check collision, 0 chance if the client didn't prevent this shot.
			if (this.Creature.Region.Collisions.Any(this.Creature.GetPosition(), target.GetPosition()))
			{
				// Only warn, could be caused by lag.
				Log.Warning("GetAimChance: Creature '{0:X16}' tried to shoot through a wall.", this.Creature.EntityId);
				return 0;
			}

			var activeSkill = this.Creature.Skills.ActiveSkill;
			var activeSkillId = (activeSkill == null ? SkillId.None : activeSkill.Info.Id);

			var d1 = 5000.0;
			var d2 = 500.0;

			if (activeSkill != null && activeSkill.Info.Id == SkillId.MagnumShot)
			{
				d1 = 8000.0;
				d2 = 1000.0;
			}

			var distance = this.Creature.GetPosition().GetDistance(target.GetPosition());
			var bowRange = this.Creature.RightHand == null ? 0 : this.Creature.RightHand.OptionInfo.EffectiveRange;

			if (distance > bowRange || distance <= 0)
				return 0;

			var aimTime = this.GetAimTime();
			var aimMod = aimTime;

			// Bonus for ranged attack
			if (activeSkillId == SkillId.RangedAttack || activeSkillId == SkillId.SupportShot || activeSkillId == SkillId.ArrowRevolver || activeSkillId == SkillId.ArrowRevolver2)
			{
				var rangedSkill = this.Creature.Skills.Get(SkillId.RangedAttack);
				if (rangedSkill != null)
					aimMod *= rangedSkill.RankData.Var3 / 100f;
			}

			var hitRatio = 1.0;
			hitRatio = ((d1 - d2) / bowRange) * distance * hitRatio + d2;

			var chance = Math.Sqrt(_aimOffset * _aimOffset + aimMod / hitRatio) * 100f;

			// Arrow Revolver bonus
			if (activeSkillId == SkillId.ArrowRevolver2 && activeSkill.Stacks == activeSkill.RankData.StackMax)
				chance += activeSkill.RankData.Var3;

			// Aim chance for moving elf caps at 50%
			if (this.Creature.IsMoving && this.Creature.IsElf)
			{
				if (chance > 50f)
					chance = 50f;
			}

			// 100% after x time (unofficial)
			if (chance >= 120)
				chance = 100;
			else
				chance = Math.Min(99, chance);

			if (target.IsMoving)
			{
				if (target.IsWalking)
					chance = Math.Min(MaxChanceWalking, chance);
				else
					chance = Math.Min(MaxChanceRunning, chance);
			}

			// Debug for devCATs
			if (this.Creature.Titles.SelectedTitle == TitleId.devCAT)
				Send.ServerMessage(this.Creature, "Debug: Aim {0}, Distance {1}, Time {2}", chance, distance, aimTime);

			return chance;
		}
开发者ID:tkiapril,项目名称:aura,代码行数:80,代码来源:AimMeter.cs


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